Parsing a SegWit transaction - what is the size of witness data? I'm parsing s SegWit transaction, I got it done until i reach the witness data.
How big is the witness data?
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 &gt; 0 {
        for each stackItem {
            bytes = read integer
            //witness data is bytes long
        }
    }
}