-
Notifications
You must be signed in to change notification settings - Fork 59
docs(dip27): version 2 Asset Unlock transactions with stable txids #189
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
base: master
Are you sure you want to change the base?
Changes from all commits
5f04c12
cffe3a7
6ab8578
81b4f55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,8 @@ | |
| Here is a table of current proposed types and their associated DIP. Future DIPs | ||
| may introduce more types. | ||
|
|
||
| *Note:* This table refers to the _payload_ version which relates only to the special transaction | ||
|
Check failure on line 7 in dip-0002/special-transactions.md
|
||
| payload and is distinct from the _transaction_ version. | ||
|
Check failure on line 8 in dip-0002/special-transactions.md
|
||
|
|
||
| | Type | Transaction Type | DIP Number and Name | Payload Version | State | | ||
| | ---- | ---------------- | ------------------- | --------------- | ----- | | ||
|
|
@@ -13,8 +13,8 @@ | |
| | 2 | Provider Update Service Transaction (ProUpServTx) | [DIP 003: Deterministic Masternode List](https://github.com/dashpay/dips/blob/master/dip-0003.md) | 1 | Active | | ||
| | 3 | Provider Update Registrar Transaction (ProUpRegTx) | [DIP 003: Deterministic Masternode List](https://github.com/dashpay/dips/blob/master/dip-0003.md) | 1 | Active | | ||
| | 4 | Provider Update Revocation Transaction (ProUpRevTx) | [DIP 003: Deterministic Masternode List](https://github.com/dashpay/dips/blob/master/dip-0003.md) | 1 | Active | | ||
| | 5 | Coinbase Transaction (CbTx) | [DIP 004: Simplified Verification of Deterministic Masternode Lists](https://github.com/dashpay/dips/blob/master/dip-0004.md) | 3 | Active | | ||
| | 5 | Coinbase Transaction (CbTx) | [DIP 004: Simplified Verification of Deterministic Masternode Lists](https://github.com/dashpay/dips/blob/master/dip-0004.md) | 4 | Active | | ||
| | 6 | Quorum Commitment | [DIP 006: Long Living Masternode Quorums](https://github.com/dashpay/dips/blob/master/dip-0006.md) | 1 | Active | | ||
| | 7 | Masternode Hard Fork Signal | [DIP 023: Enhanced Hard Fork Mechanism](https://github.com/dashpay/dips/blob/master/dip-0023.md) | 1 | Active | | ||
| | 8 | Asset Lock | [DIP 027: Dash Core Credit Pool](https://github.com/dashpay/dips/blob/master/dip-0027.md) | 1 | Active | | ||
| | 9 | Asset Unlock | [DIP 027: Dash Core Credit Pool](https://github.com/dashpay/dips/blob/master/dip-0027.md) | 1 | Active | | ||
| | 9 | Asset Unlock | [DIP 027: Dash Core Credit Pool](https://github.com/dashpay/dips/blob/master/dip-0027.md) | 2 | Active | | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,14 @@ | |
| More information on the `bestCLHeightDiff` and `bestCLSignature` fields can be found in [DIP0029 - Randomness Beacon For LLMQ Selection](https://github.com/dashpay/dips/blob/master/dip-0029.md#change-to-the-coinbase-transaction). | ||
| More information on the `creditPoolBalance` field will be described in a future document. | ||
|
|
||
| Starting with version >= 4, the following fields are added: | ||
|
|
||
| | Field | Type | Size | Description | | ||
| | ----- | ---- | ---- | ----------- | | ||
| | merkleRootAssetUnlocks | uint256 | 32 | Merkle root of the instance hashes of the block's version 2 Asset Unlock transactions | | ||
|
|
||
| The transaction hash of a version 2 Asset Unlock transaction excludes its quorum signing fields (see [DIP0027 - Credit Asset Locks](https://github.com/dashpay/dips/blob/master/dip-0027.md#transaction-identity-for-version-2)), so the block's merkle root does not commit to those bytes. This field restores the commitment: it is the merkle root of the instance hashes (the hashes of the full serialization) of the block's version 2 Asset Unlock transactions in block order, or all zeros when the block contains none. A block whose commitment does not match its transactions must be rejected without marking the block hash invalid, like a block with mutated transaction data, since a relaying peer could have altered the signing fields without affecting the merkle root. | ||
|
|
||
| ### Height in CbTx and deprecation of BIP34 | ||
|
|
||
| The CbTx contains the “height” field. It acts as a guaranteed variance in the CbTx so that each block’s CbTx gets a different hash. This is meant as a replacement for the height value currently found in the coinbase input (BIP34). With the deployment of this DIP, BIP34 becomes obsolete for new blocks and nodes should not enforce the presence of the block height in the coinbase input's “scriptSig” anymore. | ||
|
|
@@ -175,8 +183,8 @@ | |
| | Field | Type | Size | Description | | ||
| |--|--|--|--| | ||
| | signature | BLSSig | 96 | ChainLock Signature | | ||
| | indexSetCount | compactSize uint | 1-9 | Number of quorum indexes using the same signature for their member calculation | ||
|
Check failure on line 186 in dip-0004.md
|
||
| | indexSet | uint16_t[] | variable | Quorum indexes indicating which newQuorums entries use this signature for their member calculation | ||
|
Check failure on line 187 in dip-0004.md
|
||
|
|
||
| ## Tracking/Updating and verifying masternode lists based on MNLISTDIFF | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/usr/bin/python3 | ||
| # # Example showing how to compute the transaction hash (txid) of a version 2 | ||
| # # Asset Unlock transaction. The txid is the double-SHA256 of the transaction | ||
| # # serialized with the signHeight, quorumHash, and quorumSig fields set to | ||
| # # zeros, so every re-signed instance of one withdrawal shares one txid. | ||
| import hashlib | ||
| import struct | ||
|
|
||
| def sha256(s): | ||
| return hashlib.new('sha256', s).digest() | ||
|
|
||
| def compact_size(n): | ||
| if n < 253: | ||
| return struct.pack("B", n) | ||
| if n < 0x10000: | ||
| return struct.pack("<BH", 253, n) | ||
| if n < 0x100000000: | ||
| return struct.pack("<BI", 254, n) | ||
| return struct.pack("<BQ", 255, n) | ||
|
|
||
| def serialize_with_compact_size(s): | ||
| return compact_size(len(s)) + s | ||
|
|
||
| def withdrawal_txid(index, fee, outputs): | ||
| # Transaction version 3, type 9 (Asset Unlock) | ||
| tx = struct.pack("<HH", 3, 9) | ||
| # No inputs | ||
| tx += compact_size(0) | ||
| # Outputs | ||
| tx += compact_size(len(outputs)) | ||
| for value, script in outputs: | ||
| tx += struct.pack("<q", value) + serialize_with_compact_size(script) | ||
| # nLockTime | ||
| tx += struct.pack("<I", 0) | ||
| # Payload with signHeight, quorumHash, and quorumSig set to zeros: | ||
| # version (2), index, fee, signHeight (0), quorumHash (zeros), quorumSig (zeros) | ||
| payload = struct.pack("<BQI", 2, index, fee) | ||
| payload += struct.pack("<I", 0) # signHeight | ||
| payload += b"\x00" * 32 # quorumHash | ||
| payload += b"\x00" * 96 # quorumSig | ||
| tx += serialize_with_compact_size(payload) | ||
| return sha256(sha256(tx))[::-1].hex() | ||
|
|
||
| # P2PKH output paying 100000000 duffs to public key hash 0x1111...11 | ||
| script = bytes.fromhex("76a914" + "11" * 20 + "88ac") | ||
| outputs = [(100000000, script)] | ||
|
|
||
| for index in [101, 123456789]: | ||
| print(withdrawal_txid(index, 70000, outputs)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,7 @@ topup | |
| topups | ||
| tprv | ||
| tpub | ||
| unmined | ||
| unretrievable | ||
| UTXO | ||
| varint | ||
|
|
||
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.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Define one expiration boundary.
The text says “48 or more,” which means
height >= signHeight + 48, but the parenthetical saysheight > signHeight + 48. At exactlysignHeight + 48, implementations can make opposite validity decisions. Use one operator consistently in both statements.Proposed correction if 48 blocks is inclusive
🤖 Prompt for AI Agents