0

I am able to get the tx id (or transaction hash) of almost any transaction but the one where the script starts with an "OP_O" (which is, I think, the null dummy introduced here https://github.com/bitcoin/bitcoin/pull/3843)

For example:

https://www.blockchain.com/btc/tx/97d1b00fcef1f19531a19bb1722635341a9f2ad261ecf6eed89eca2cbd3bb3ee

How am I suppose to get the txid of this transaction? And how is it different from a regular (without multisig) one?

1

How am I suppose to get the txid of this transaction?

The same way you get the txid of any other transaction, by hashing it (unless it is segwit). Note that the transaction you linked to is not a segwit transaction, so you can just take its hash.

If the transaction is a segwit transaction (as indicated by the marker and flag bytes of 0x0001 following the version bytes), then you need to only hash the parts that are non-segwit. Specifically, you drop all of the segwit parts (so the marker and flag and any witnesses which can be found between the last output and the locktime), and hash what is left. This is described in BIP 144.

And how is it different from a regular (without multisig) one?

There isn't.

  • Thank you, I will double-check my code. I tested it on a full block (about 2k txs) and the only times the txid didn't match (20 times) was when a "OP_0" appeared in one of the inputs scripts. – Kevin P Oct 24 '18 at 18:07
  • Also, I don't simply hash the transaction as it is. I parse it, store all its elements in a data structure, and then append them back and hash them (I use the tx id as an error check). – Kevin P Oct 24 '18 at 18:11
  • OP_0 is used in segwit transactions too, so that may be your problem. – Andrew Chow Oct 24 '18 at 19:30
  • Problem solved: I had a problem with my "varint" function... Thank you! – Kevin P Oct 25 '18 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.