Complete definition of 'tx_witness' data structure used in 'tx' data structure

0

I'm reading the Protocol Documentation page for the 'tx' data structure and cannot find a completely clear definition of the 'tx_witness' data structure.

After the 'tx_out' table, there is short comment stating that "The TxWitness structure consists of a var_int count of witness data components, followed by (for each witness data component) a var_int length of the component and the raw component data itself."

Could someone post a table, similar to others on the Protocol Documentation page, defining clearly how a 'tx_witness' data structure should be formed?

Matthew Charles Stannard

Posted 2018-01-18T20:15:07.757

Reputation: 625

Answers

1

In Bitcoin Core, the scriptWitness property (for the CTxIn class) is serialized from a CTransaction as a std::vector<std::vector<unsigned char> >, so I would imagine the serialized version would look something like:

TxWitness:

+------------+-------------------------+------------------------+
| Field Size |        Description      |       Data Type        |
+------------+-------------------------+------------------------+
| 0+         | witness_component count | var_int                |
| ?          | witness_components      | witness_component[]    |
+------------+-------------------------+------------------------+

WitnessComponent:

+------------+------------------+-----------+
| Field Size |   Description    | Data Type |
+------------+------------------+-----------+
| 0+         | component length | var_int   |
| ?          | component        | uchar[]   |
+------------+------------------+-----------+

References:

Tony Rizko

Posted 2018-01-18T20:15:07.757

Reputation: 308