Johnson Lau
在2013年提议。概述了使用特殊操作码使资金进入和退出附加块的方法。 Johnson Lau
在2017年提出的, opt-in
,序列化,验证和网络服务方面利用了BIP141, BIP143和BIP144的一些功能。拓展块的规则可以认为是这些BIP的拓展和修订。拓展块在当前交易格式下不兼容BIP141,它需要一些小的附加规则。OP_RETURN 0x24 0xaa21a9ef[32-byte-merkle-root]
(previous-resolution-value + entering-value - exiting-value) - ext-block-fees
.进入拓展区块:
示例:
Transaction #1 (coinbase):
Output #0:
- Script: P2PKH
- Value: 12.5
Output #1:
- Script: OP_RETURN 0xaa21a9ef[merkle-root]
- Value: 0
-------------------------------
Transaction #2 (extension block funding transaction):
Output #0:
- Script: P2WPKH (will enter the extension utxo set)
- Value: 5.0
Output #1:
- Script: P2PKH (stays in the canonical utxo set)
- Value: 2.5
-------------------------------
该决议交易可以赎回任何隔离验证的输出;
Transaction #3 (resolution transaction):
Input #0:
- Outpoint:
- Hash: previous-resolution-txid
- Index: 0
Input #1:
- Outpoint:
- Hash: Transaction #2 TXID
- Index: 0
Output #0:
- Script: OP_TRUE
- Value: 5.0
在这个例子中,一个花费者要赎回tx2的0号输出,对应的拓展块的存在形式可能如下:
Transaction #4 (redeemer of transaction #2):
Input #0:
- Outpoint:
- Hash: Transaction #2 TXID
- Index: 0
Output #0:
- Script: P2WPKH (this output remains in the ext. block)
- Value: 5.0
退出拓展块
在随后的交易中,tx2的输出的花费者希望获得一个输出出口来获得他们的金额。
Transaction #5 (coinbase):
Output #0:
- Script: P2PKH
- Value: 12.5
Output #1:
- Script: OP_RETURN 0xaa21a9ef[merkle-root]
- Value: 0
----------------------------
Transaction #6 (resolution transaction):
Input #0:
- Outpoint:
- Hash: previous-resolution-txid
- Index: 0
Output #0:
- Script: OP_TRUE
- Value: 2.5
Output #1:
- Script: P2PKH (duplicated from the exited output below)
- Value: 2.5
--------------------------------
拓展区块
Transaction #7:
Input #0:
- Outpoint:
- Hash: Transaction #4 TXID
- Index: 0
Output #0:
- Script: P2WPKH (this output will remain in the ext. block)
- Value: 2.5
Output #1:
- Script: P2PKH (note that this causes an exit!)
- Value: 2.5
金额
在前面的例子中,tx2的花费者的输出应该添加一点费用。
Transaction #5 (coinbase):
Output #0:
- Script: P2PKH
- Value: 12.501 (reward + fee)
Output #1:
- Script: OP_RETURN 0xaa21a9ef[merkle-root]
- Value: 0
---------------------------
Transaction #6 (resolution transaction):
Input #0:
- Outpoint:
- Hash: previous-resolution-txid
- Index: 0
Output #0:
- Script: OP_TRUE
- Value: 2.499 (fee is subtracted)
Output #1:
- Script: P2PKH (from the exited output below)
- Value: 2.5
拓展块
Transaction #7:
Input #0:
- Outpoint:
- Hash: Transaction #4 TXID
- Index: 0
Output #0:
- Script: P2WPKH (this output will remain in the ext. block)
- Value: 2.499 (fee is subtracted, this propagates up)
Output #1:
- Script: P2PKH (note that this causes an exit!)
- Value: 2.5
block weight
和transaction weight
的概念将被移除。sigops cost
的概念继续存在,用于将来的软分叉和可升级的DoS限制.
MAX_BLOCK_SIZE: 1000000 (unchanged)
MAX_BLOCK_SIGOPS: 20000 (unchanged)
MAX_EXTENSION_SIZE: TBD
MAX_EXTENSION_COST: TBD
getblocktemplate
的拓展。resolution
,它是一个bool值,被设置为true。直接在传统交易数组中包含决议交易是为了与现有的挖矿客户端进行向后兼容。default_witness_commitment
已被重命名为default_extension_commitment
,并被包含在拓展区块的承诺脚本中。mutable
字段在resolution
中被定义。如果传统交易在可变数组中,resolution
允许拓展块可变,前提是客户端能正确的更新决议交易。resolution
的可变字段,还定义了resolution capabilities
字段,以便客户端声明它可以更新决议交易。commitment-hash->ext
map结构中,此处区块数据可能是必须的(除了调用submitblock期间的一个重新序列化)extblk
(在GBT作为非extblk出现)