4

I'm parsing s SegWit transaction, I got it done until i reach the witness data.
How big is the witness data?

1 Answer 1

4

I found it:

Each witness field starts with a compactSize integer to indicate the number of stack items for the corresponding txin. It is then followed by witness stack item(s) for the corresponding txin, if any.

Each witness stack item starts with a compactSize integer to indicate the number of bytes of the item.

If a txin is not associated with any witness data, its corresponding witness field is an exact 0x00, indicating that the number of witness stack items is zero.

for each input {
    stackItems = read integer
    if stackItems > 0 {
        for each stackItem {
            bytes = read integer
            //witness data is bytes long
        }
    }
}
2
  • Do you know the databytes regarding "stackItems" and "bytes"? Commented Dec 20, 2017 at 13:02
  • The stackItems must NOT be read. It is the txInCount! And the "bytes" is CompactSize Unsigned Integer value. fyi - see bitcoincore.org/en/segwit_wallet_dev Commented Dec 20, 2017 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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