You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
get_transactions() doesn't get segwit transactions #93
I am trying to use get_transactions() to get segwit transactions. If I put "private_key.get_transactions()" it thinks I am looking for the transactions associated with the LEGACY address of that private key.
Is there a flag to give to "get_transactions()" to make it look for transactions associated with the segwit address of the private key? Like Ex... "private_key.get_transactions(segwit_address)"
Edit
I ran this through the debugger and walked through the get_transactions method in wallet.py step by step and I discovered that get_transactionsis properly detecting that the transactions are through the private key's segwit address. The txids it fetches are wrong though. I'm not sure why.
@bjarnemagnussen I just reproduced the bug. When I run get_transactions() on the segwit (testnet) address '2MwxwQoEgQsdKFDFUr1xXKavY59rZLhxptT', where privKey == PrivateKeyfor('2MwxwQoEgQsdKFDFUr1xXKavY59rZLhxptT'), I do privKey.get_transactions(). and I get the following array ['65d89b1aee0818c082d5dba5020531b6c6ec61f7a4014df110b3fd645bd37d12', '0c5951a0cba0da6709e3d6caff52dc349102f48a85acb506d8690753d4deb187'].
There is only 1 transaction for the private key of the address '2MwxwQoEgQsdKFDFUr1xXKavY59rZLhxptT' and it is 'f825688b407d6dd0433f91a3d9af490cfe57b9b8014b4a2ded68d50dfa8fb01e' NOT '65d89b1aee0818c082d5dba5020531b6c6ec61f7a4014df110b3fd645bd37d12' or '0c5951a0cba0da6709e3d6caff52dc349102f48a85acb506d8690753d4deb187'
When I run get_transactions() on the non-segwit (testnet) address 'mquSX2dazgEdN1CEC1eB2aNQ4upB5B9uSG', where privKey == PrivateKeyfor('mquSX2dazgEdN1CEC1eB2aNQ4upB5B9uSG'), I do privKey.get_transactions(). and I get the following array ['c9ba98708ad79782ea4865a1dbb0850d25cddcfaeffb754bf3a286dc4deeea40', '9c1e7214e418905ef9e9799ad8076c1f8f0348ebabfd80643ac28ae30887fb79'].
'c9ba98708ad79782ea4865a1dbb0850d25cddcfaeffb754bf3a286dc4deeea40' is the correct TXID for the address 'mquSX2dazgEdN1CEC1eB2aNQ4upB5B9uSG'.
So it seems like get_transactions() only fetches the correct TXID for non-segwit transactions. Is there a way to fix this? Or maybe a work around it to get segwit TXIDs?
P.S. these transactions that I'm fetching include an OP_RETURN value. Maybe that's what is throwing the ofek/bit off? Also, I am not sure what the second number is in the arrays. Maybe it has something to do with the OP_RETURN values?
Currently we only use the APIs provided by Bitpay and Smartbit for the test network. But Bitpay is currently down and it therefore falls back to Smartbit only.
I think I have identified a bug in Bit when it is polling the webAPI "Smartbit" for all transactions of an address. It returns the transaction hashes instead of ids:
This explains why polling the non-segwit address gave you a correct txid, as for non-segwit it is the same as the txhash (in most cases).
Regarding the fact that you received two transactions when polling for the segwit address "2MwxwQoEgQsdKFDFUr1xXKavY59rZLhxptT": Are you sure that you did poll that address? Because the address has received funds from another segwit address "2MuWhT3LGwP49E2n2yH5UcZmz4G4yo38gnk" that contains exactly those two address hashes.
Long story short: I will commit a fix to the polling of "Smartbit" ASAP and hopefully it will fix it. If not please re-open this issue!
Activity
bjarnemagnussen commentedon Jan 22, 2020
Hi and sorry for the delay.
Can you post a Segwit address that when used with
get_transactionsreturns wrong txids?Also just to be sure that this did not cause the mistake: With Segwit the txid != txhash.
ChristianOConnor commentedon Jan 27, 2020
@bjarnemagnussen I just reproduced the bug. When I run get_transactions() on the segwit (testnet) address '2MwxwQoEgQsdKFDFUr1xXKavY59rZLhxptT', where privKey == PrivateKeyfor('2MwxwQoEgQsdKFDFUr1xXKavY59rZLhxptT'), I do privKey.get_transactions(). and I get the following array ['65d89b1aee0818c082d5dba5020531b6c6ec61f7a4014df110b3fd645bd37d12', '0c5951a0cba0da6709e3d6caff52dc349102f48a85acb506d8690753d4deb187'].
There is only 1 transaction for the private key of the address '2MwxwQoEgQsdKFDFUr1xXKavY59rZLhxptT' and it is 'f825688b407d6dd0433f91a3d9af490cfe57b9b8014b4a2ded68d50dfa8fb01e' NOT '65d89b1aee0818c082d5dba5020531b6c6ec61f7a4014df110b3fd645bd37d12' or '0c5951a0cba0da6709e3d6caff52dc349102f48a85acb506d8690753d4deb187'
When I run get_transactions() on the non-segwit (testnet) address 'mquSX2dazgEdN1CEC1eB2aNQ4upB5B9uSG', where privKey == PrivateKeyfor('mquSX2dazgEdN1CEC1eB2aNQ4upB5B9uSG'), I do privKey.get_transactions(). and I get the following array ['c9ba98708ad79782ea4865a1dbb0850d25cddcfaeffb754bf3a286dc4deeea40', '9c1e7214e418905ef9e9799ad8076c1f8f0348ebabfd80643ac28ae30887fb79'].
'c9ba98708ad79782ea4865a1dbb0850d25cddcfaeffb754bf3a286dc4deeea40' is the correct TXID for the address 'mquSX2dazgEdN1CEC1eB2aNQ4upB5B9uSG'.
So it seems like get_transactions() only fetches the correct TXID for non-segwit transactions. Is there a way to fix this? Or maybe a work around it to get segwit TXIDs?
P.S. these transactions that I'm fetching include an OP_RETURN value. Maybe that's what is throwing the ofek/bit off? Also, I am not sure what the second number is in the arrays. Maybe it has something to do with the OP_RETURN values?
bjarnemagnussen commentedon Jan 28, 2020
Thanks for the example which was very helpful.
Currently we only use the APIs provided by Bitpay and Smartbit for the test network. But Bitpay is currently down and it therefore falls back to Smartbit only.
I think I have identified a bug in Bit when it is polling the webAPI "Smartbit" for all transactions of an address. It returns the transaction hashes instead of ids:
bit/bit/network/services.py
Line 362 in 10b9aa6
This explains why polling the non-segwit address gave you a correct txid, as for non-segwit it is the same as the txhash (in most cases).
Regarding the fact that you received two transactions when polling for the segwit address "2MwxwQoEgQsdKFDFUr1xXKavY59rZLhxptT": Are you sure that you did poll that address? Because the address has received funds from another segwit address "2MuWhT3LGwP49E2n2yH5UcZmz4G4yo38gnk" that contains exactly those two address hashes.
Long story short: I will commit a fix to the polling of "Smartbit" ASAP and hopefully it will fix it. If not please re-open this issue!
Fixes Smartbit when fecthing all transactions
ofek commentedon Jan 28, 2020
Nicely done 🙇♂️
ChristianOConnor commentedon Jan 29, 2020
Awesome thanks @bjarnemagnussen ! For everything! Great job!