4

BIP141 says wtxid is SHA256 of [nVersion][marker][flag][txins][txouts][witness][nLockTime]. Is data that hashed as txid includes witness?

And will txid be presented in block, e.g. be counted when building Merkle tree?

4

Is data that hashed as txid includes witness?

No, the txid is the hash of just [nVersion][txins][txouts][nLockTime] which is the same as a serialized non-witness transaction. That means the signature is not included in the transaction hash, removing the potential for TXID malleability due to mauling the signature. Only WTXID contains the witness, marker and flag as you wrote in your post.

And will txid be presented in block, e.g. be counted when building Merkle tree?

Yes, the transaction ID is used in the same way that non-segwit TXIDs are used when building the merkle tree.

  • Are SegWit txins have different data structure with non-SegWit txins, like SegWit txins doesn't include ScriptSig but non-SegWit txins do? – fjchen Nov 6 '17 at 5:03
  • 1
    Segwit inputs still have a ScriptSig as all inputs must have one. However those ScrtiptSigs will just be empty. Transactions that spend from Segwit outputs will have a slightly different structure; there will be an additional field following the outputs for the witness data. See BIP 144: github.com/bitcoin/bips/blob/master/bip-0144.mediawiki – Andrew Chow Nov 6 '17 at 5:57

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.