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

Your Answer

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

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