user71255: 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?

user74555: 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:

https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h#L67
https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h#L254
https://github.com/bitcoin/bitcoin/blob/master/src/script/script.h#L676


71255: <p>I'm reading the <a href="https://en.bitcoin.it/wiki/Protocol_documentation#tx" rel="nofollow noreferrer">Protocol Documentation</a> page for the 'tx' data structure and cannot find a completely clear definition of the 'tx_witness' data structure.</p>

<p>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."</p>

<p>Could someone post a table, similar to others on the Protocol Documentation page, defining clearly how a 'tx_witness' data structure should be formed?</p>
 74555: <p>In Bitcoin Core, the <code>scriptWitness</code> property (for the <code>CTxIn</code> class) is serialized from a <code>CTransaction</code> as a <code>std::vector&lt;std::vector&lt;unsigned char&gt; &gt;</code>, so I would imagine the serialized version would look something like:</p>

<p>TxWitness:
</p>

<pre><code>+------------+-------------------------+------------------------+
| Field Size |        Description      |       Data Type        |
+------------+-------------------------+------------------------+
| 0+         | witness_component count | var_int                |
| ?          | witness_components      | witness_component[]    |
+------------+-------------------------+------------------------+
</code></pre>

<p>WitnessComponent:
</p>

<pre><code>+------------+------------------+-----------+
| Field Size |   Description    | Data Type |
+------------+------------------+-----------+
| 0+         | component length | var_int   |
| ?          | component        | uchar[]   |
+------------+------------------+-----------+
</code></pre>

<p>References:</p>

<ul>
<li><a href="https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h#L67" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h#L67</a></li>
<li><a href="https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h#L254" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h#L254</a></li>
<li><a href="https://github.com/bitcoin/bitcoin/blob/master/src/script/script.h#L676" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/master/src/script/script.h#L676</a></li>
</ul>
