区块链芝士丨隔离验证钱包开发指南(3)

Pay-to-Witness-Script-Hash (P2WSH)

P2SH-P2WPKH 是BIP141定义的另一个新的脚本格式, 类似P2SH. 它允许付款到任意复杂的脚本. 格式为:

scriptPubKey (34 bytes): OP_0 < 32-byte-script-hash >

花费P2WSH的输出,scriptSig必须是空的,并且witness为

witness: <...> <...> <...> < witnessScript >

RIPEMD160(SHA256(witnessScript)) 等于scriptPubkey中的 32-byte-script-hash, witnessScript是反序列化并且当作剩下的数据在witness中

P2WSH in P2SH (P2SH-P2WSH)

P2SH-P2WPKH 是使用一个P2WSH脚本作为P2SH的 redeemScript. P2SH-P2WPKH 的 scriptPubKey 看起来和P2SH是一样的:

scriptPubKey (23 bytes): OP_HASH160 <20-byte-script-hash> OP_EQUAL

花费P2SH-P2WPKH的输出, scriptSig必须只包含一个 redeemScript, 并且witness 是和P2WSH是相同的:

scriptSig (35 bytes): < OP_0 < 32-byte-script-hash > > 
witness: <...> <...> <...> < witnessScript >

SHA256(witnessScript) 等于 32-byte-script-hash, 并且 RIPEMD160(0x0020{32-byte-pubkey-hash}) 等于 20-byte-script-hash.

新的签名算法

花费一个witness程序的输出,当产生ECDSA签名时一个新的签名算法必须被使用, 一个详细的例子能在BIP143中找到

新的支付地址

2个新的支付地址类型被定义了. 完整的规范可以在BIP142中找到.

本文由 零点财经 作者:tao 发表,其版权均为 零点财经 所有,文章内容系作者个人观点,不代表 零点财经 对观点赞同或支持。如需转载,请注明文章来源。
分享生成图片
50

发表回复

区块链芝士丨隔离验证钱包开发指南(3)

2021-06-22 11:05:00

Pay-to-Witness-Script-Hash (P2WSH)

P2SH-P2WPKH 是BIP141定义的另一个新的脚本格式, 类似P2SH. 它允许付款到任意复杂的脚本. 格式为:

scriptPubKey (34 bytes): OP_0 < 32-byte-script-hash >

花费P2WSH的输出,scriptSig必须是空的,并且witness为

witness: <...> <...> <...> < witnessScript >

RIPEMD160(SHA256(witnessScript)) 等于scriptPubkey中的 32-byte-script-hash, witnessScript是反序列化并且当作剩下的数据在witness中

P2WSH in P2SH (P2SH-P2WSH)

P2SH-P2WPKH 是使用一个P2WSH脚本作为P2SH的 redeemScript. P2SH-P2WPKH 的 scriptPubKey 看起来和P2SH是一样的:

scriptPubKey (23 bytes): OP_HASH160 <20-byte-script-hash> OP_EQUAL

花费P2SH-P2WPKH的输出, scriptSig必须只包含一个 redeemScript, 并且witness 是和P2WSH是相同的:

scriptSig (35 bytes): < OP_0 < 32-byte-script-hash > > 
witness: <...> <...> <...> < witnessScript >

SHA256(witnessScript) 等于 32-byte-script-hash, 并且 RIPEMD160(0x0020{32-byte-pubkey-hash}) 等于 20-byte-script-hash.

新的签名算法

花费一个witness程序的输出,当产生ECDSA签名时一个新的签名算法必须被使用, 一个详细的例子能在BIP143中找到

新的支付地址

2个新的支付地址类型被定义了. 完整的规范可以在BIP142中找到.