I'm parsing s SegWit transaction, I got it done until i reach the witness data.
How big is the witness data?
1 Answer
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
}
}
}
-
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