EdgeApp / airbitz-core

Bitcoin wallet C/C++ API for building cross-platform applications that require user authentication, encryption, backup, and meta-data management. This library alone implements the full functionality of the Airbitz Edge Security platform and bitcoin wallet minus the graphical interface.
https://airbitz.co
Other
81 stars 43 forks source link

Fixed txid for Segwit Transactions #27

Closed thehobbit85 closed 6 years ago

thehobbit85 commented 6 years ago

When using the function bc::hash_transaction, there is a second optional param for the sighash type, and the default is all, but for segwit tx's it should be anyone_can_pay.

So instead of trying to get the txid using the function, we get it from the txid inside the metadata or from the electrum servers. Only if we never got it, then we will try to calculate it the old way.

paullinator commented 6 years ago

I don’t see anywhere where this changes the sighash type. How is using the passed in txid change anything?

thehobbit85 commented 6 years ago

You are right, there is no change to the sighash type. If you follow the commit, you will notice that it should never even try to calculate the txid and the if statement is there just in case. The Txids we are getting from electrum are correct, the problem only happened when we recalculated the txid ourselves and then we got a different hash then the one we got from the servers. Thats why passing it along solves it.