-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: describe elements transaction serialization format #1148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, I have just done a first pass with mostly grammatical suggestions, and will make a second pass (when I can) to go over the examples closely.
doc/elements-tx-format.md
Outdated
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 requires familiarity with the architecture of bitcoin and elements, as well the various parts that are expected in an elements transaction (inputs, outputs, assets, pegin data, etc.). For more information on those, please refer to the [elements code tutorial](https://elementsproject.org/elements-code-tutorial/overview). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 requires familiarity with the architecture of bitcoin and elements, as well the various parts that are expected in an elements transaction (inputs, outputs, assets, pegin data, etc.). For more information on those, please refer to the [elements code tutorial](https://elementsproject.org/elements-code-tutorial/overview). | |
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 requires familiarity with the architecture of Bitcoin and Elements, as well the various parts that are expected in an Elements transaction (inputs, outputs, assets, peg-in data, etc.). For more information on those, please refer to the [Elements code tutorial](https://elementsproject.org/elements-code-tutorial/overview). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I will add all these, except for the "peg-in" one.
It appears that the existing elements docs use "pegin", not "peg-in".
claimpegin "bitcoinTx" "txoutproof" ( "claim_script" )
Claim coins from the main chain by creating a pegin transaction with the necessary metadata after the corresponding Bitcoin transaction.
https://elementsproject.org/en/doc/0.18.1.6/rpc/wallet/claimpegin/
doc/elements-tx-format.md
Outdated
*Note:* The encoding column in the following tables corresponds to the way that the fields are serialized. In bitcoin, numbers and hashes are serialized in little endian, and this same notion carries over to elements. | ||
|
||
*Note:* Values are listed in multiples of 100,000,000 (this corresponds directly to how bitcoin encodes value, where 1 BTC is divisible into 100,000,000 satoshis). For example, a `ConfidentialAmount` representing 7 inflation keys would be encoded as 700,000,000. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*Note:* The encoding column in the following tables corresponds to the way that the fields are serialized. In bitcoin, numbers and hashes are serialized in little endian, and this same notion carries over to elements. | |
*Note:* Values are listed in multiples of 100,000,000 (this corresponds directly to how bitcoin encodes value, where 1 BTC is divisible into 100,000,000 satoshis). For example, a `ConfidentialAmount` representing 7 inflation keys would be encoded as 700,000,000. | |
*Note:* The encoding column in the following tables corresponds to the way that the fields are serialized. In Bitcoin, numbers and hashes are serialized in little-endian, and this same notion carries over to Elements. | |
*Note:* Values are listed in multiples of 100,000,000 (this corresponds directly to how Bitcoin encodes value, where 1 BTC is divisible into 100,000,000 Satoshis). For example, a `ConfidentialAmount` representing 7 inflation keys would be encoded as 700,000,000. |
doc/elements-tx-format.md
Outdated
|
||
|Field|Required|Size|Data Type|Encoding|Notes| | ||
|-----|--------|-----|---------|--------|-----| | ||
| Version | Yes | 4 bytes | `UnsignedInteger` | Little endian | Protocol version (should always be 2). | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a signed int32 - link
Might be worth adding some info from https://developer.bitcoin.org/reference/transactions.html#raw-transaction-format
Maybe "Data Type" should be the actual C++ type used?
| Version | Yes | 4 bytes | `UnsignedInteger` | Little endian | Protocol version (should always be 2). | | |
| Version | Yes | 4 bytes | `uint32_t` | Little-Endian | Transaction version number. Currently version 2. Version 2 means that [BIP 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki#specification) applies. | |
doc/elements-tx-format.md
Outdated
|Field|Required|Size|Data Type|Encoding|Notes| | ||
|-----|--------|-----|---------|--------|-----| | ||
| Version | Yes | 4 bytes | `UnsignedInteger` | Little endian | Protocol version (should always be 2). | | ||
| Flags | Yes | 1 byte | | | Whether the transaction contains a witness. Either 0 or 1. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Flags | Yes | 1 byte | | | Whether the transaction contains a witness. Either 0 or 1. | | |
| Flags | Yes | 1 byte | unsigned char | | Whether the transaction contains a witness. Either 0 (no witness) or 1. | |
doc/elements-tx-format.md
Outdated
| Num Inputs | Yes | Varies | `VarInt` | | Number of outputs from the transaction. | | ||
| Outputs | Yes | Varies | `Vector<TxOut>` | | | | ||
| Locktime | Yes | 4 bytes | `UnsignedInteger` | 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. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. | | |
| 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. | |
doc/elements-tx-format.md
Outdated
|-----|--------|-----|---------|--------|-----| | ||
| Output Hash (TXID) | Yes | 32 bytes | `UnsignedInteger` | Little endian | Hashes in bitcoin are encoded as integers in little endian. Be mindful – this means that they will look backwards when serialized. | | ||
| Output Index | Yes | 4 bytes | `UnsignedInteger` | Little endian | **Output is a coinbase**: `0xffffffff`<br><br>The two most significant bits are reserved for flags.<br><br>**Output is a pegin:** second most significant bit is 1.<br><br>**Output is 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. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ScriptSig Length | Yes | Varies | `VarInt` | | Set to `0x00` if the transaction is segwit and the witness contains the signature. | | |
| ScriptSig Length | Yes | Varies | `VarInt` | | Set to `0x00` if the transaction is SegWit and the witness contains the signature. | |
doc/elements-tx-format.md
Outdated
|
||
#### Witness | ||
|
||
As noted above, the witness is only present for segwit transactions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted above, the witness is only present for segwit transactions. | |
As noted above, the witness is only present for SegWit transactions. |
doc/elements-tx-format.md
Outdated
Serialized format: | ||
`[Issuance Amount Range Proof][Inflation Keys Range Proof][Script Witness][Pegin Witness]` | ||
|
||
The range proofs must be empty if their asociated amount (issuance / inflation keys) is explicit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The range proofs must be empty if their asociated amount (issuance / inflation keys) is explicit. | |
The range proofs must be empty if their associated amounts (issuance / inflation keys) are explicit. |
doc/elements-tx-format.md
Outdated
|
||
The Range Proof must be empty if the output’s amount is explicit. | ||
|
||
The Surjectionproof must be empty if the output’s assetId is explicit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Surjectionproof must be empty if the output’s assetId is explicit. | |
The Surjection Proof must be empty if the output’s assetId is explicit. |
doc/elements-tx-format.md
Outdated
|
||
This data type is derived from bitcoin and allows an integer to be encoded depending on the represented value, to save space. Variable length integers always precede an vector of a type of data that may vary in length. Longer numbers are encoded in little endian. | ||
|
||
Refer to the [bitcoin protocol documentation](https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer) for a full description on how this type is serialized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer to the [bitcoin protocol documentation](https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer) for a full description on how this type is serialized. | |
Refer to the [Bitcoin protocol documentation](https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer) for a full description on how this type is serialized. |
doc/elements-tx-format.md
Outdated
|Field|Required|Size|Data Type|Encoding|Notes| | ||
|-----|--------|-----|---------|--------|-----| | ||
| Asset | Yes | 1 or 33 bytes | `ConfidentialAsset` | | | | ||
| Amount | Yes | 1 or 9 or 33 bytes | `ConfidentialAmount` | | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null asset and null amounts are illegal in outputs. They cannot be 1 byte.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
doc/elements-tx-format.md
Outdated
|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` | | Freeform entropy field, no consensus-defined meaning, but is used as additional entropy to the asset tag calculation. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only freeform for new issuances. For reissuances it is required to be the asset's entropy value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
doc/elements-tx-format.md
Outdated
| 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` | | Freeform entropy field, no consensus-defined meaning, but is used as additional entropy to the asset tag calculation. | | ||
| Amount | Yes | 1 or 9 or 33 bytes | `ConfidentialAmount` | | Amount of the asset to issue. Both explicit and blinded amounts are supported. | | ||
| Num Inflation Keys | Yes | 1 or 9 or 33 bytes | `ConfidentialAmount` | | Number of inflation keys to issue. Both explicit and blinded amounts are supported. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Inflation Keys cannot be reissued.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a note here explaining this.
doc/elements-tx-format.md
Outdated
|Field|Required|Size|Data Type|Encoding|Notes| | ||
|-----|--------|-----|---------|--------|-----| | ||
| Output Hash (TXID) | Yes | 32 bytes | `UnsignedInteger` | Little endian | Hashes in bitcoin are encoded as integers in little endian. Be mindful – this means that they will look backwards when serialized. | | ||
| Output Index | Yes | 4 bytes | `UnsignedInteger` | Little endian | **Output is a coinbase**: `0xffffffff`<br><br>The two most significant bits are reserved for flags.<br><br>**Output is a pegin:** second most significant bit is 1.<br><br>**Output is an asset issuance:** most significant bit is 1. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input is a pegin; Input has an asset issuance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
ab50b63
to
7aaf83a
Compare
doc/elements-tx-format.md
Outdated
| 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. | | ||
|
||
Serialized format: `[Version][Flags][Num Inputs][Inputs][Num Outputs][Outputs][Locktime][Witness]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to have the serialized form listed here? The table is sequential and conveys the form. Duplicating it makes it redundant and the reader may wonder if it differs .
doc/elements-tx-format.md
Outdated
|
||
|Field|Required|Size|Data Type|Encoding|Notes| | ||
|-----|--------|-----|---------|--------|-----| | ||
| Output Hash (TXID) | Yes | 32 bytes | `uint256` | Little-endian | Bytes of the output hash are encoded in little-endian. **NB**: this means that they appear backwards when serialized. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably omit the NB. We can assume familiarity with little-endian and big-endian serializations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I think the situation here is more complex than this documentation presents. The serialization order of the hashes is the correct order of the bytes produced by SHA256. It is the elements client that takes this correct serialization order, reinterprets it as a 256 bit integer in little endian format and then displays that integer in hex, which has the effect of displaying AssetIDs backwards.
I just don't know a concise way of explaining all this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Thank you for the clarification.
I was actually under the (incorrect) impression that the elements client displayed the correct order of bytes produced by SHA256, and the hashes were just serialized in reverse.
Your explanation makes much more sense.
I will make this distinction more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should drop any reference to endianness and just say that the bytes are reversed. You can add a footnote explaining that historically this has something to do with endianness and type conversions but I don't think it would make things any clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I've stated that the bytes are reversed, and I've added a footnote explaining the historical reasons for this.
doc/elements-tx-format.md
Outdated
|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` | | Whether the transaction contains a witness. Either 0 (no witness) or 1. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should state if other values are accepted or ignored. (In this case, they are rejected)
Serialized format: `[Input Witnesses][Output Witnesses]` | ||
|
||
#### InputWitness | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be helpful to add a one sentence description of this field, in case someone is arriving here without the previous context.
doc/elements-tx-format.md
Outdated
| 00 ................................. Pegin witness (0x00 → null) | ||
| | ||
| Input #2 witness | ||
| 00 ................................. IssuanceAmountRangeproof (null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the use of camel case here is inconsistent with input 1
doc/elements-tx-format.md
Outdated
|Field|Required|Size|Data Type|Encoding|Notes| | ||
|-----|--------|-----|---------|--------|-----| | ||
| Output Hash (TXID) | Yes | 32 bytes | `uint256` | Little-endian | Bytes of the output hash are encoded in little-endian. **NB**: this means that they appear backwards when serialized. | | ||
| 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 pegin:** second most significant bit is 1.<br><br>**Input has an asset issuance:** most significant bit is 1. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if both bits are 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's self-evident that an asset issuance and a pegin are mutually exclusive, from a logical perspective.
I'd prefer not to enumerate every single thing that could be invalid, because that would make the document much longer and more confusing to read.
I could add a link to the actual transaction validation code here, but I'm not sure how helpful that will be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I am aware you can pegin and issue an asset at the same time. I've never tried it though.
doc/elements-tx-format.md
Outdated
|
||
#### ConfidentialAsset | ||
|
||
Serialized format: `[header][value]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be helpful to keep with the table description for these types, for consistency and clarity (even though there are only 2 fields).
e250b8a
to
69e1d14
Compare
48f6101
to
dc35239
Compare
ee113d8
to
0ba641b
Compare
0ba641b
to
bd36282
Compare
doc/elements-tx-format.md
Outdated
| 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 pegin:** 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` | Big-endian | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would drop the "Big-endian" for scripts and leave the field blank.
doc/elements-tx-format.md
Outdated
|-----|--------|-----|---------|--------|-----| | ||
| 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. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Amount and Num Inflation Keys cannot be explicitly 0. (Instead they should be NULL values).
doc/elements-tx-format.md
Outdated
|
||
* The *Encoding* column in the following tables indicates how the fields are serialized. | ||
|
||
* Values are defined in multiples of 100,000,000 (this corresponds directly to how Bitcoin encodes value, where 1 BTC is divisible into 100,000,000 Satoshis). For example, a `ConfidentialAmount` representing 7 units of something (`L-BTC`, inflation keys, etc.) would be encoded as 700,000,000. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apoelstra correct me if I'm wrong, but how the element/green UI handles units is ... more complicated than this suggests. There is something about the asset registry etc. etc.
I think we should simply note that all unit values are in satoshis, or say all values are in the smallest indivisible unit (i.e. satoshis) or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
Even if other assets didn't have "natural units" that differed from 10^8 I don't know what 10^8 would have to do with the encoding, so we should drop any mention of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I mentioned this was because Example 2
below contains an asset issuance with the number of inflation keys encoded as:
0x29b92700 = 700 000 000
Does this correspond to 7 keys? A single inflation key is indivisible, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's 700 million reissuance keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. So when I parse the full issuance transaction with $elements-cli decoderawtransaction <...>
, the result contains:
"issuance": {
"assetBlindingNonce": "0000000000000000000000000000000000000000000000000000000000000000",
"assetEntropy": "503f1db03b8ed61ace8fbadc2fcb6c200bdf1ada403d74b891e55e1a047b6596",
"isreissuance": false,
"token": "6e88fa86a097b9ede564f67c60e8c5d24ed1f10eeb56c3a60223961f2e38737f",
"asset": "d42c5ba3724b7f7a045968e0c04e69f81070aca8b6e2db88cd84c65dd07b8324",
"assetamount": 33.00000000,
"tokenamount": 7.00000000
}
Is the "tokenamount": 7.00000000
indicating that there are really 700,000,000 reissuance tokens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol. yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok that makes sense now. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened #1152 about this.
|
||
|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. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apoelstra Is there any existing wallet interpretation of an explicit nonce? Care to comment on its endianness?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, and lol. It's hard to imagine an interpretation of "endianness" for nonces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you would take the explicit value as an secp256k1 scalar value and multiply the generator with it, that would give it an endianness. But I wasn't sure if a wallet is expected to do anything with an explicit nonce.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would make sense. But no, in practice nobody interprets "explicit nonces" at all.
doc/elements-tx-format.md
Outdated
| | ||
| Input #1 | ||
| 3d0bfb6e61989331d67dac3b6adf067a | ||
| fda20f504cabb1a7364853a68a0bb6df ... Outpoint TXID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest commenting that the previous TXID is dfb6...
here and for other examples.
doc/elements-tx-format.md
Outdated
| Output #1 | ||
| 01 ................................. Asset header (0x01 → explicit, unblinded value) | ||
| 6d521c38ec1ea15734ae22b7c4606441 | ||
| 2829c0d0579f0a713d1c04ede979026f ... Key used to generate asset ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest commenting that the assetID is 6f02...
here and in the other examples.
doc/elements-tx-format.md
Outdated
| | | 7cb3495046 ..................... Stack item #2 | ||
| 06 ................................. Pegin witness stack length | ||
| | 08 ............................... Stack item #1 length | ||
| | | e8092b0000000000 ............... Stack item #1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apoelstra Should be be describing the pegin structure here, amount, claim_script, genesis hash, peg-in transaction? I know that the transaction tool does this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that we should. I'm tempted to say "it's a stack of byte vectors" but in this case every field has a clear meaning and fixed format, and it's simple enough to parse.
0b6c0bc
to
02468b4
Compare
720a442
to
cc132c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, though I think we might as well inline the definition of the encoding for VarInts.
88cab61
to
dd57bff
Compare
ack thank you!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job, thank you!
…or rc5 37076d7 Bump version to -rc5 (Pablo Greco) 5629cae fs: Make compatible with boost 1.78 (Andrew Chow) 60b913e Elements-qt: Correctly display the amount in the sender's wallet after using Send button (Andrea Bonel) 872478b docs: describe elements transaction serialization format (#1148) (James Dorfman) dd2d758 fixed minor issues found in review (Allen Piscitello) 2da7d75 removing test that fails due to blinded issuances, which results in incorrect reissuance token ids (Allen Piscitello) 420de43 removing code to blind issuances. PSET should be modified to include an option to blind or unblind issuances, defaulting to unblind. (Allen Piscitello) Pull request description: Backport #1150 #1154 and #1148 from master. Backport bitcoin/bitcoin#24104 from Bitcoin Core Bump to -rc5 ACKs for top commit: jamesdorfman: utACK 37076d7. delta1: utACK 37076d7 Tree-SHA512: 616322f94c17008cc7fd582203c22b33c73b922269ab33fd13b270f491eda9b30d4f18efa3f7887e247bef46b63c4810f4084e409bea98120702c426a83343a8
Note: When reviewing this markdown file, please open it in a markdown viewer. Otherwise, the tables will be illegible. Github will show you the rendered markdown if you open the "Files changed" tab, click the three dots on the top right of the file, and select "View file".
This PR adds a new markdown document which contains a detailed description of the elements transaction serialization format.
The document includes a detailed descriptions of all fields and examples where complex raw transactions are deserialized, step-by-step.
Intended audience: