# Elements Transaction Format

This document describes the format used to serialize Elements transactions. Once a transaction has been converted into this raw, serialized form, it can be broadcast across the network.

This document assumes some familiarity with Bitcoin and Elements (UTXOs, [Script](https://en.bitcoin.it/wiki/Script), assets, peg-ins, etc.). For more information on those, please refer to the [Bitcoin Wiki](https://en.bitcoin.it/wiki/Main_Page) and the [Elements Code Tutorial](https://elementsproject.org/elements-code-tutorial/overview).

### Data Types

*Notes*:
* Fields in the following table are listed in the same order in which they are serialized.

* The *Encoding* column in the following tables indicates how the fields are serialized.

* All values are defined in terms of the smallest indivisible unit. For example, a value of 1 L-BTC would be defined as 100,000,000 (L-Satoshis).

#### Transaction

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Version | Yes | 4 bytes | `int32_t` | Little-endian | Transaction version number. Currently version 2 (see [BIP 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki#specification)). | |
| Flags | Yes | 1 byte | `unsigned char` | | 1 if the transaction contains a witness, otherwise 0. All other values are invalid. |
| Num Inputs | Yes | Varies | `VarInt` | | Number of inputs to the transaction. |
| Inputs | Yes | Varies | `Vector<TxIn>` | | |
| Num Outputs | Yes | Varies | `VarInt` | | Number of outputs from the transaction. |
| Outputs | Yes | Varies | `Vector<TxOut>` | | |
| Locktime | Yes | 4 bytes | `uint32_t` | Little-endian | See [BIP 113](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki). |
| Witness | Only if flags is 1 | Varies | `Witness` | | See [BIP 141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki). Note that Elements witnesses contain more data than Bitcoin witnesses. This extra data is described further below. |

Notable differences from Bitcoin:
- In Bitcoin the *Flags* field is optional and it is two bytes long. In Elements, this field is mandatory and it is reduced to one byte.
- In Bitcoin, only inputs have witnesses. In Elements, each output also has a witness section associated with it.
- In Bitcoin transactions the *Locktime* appears immediately after the witnesses, whereas in Elements transactions it appears right before them.

This is the overarching structure of a serialized transaction. The rest of this document contains further details on specific parts, as well as examples.

#### Variable Length Integer (VarInt)

This data type is derived from Bitcoin, and allows an integer to be encoded with a variable length (which depends on the represented value), in order to save space.
Variable length integers always precede a vector of a type of data that may vary in length and are used to indicate this length.
Longer numbers are encoded in little-endian.

| Value | Size | Format | Example |
| ----- | ---- | ------ | ------- |
| < `0xFD` | 1 byte | `uint8_t` | `0x0F` = 15 |
| <= `0xFFFF` | 3 bytes | `0xFD` followed by the number as a `uint16_t` | `0xFD 00FF` = 65 280 |
| <= `0xFFFF FFFF` | 5 bytes | `0xFE` followed by the number as a `uint32_t` | `0xFE 0000 00FF` = 4 278 190 080 |
| <= `0xFFFF FFFF FFFF FFFF` | 9 bytes | `0xFF` followed by the number as a `uint64_t` | `0xFF 0000 0000 0000 00FF` = 18 374 686 479 671 623 680 |

#### Vector\<Type\>

Each `Vector` begins with a `VarInt` describing the number of items it contains.

If the vector is of type `hex`, then the size / structure of each individual item is not known in advance. In this case, each item begins with a `VarInt` describing its size `s` in bytes, followed by `s` bytes which should be interpreted as the item itself.
Otherwise, size prefixes are omitted, and each item should be interpreted in accordance with the vector's type.

In other words, the vector is serialized as follows: `[Length (n)][Item #1][Item #2][...][Item #n]`.

Refer to the examples section below for more concrete examples of serialized vectors.

#### TxIn

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Output Hash (TXID) | Yes | 32 bytes | `hex` | [^1] | |
| Output Index | Yes | 4 bytes | `uint32_t` | Little-endian | **Input is a coinbase**: `0xffffffff`<br><br>The two most significant bits are reserved for flags.<br><br>**Input is a peg-in:** second most significant bit is 1.<br><br>**Input has an asset issuance:** most significant bit is 1. |
| ScriptSig Length | Yes | Varies | `VarInt` | | Set to `0x00` if the transaction is SegWit and the witness contains the signature. |
| ScriptSig | If ScriptSig Length is non-zero | Varies | `hex` | | |
| Sequence | Yes | 4 bytes | `uint32_t` | Little-endian | |
| Asset Issuance | Only if the transaction has an issuance (as indicated by the Output Index) | Varies | `AssetIssuance` |  | |

[^1]: The hex encodings of hashes by the Elements client (TXID, asset ID) are byte-reversed, and so the bytes will need to be re-reversed to match the serialized data. This is the same situation as in Bitcoin. For example, the hash `1123...deff` would be displayed by the Bitcoin and Elements clients as `ffde...2311`. This is primarily for historical reasons: the Bitcoin client has always interpreted and displayed hashes as little-endian integers and parsed their bytes in reverse order.

Notable differences from Bitcoin:
- In Elements, the *Output Index* field uses the two most significant bits to flag if the transaction is a peg-in transaction (1 << 30) or if it is an issuance (1 << 31). If these flags are present, they must be removed to refer to the output's index.
- Inputs can allow for the issuance of new assets or for reissuances of these assets. To create a new asset, any input being spent can be used and a 0 value must be used in the issuance's blinding nonce field. To reissue an asset, the asset blinding factor is used in the issuance's blinding nonce field, and the asset being spent must be of the reissuance token's asset type.

#### TxOut

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Asset | Yes | 33 bytes | `ConfidentialAsset` | | Cannot be null. |
| Amount | Yes | 9 or 33 bytes | `ConfidentialAmount` | | Cannot be null. |
| Nonce | Yes | 1 or 33 bytes | `ConfidentialNonce` | | |
| ScriptPubKey Length | Yes | Varies | `VarInt` | | | |
| ScriptPubKey | If ScriptPubKey Length is non-zero | Varies | `hex` | | |

#### Witness

As noted above, the witness is only present for SegWit transactions.

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Input Witnesses | Yes | Varies | `Vector<InputWitness>` | | There is exactly one input witness for each input in the transaction.<br><br>This number is not explicitly included in the witness — it is implied by the number of inputs. |
| Output Witnesses | Yes | Varies | `Vector<OutputWitness>` | | There is exactly one output witness for each output in the transaction.<br><br>This number is not explicitly included in the witness — it is implied by the number of outputs. |

#### InputWitness

SegWit transactions have one such witness for each input.

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Issuance Amount Range Proof | Yes | Varies | `Proof` | | `0x00` → null. |
| Inflation Keys Range Proof | Yes | Varies | `Proof` | | `0x00` → null. |
| Script Witness | Yes | Varies | `Vector<hex>` | | The vector represents the witness stack.<br>Can be empty (length of 0). |
| Peg-in Witness | Yes | Varies | `Vector<hex>` | | The vector represents the witness stack.<br>Can be empty (length of 0). |

The range proofs must be empty if their associated amounts (issuance / inflation keys) are explicit.
Refer [here](https://elementsproject.org/features/confidential-transactions/investigation) for more details on range proofs.

A non-empty peg-in witness stack should always have a length of 6, and the items should be interpreted as follows:

1. The little-endian 64-bit value of the peg-in for the peg-in transaction.
2. Asset ID of the asset being pegged in.
3. The 32 byte genesis hash of the blockchain which originated the peg-in.
4. Claim script for the peg-in transaction.
5. The mainchain peg-in transaction serialized without witnesses.
6. Merkle proof of transaction inclusion, from the mainchain.

See *Example #3* in the Examples section below for a concrete example.

Notable differences from Bitcoin:
- Each input witness has four fields, rather than just one witness stack.

#### OutputWitness

SegWit transactions have one such witness for each output.

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Surjection Proof | Yes | Varies | `Proof` | | A non-null value indicates that the corresponding output's asset is blinded. |
| Range Proof | Yes | Varies | `Proof` | | A non-null value indicates that the corresponding output's value is blinded. |

It is possible for an output's asset to be blinded but not its value, and vice-versa.

More details:
- [Confidential Assets](https://blockstream.com/bitcoin17-final41.pdf)
- [Range Proofs](https://elementsproject.org/features/confidential-transactions/investigation)
- [Surjection Proofs](https://github.com/ElementsProject/elements/blob/master/src/secp256k1/src/modules/surjection/surjection.md)
#### AssetIssuance

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Asset Blinding Nonce | Yes | 32 bytes | `hex` | | Zero for a new asset issuance; otherwise a blinding factor for the input. |
| Asset Entropy | Yes | 32 bytes | `hex` | | **New issuances:** Freeform entropy field, no consensus-defined meaning, but is used as additional entropy to the asset tag calculation.<br><br>**Reissuances:** Required to be the asset's entropy value (from its initial issuance). |
| Amount | Yes | 1 or 9 or 33 bytes | `ConfidentialAmount` | | Amount of the asset to issue. Both explicit and blinded amounts are supported.<br><br>**Note**: cannot be explicitly set to 0 (should be null instead). |
| Num Inflation Keys | Yes | 1 or 9 or 33 bytes | `ConfidentialAmount` | | Number of inflation keys to issue. Both explicit and blinded amounts are supported.<br><br>**Notes:**<br>  - Cannot be explicitly set to 0 (should be null instead).<br>  - Inflation keys cannot be reissued. |

#### ConfidentialAsset

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Header | Yes | 1 byte | | | A header byte of `0x00` indicates a “null” value with no subsequent bytes.<br><br>A header byte of `0x01` indicates an “explicit” value with the following 32 bytes denoting the key used to generate the asset ID (little-endian).<br><br>A header byte of `0x0a` or `0x0b` indicates a blinded value encoded as a compressed elliptic curve point. With the least significant bit of the header byte denoting the least significant bit of the y-coordinate, and the remaining 32 bytes denoting the x-coordinate (big-endian). The point must be a point on the curve. |
| Value | If header byte is not `0x00` | 32 bytes | `hex` | Depends on header byte | |

#### ConfidentialAmount

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Header | Yes | 1 byte | | | A header byte of `0x00` indicates a “null” value with no subsequent bytes.<br><br>A header byte of `0x01` indicates an “explicit” value with the following 8 bytes denoting a 64-bit value (big-endian).  This value must be between 0 and `MAX_MONEY` inclusive.<br><br>A header byte of `0x08` or `0x09` indicates a blinded value encoded as a compressed elliptic curve point. With the least significant bit of the header byte denoting the least significant bit of the y-coordinate, and the remaining 32 bytes denoting the x-coordinate (big-endian). The point must be a point on the curve. |
| Value | If header byte is not `0x00` | 8 or 32 bytes | `hex` | Big-endian | |

#### ConfidentialNonce

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Header | Yes | 1 byte | | | A header byte of `0x00` indicates a “null” value with no subsequent bytes.<br><br>A header byte of `0x01` indicates an “explicit” value with the following 32 bytes denoting a value (big-endian).<br><br>A header byte of `0x02` or `0x03` indicates a compressed elliptic curve point. With the least significant bit of the header byte denoting the least significant bit of the y-coordinate, and the remaining 32 bytes denoting the x-coordinate (big-endian). This point is not required to be on the curve. |
| Value | If header byte is not `0x00` | 32 bytes | `hex` | Big-endian | |

#### Proof

| Field | Required | Size | Data Type | Encoding | Notes |
| ----- | -------- | ---- | --------- | -------- | ----- |
| Length | Yes | Varies | `VarInt` | | `0x00` → null. |
| Value | If header byte is not `0x00` | Varies | `hex` | Big-endian | The proof itself. This should be interpreted based on the context (surjection proof, range proof, etc). |
## Examples

#### Example 1
Signed transaction on liquidtestnet, moving 2 existing tL-BTC outputs into two new outputs with sizes: 0.00055 tL-BTC, 0.01 tL-BTC.

Raw hex:
```
02000000010290683fa6b0393b659df707b65e05cbfdf92cc2688589a0ed4931e8a61dfe64c40000000000ffffffff8d83eb1b0826f46d473003d041116927470e2ce0f7cc0c634a983d438d770ac80000000000ffffffff0201499a818545f6bae39fc03b637f2a4e1e64e590cac1bc3a6f6d71aa4443654c1401000000000000d6d8028272c6d7d23b5d8836daac705b4a312b0ebc03f87290da2ed511a833096f0d8e1600144447cb259b2a9857922c5a19cd6449b227dd6c3501499a818545f6bae39fc03b637f2a4e1e64e590cac1bc3a6f6d71aa4443654c140100000000000f42400372fdd5c6e805a50d73ab15ec41cfaadcbe408ecc7a5867621918f1070f84ec9516001424ae71d4804ca7dd1fa66486a87af9dff1663c8400000000000002463043021f3a851011d5b7b52c9761e8a0bd558f2d43129bd1602ffc30945c0a9eaeeaa4022078763819f41ed3084d88fbd3ccf00f8107db76a431a3c085191e3aceb1cb12b0012103207312a1d3e7c2aa5c5212e18f2fe0095e8d11e9ca78f4acc7f6e40dbd21d2ed0000000247304402203e13aa1c792fc14ff06f2c2269e7fff35dc7710dbd73bca3738d21888f031a72022008f9eeb1ea00a8da358321a23e9cd14f6163f609ba391205d5eadcf47661288f012103daa4c9684c369d4420b9f20e4116362b6a3786e9a12a4e1927d1a25c4ffd931b0000000000
```

Deserialization:
```
02000000 ............................. Version

01 ................................... Flags (0x01 → witness data is present)

02 ................................... Num Inputs
|
|                                      Input #1
| 90683fa6b0393b659df707b65e05cbfd
| f92cc2688589a0ed4931e8a61dfe64c4 ... Outpoint TXID: c464fe1da6e83149eda0898568c22cf9fdcb055eb607f79d653b39b0a63f6890
| 00000000 ........................... Outpoint index
|
| 00 ................................. ScriptSig length
| | .................................. ScriptSig (empty: segwit transaction)
|
| ffffffff ........................... Sequence number: UINT32_MAX
|
|                                      Input #2
| 8d83eb1b0826f46d473003d041116927
| 470e2ce0f7cc0c634a983d438d770ac8 ... Outpoint TXID: c80a778d433d984a630cccf7e02c0e4727691141d00330476df426081beb838d
| 00000000 ........................... Outpoint index
|
| 00 ................................. ScriptSig length
| | .................................. ScriptSig (empty)
|
| ffffffff ........................... Sequence number: UINT32_MAX

02 ................................... Num Outputs
|
|                                      Output #1
| 01 ................................. Asset Header (0x01 → explicit)
| 499a818545f6bae39fc03b637f2a4e1e
| 64e590cac1bc3a6f6d71aa4443654c14 ... Asset ID: 144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49
|
| 01 ................................. Amount header (0x01 → explicit)
| 000000000000d6d8 ................... Amount: 0xd6d8 tL-Satoshis = 0.00055 tL-BTC
|
| 02 ................................. Nonce header (0x02 → compressed point)
| 8272c6d7d23b5d8836daac705b4a312b
| 0ebc03f87290da2ed511a833096f0d8e ... Nonce x-coordinate (big-endian)
|
| 16 ................................. ScriptPubKey length (0x16 = 22 bytes)
| | 00144447cb259b2a9857922c5a19cd
| | 6449b227dd6c35 ................... ScriptPubKey
|
|                                      Output #2
| 01 ................................. Asset header (0x01 → explicit)
| 499a818545f6bae39fc03b637f2a4e1e
| 64e590cac1bc3a6f6d71aa4443654c14 ... Asset ID: 144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49
|
| 01 ................................. Amount header (0x01 → explicit)
| 00000000000f4240 ................... Amount: 0xf4240 tL-Satoshis = 0.01 tL-BTC
|
| 03 ................................. Nonce header (0x03 → compressed point)
| 72fdd5c6e805a50d73ab15ec41cfaadc
| be408ecc7a5867621918f1070f84ec95 ... Nonce x-coordinate (big-endian)
|
| 16 ................................. ScriptPubKey length (0x16 = 22 bytes)
| | 001424ae71d4804ca7dd1fa66486a8
| | 7af9dff1663c84 ................... ScriptPubKey

00000000 ............................. Locktime

...................................... Input witnesses (1 per input)
|
|                                      Input #1 witness
| 00 ................................. Issuance amount range proof (null)
| 00 ................................. Inflation keys range proof (null)
| 02 ................................. Script witness stack length
| | 46 ............................... Stack item #1 length (0x46 = 70 bytes)
| | | 3043021f3a851011d5b7b52c9761
| | | e8a0bd558f2d43129bd1602ffc30
| | | 945c0a9eaeeaa4022078763819f4
| | | 1ed3084d88fbd3ccf00f8107db76
| | | a431a3c085191e3aceb1cb12b001 ... Stack item #1
| | 21 ............................... Stack item #2 length (0x21 = 33 bytes)
| | | 03207312a1d3e7c2aa5c5212e18f
| | | 2fe0095e8d11e9ca78f4acc7f6e4
| | | 0dbd21d2ed ..................... Stack item #2
| 00 ................................. Peg-in witness (0x00 → null)
|
|                                      Input #2 witness
| 00 ................................. Issuance amount range proof (0x00 → null)
| 00 ................................. Inflation keys range proof (0x00 → null)
| 02 ................................. Script witness stack length
| | 47 ............................... Stack item #1 length (0x47 = 71 bytes)
| | | 304402203e13aa1c792fc14ff06f
| | | 2c2269e7fff35dc7710dbd73bca3
| | | 738d21888f031a72022008f9eeb1
| | | ea00a8da358321a23e9cd14f6163
| | | f609ba391205d5eadcf47661288f
| | | 01 ............................. Stack item #1
| | 21 ............................... Stack item #2 length (0x21 = 33 bytes)
| | | 03daa4c9684c369d4420b9f20e41
| | | 16362b6a3786e9a12a4e1927d1a2
| | | 5c4ffd931b ..................... Stack item #2
| 00 ................................. Peg-in witness stack length

...................................... Output witnesses (1 per output)
|
|                                      Output #1 witness
| 00 ................................. Surjection proof length
| 00 ................................. Range proof length
|
|                                      Output #2 witness
| 00 ................................. Surjection proof length
| 00 ................................. Range proof length
```

#### Example 2
Signed transaction issuing 33 units of a new asset on regtest.

Raw hex:
```
[encoded data, 27276 characters]
```

Deserialization:
```
02000000 ............................. Version

01 ................................... Flags (0x01 → witness data is present)

01 ................................... Num inputs
|
|                                      Input #1
| eb87c50cb285fc7262a00ceefda34aaa
| ac951ce5dd3e95c1bc85b7ce6a218ea5 ... Outpoint TXID: a58e216aceb785bcc1953edde51c95acaa4aa3fdee0ca06272fc85b20cc587eb
| 00000080 ........................... Output Index (little-endian → 0x80000000 → most significant bit is 1 → asset issuance)
|
| 00 ................................. ScriptSig length
| | .................................. ScriptSig (empty: segwit transaction)
|
| fdffffff ........................... Sequence number
|
| .................................... Asset issuance
| | 000000000000000000000000000000
| | 000000000000000000000000000000
| | 0000 ............................. Asset blinding nonce (0 for new asset issuance)
| |
| | 000000000000000000000000000000
| | 000000000000000000000000000000
| | 0000 ............................. Asset entropy
| |
| | 01 ............................... Amount header (0x01 → explicit, unblinded value)
| | 00000000c4b20100 ................. Amount: 0xc4b20100 = 3,300,000,000 → 33 units (each divisible by 100,000,000)
| |
| | 01 ............................... Num inflation keys header (0x01 → explicit, unblinded value)
| | 0000000029b92700 ................. Value. 0x29b92700 = 700,000,000 inflation keys

05 ................................... Num outputs
|
|                                      Output #1
| 0b ................................. Asset header (0x0b → blinded value)
| 3cefc49d6412e3d5f7e418319b4e7d0b
| 505c32b632fe882ff59c5f54e60d43b5 ... Asset x-coordinate (big-endian)
|
| 08 ................................. Amount header (0x08 → blinded value)
| 66abe471dfadfb650825abe6f757860b
| 6760d30ff62bc7c9ebd438608f45368b ... Amount x-coordinate (big-endian)
|
| 02 ................................. Nonce header (0x02 → blinded value)
| 115750003261bc64bb73d83401a91279
| 6d0c0fb9d54c72751a7ca7a5149a9bdf ... Nonce x-coordinate (big-endian)
|
| 19 ................................. ScriptPubKey length (0x19 = 25)
| | 76a914031d2893a2c3a3bc6a8a
| | 04fda5ffb75ffe11a8b788ac ......... ScriptPubKey
|
|                                      Output #2
| 0a ................................. Asset header (0x0a → blinded value)
| 3b2ca466dbac12b36dff8b0457fdda3a
| 987141042175d4f230a92b15a390441c ... Asset x-coordinate (big-endian)
|
| 08 ................................. Amount header (0x08 → blinded value)
| f27d5f8d5de47d6d0e1ff49fb2e1fb60
| 548494baed86f9e84b39e1fdce3c8da7 ... Amount x-coordinate (big-endian)
|
| 03 ................................. Nonce header (0x03 → blinded value)
| b1fe30c45ce67e5f1a1f209ee01251d9
| 4cfa29b6f13a500b891c5bb4811873d0 ... Nonce x-coordinate (big-endian)
|
| 19 ................................. ScriptPubKey length (0x19 = 25)
| | 76a914b559decb917ff2a5c9d4553f
| | f692889ae7f8577288ac ............. ScriptPubKey
|
|                                      Output #3
| 01 ................................. Asset header (0x01 → explicit, unblinded value)
| 230f4f5d4b7c6fa845806ee4f6771345
| 9e1b69e8e60fcee2e4940c7a0d5de1b2 ... Asset value
|
| 01 ................................. Amount header (0x01 → explicit, unblinded value)
| 0000000000000000 ................... Amount
|
| 00 ................................. Nonce header (0x00 → null)
|
| 03 ................................. ScriptPubKey length
| | 6a0100 ........................... ScriptPubKey
|
|                                      Output #4
| 0b ................................. Asset header (0x0b → blinded value)
| 1df891f7d1a2feffb5ea3ddc9a8083ec
| 7ebd3074f5b6df16da1060eb1b40c06d ... Asset x-coordinate (big-endian)
|
| 08 ................................. Amount header (0x08 → blinded value)
| c1533ecae1f143762b2a4ebf6db111e8
| 01a0884771cdc0fb5ce1faa4aa29f42a ... Amount x-coordinate (big-endian)
|
|                                      Nonce
| 03 ................................. Nonce header (0x03 → blinded value)
| 67e4e9d0fc453f01024bdb22c60edac2
| 8ca8962c670635514c155245cec1d128 ... Nonce x-coordinate (big-endian)
|
| 16 ................................. ScriptPubKey length (0x16 = 22)
| | 001439b9791c9e35bba2c35a9ae82
| | 9f3d22889b604ed .................. ScriptPubKey
|
|                                      Output #5
| 01 ................................. Asset header (0x01 → explicit, unblinded value)
| 230f4f5d4b7c6fa845806ee4f6771345
| 9e1b69e8e60fcee2e4940c7a0d5de1b2 ... Asset ID: b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23
|
| 01 ................................. Amount header (0x01 → explicit, unblinded value)
| 00000000000069dc ................... Amount: 0x00000000000069dc = 0.00027100. Recall: values are divisible by 100,000,000.
|
| 00 ................................. Nonce header (0x00 → null)
|
| 00 ................................. ScriptPubKey length

00000000 ............................. Locktime

...................................... Input witnesses (1 per input)
|
|                                      Input witness #1
| 00 ................................. Issuance amount range proof (0x00  → null)
| 00 ................................. Inflation keys range proof (0x00 → null)
| 02 ................................. Script witness stack
| | 47 ............................... Stack item #1 length (0x47 = 71 bytes)
| | | 3044022062d246df3e46f806c78e
| | | b39ad2feaaad1a43fa6ecac464e2
| | | 7895de0a38646d6502200334e8de
| | | 266d42ff440af0e59861d7a11d35
| | | 29df8f584c558cf4879ef89d51fa
| | | 01 ............................. Stack item #1
| | 21 ............................... Stack item #2 length (0x21 = 33 bytes)
| | | 02d8aefaed1152469fa73d5ac7a1
| | | 52a632e70a15a135d9f46c76f015
| | | 78a3dd9f91 ..................... Stack item #2
| 00 ................................. Peg-in witness length

...................................... Output witnesses (1 per output)
|
|                                      Output witness #1
| 83 ................................. Surjection proof length (0x83 = 131 bytes)
| | 0300077b8d6962c63f392384c85393
| | 6e6a1883f226f712b50f94afe34a3e
| | da584a13083767a68601bcd503b4ec
| | d3a01db8d24494b8716b729ed3bf9f
| | 211e49fcd120c7ff3c96a0e6a316e0
| | 42ee065c357d239aac8082a9d9a0a2
| | 8c0c660fe4ddf838ad71f57eea7114
| | 1d92c466cb25f1e6c17f85ef4f3c13
| | db1ac3bf34fcc92f05435 ............ Surjection proof
| fd4e10 ............................. Range proof length (0xfd4e10 = 4174, refer to VarInt docs for deserialization info)
| | 60330000000000000001730184(..) ... Range proof (shortened for brevity)

|                                      Output witness #2
| 83 ................................. Surjection proof length (0x83 = 131 bytes)
| | 030007b5838d73f86ee7e4773a383f
| | 2aca5407b3d1a33951a1de1eb6f915
| | 3607c6e43fd230512e32f97fa1e352
| | a6f4b3ea37f41f48dec18babb4a97b
| | 6e8a2446184234bf02606ce6335cfc
| | c3fe067b8bfd599260477ad6026538
| | b2f7e023bf3093efd0132bab96492f
| | d93a477432fde7b6e926a41017573e
| | e62efe39433759808c1595 ........... Surjection proof
| fd4e10 ............................. Range proof length (0xfd4e10 = 4174, refer to VarInt docs for deserialization info)
| | 603300000000000000017ac624(..) ... Range proof (shortened for brevity)
|
|                                      Output witness #3
| 00 ................................. Surjection proof length
| 00 ................................. Range proof length
|
|                                      Output witness #4
| 83 ................................. Surjection proof length (0x83 = 131 bytes)
| | 030007e2d81658dcbb09fe2bcc6039
| | aa5979dcb52f20bfc1f38ca06b907f
| | 1b50bf8d6ad9a584e1c56387643830
| | db7936d40fe224efe60fb930cb04f9
| | 440472e54aca84378f419e46c71c58
| | 9e9375489f63007d94f6273bb71b8b
| | 979e8c29b110774f4a134192b6e979
| | 73a7b59856c16f31b7da29b6214699
| | 3018bc11ed5fd3b101a3fa ........... Surjection proof
| fd4e10 ............................. Range proof length (0xfd4e10 = 4174, refer to VarInt docs for deserialization info)
| | 603300000000000000011f237(..)  ... Range proof (shortened for brevity)
|
|                                      Output witness #5
| 00 ................................. Surjection proof length
| 00 ................................. Range proof length
```

#### Example 3

Signed peg-in claim transaction on liquidv1 (production liquid).

Raw hex:
```
0200000001013d0bfb6e61989331d67dac3b6adf067afda20f504cabb1a7364853a68a0bb6df0000004000ffffffff02016d521c38ec1ea15734ae22b7c46064412829c0d0579f0a713d1c04ede979026f0100000000002b09c1001600143921df9000812998ceff99b610437734d552424f016d521c38ec1ea15734ae22b7c46064412829c0d0579f0a713d1c04ede979026f01000000000000002700000000000000000247304402204f84bb59c2af17b76ba71486a3fe4941829f0b5d23bda5c9f49c449489693e5002206e1f3bba907e511e99bf317059264f89a56c50c56fefa82583b8e941b865facc012102e776bdb5d8fc14d24b330c0efbf34227cbba1cf25eb0778aa45f8b7cb34950460608e8092b0000000000206d521c38ec1ea15734ae22b7c46064412829c0d0579f0a713d1c04ede979026f206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000160014504b2e2f011741aec712fb2f51dc1537272f284a53020000000113391c88becfe2a855a74fb1890cabef7c81a4be742771046ca0c38e29cfada501000000000000008001e8092b000000000017a9144d733642e6cc020cfd3b2ae52e4ef1b50be6a15f8700000000fd990100004020fe6c0db88a5a5b747b9fa39abbf100641325110dd17c00000000000000000000da21e101b583f398f9d46d97b4d083f6142b0fc67dff71bb2969862fa9e346fe2a05fc627efd0917b8cc42a7bd0900000a874b10883f43cb8d4e8703e8861296688ded81d601a6cb4b68b9680faf7974401da4d3e264de6948f2df86a20cc7dc588a3ff8cc05c27afdd35b1cf50ccf7ae4acf64afb05980884134795302653d442be5f7dd80071ab56b25f57d411545122e475f642f7d98042282c59203e09cd3db6544fc4aac33069ab94057358815a3a6b9e1cb47d349006a33832c6a8a32105d1f16a63982aeea22f19d2c365030d4e3d0bfb6e61989331d67dac3b6adf067afda20f504cabb1a7364853a68a0bb6df9231e9542459531f983b26c6dff457ec9af808191d709c761c22d86a8e59d8200f580dc22957e89c3fe8f3d5dc34f9add75e288041f2b4bc5639ee915535a187c89756e0bd15f3b539864dd4e6dacea4fdd5daa290523e4cf9231cccab094c7efc9f6cf9bc4679908cffcb16a2ff3ec061c66bfa15b886c08c6973776d2fba78035dd70300000000
```

Deserialization:
```
02000000 ............................. Version

01 ................................... Flags (0x01 → witness data is present)
|
|                                      Input #1
| 3d0bfb6e61989331d67dac3b6adf067a
| fda20f504cabb1a7364853a68a0bb6df ... Outpoint TXID: dfb60b8aa6534836a7b1ab4c500fa2fd7a06df6a3bac7dd6319398616efb0b3d
| 00000040 ........................... Output Index (little-endian → 0x40000000 → second most significant bit is 1 → peg-in)
|
| 00 ................................. ScriptSig length
| | .................................. ScriptSig (empty: segwit transaction)
|
| ffffffff ........................... Sequence number: UINT32_MAX

02 ................................... Num outputs
|
|                                      Output #1
| 01 ................................. Asset header (0x01 → explicit, unblinded value)
| 6d521c38ec1ea15734ae22b7c4606441
| 2829c0d0579f0a713d1c04ede979026f ... Asset ID: 6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d
|
| 01 ................................. Amount header (0x01 → explicit, unblinded value)
| 00000000002b09c1 ................... Amount: 0.02820545 L-BTC
|
| 00 ................................. Nonce header (0x00 → null)
|
| 16 ................................. ScriptPubKey length (0x16 = 22)
| | 00143921df9000812998ceff99b610
| | 437734d552424f ................... ScriptPubKey
|
|                                      Output #2
| 01 ................................. Asset header (0x01 → explicit, unblinded value)
| 6d521c38ec1ea15734ae22b7c4606441
| 2829c0d0579f0a713d1c04ede979026f ... Asset ID: 6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d
|
| 01 ................................. Amount header (0x01 → explicit, unblinded value)
| 0000000000000027 ................... Amount: 0.00000039 L-BTC
|
| 00 ................................. Nonce header (0x00 → null)
|
| 00 ................................. ScriptPubKey length
| | .................................. ScriptSig (empty: segwit transaction)

00000000 ............................. Locktime

...................................... Input witnesses (1 per input)
|
|                                      Input witness #1
| 00 ................................. Issuance amount range proof (null)
| 00 ................................. Inflation keys range proof (null)
| 02 ................................. Script witness stack length
| | 47 ............................... Stack item #1 length (0x47 = 71 bytes)
| | | 304402204f84bb59c2af17b76ba7
| | | 1486a3fe4941829f0b5d23bda5c9
| | | f49c449489693e5002206e1f3bba
| | | 907e511e99bf317059264f89a56c
| | | 50c56fefa82583b8e941b865facc
| | | 01 ............................. Stack item #1
| | 21 ............................... Stack item #2 length (0x21 = 33 bytes)
| | | 02e776bdb5d8fc14d24b330c0efb
| | | f34227cbba1cf25eb0778aa45f8b
| | | 7cb3495046 ..................... Stack item #2
| 06 ................................. Peg-in witness stack length
| | 08 ............................... Stack item #1 length
| | | e8092b0000000000 ............... Peg-in value (little-endian): 0x2b09e8 = 0.02820545 BTC)
| | 20 ............................... Stack item #2 length (0x20 = 32)
| | | 6d521c38ec1ea15734ae22b7c46064
| | | 412829c0d0579f0a713d1c04ede979
| | | 026f ........................... Asset ID: 6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d
| | 20 ............................... Stack item #3 length (0x20 = 32)
| | | 6fe28c0ab6f1b372c1a6a246ae63f7
| | | 4f931e8365e15a089c68d619000000
| | | 0000 ........................... Genesis hash: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
| | 16 ............................... Stack item #4 length (0x16 = 22)
| | | 0014504b2e2f011741aec712fb2f51
| | | dc1537272f284a ................. Claim script
| | 53 ............................... Stack item #5 length
| | | 020000000113391c88becfe2a855a7
| | | 4fb1890cabef7c81a4be742771046c
| | | a0c38e29cfada50100000000000000
| | | 8001e8092b000000000017a9144d73
| | | 3642e6cc020cfd3b2ae52e4ef1b50b
| | | e6a15f8700000000 ............... Serialized mainchain peg-in transaction
| | fd9901 ........................... Stack item #6 length (0xfd9901 = 409, refer to VarInt docs for deserialization info)
| | | 00004020fe6c0db88a5a5b747b(..).. Mainchain transaction inclusion merkle proof (shortened for brevity)

...................................... Output witnesses (1 per output)
|
|                                      Output #1 witness
| 00 ................................. Surjection proof length
| 00 ................................. Range proof length
|
|                                      Output #2 witness
| 00 ................................. Surjection proof length
| 00 ................................. Range proof length
```
