作者:sickworm
时间:2019年2月27日 16:59:24
来源:https://cloud.tencent.com/developer/article/1396264
如果你还不了解经典交易构成,请看:https://blog.csdn.net/q4878802/article/details/49638457
隔离见证交易相关规范:
隔离见证 Segregated witness 交易解析
一、P2SH-P2WPH
交易:https://testnet.blockchain.info/tx/f299afe17901f5a8d87f306c13f42c6fbf3d5b5de090973cf0fd34d403ccd2b8
交易报文:
01000000
00 // marker,固定值,旧交易不能txin count为0,此作为隔离见证交易格式的判断位
01 // flag,固定值,this will allow us to easily add more extra non-committed data to transactions (like txouts being spent, …). It can be interpreted as a bitvector.
// intput count 03 6f7f967a3e8c20964758efdc78e267a254b181fc3f4eab9112d885dd10e8a486 // prev tx 01000000 // prev tx index 17 16 001406c3d51e041b64e87a577ffd1a4ff5357cefd015 // scriptSig, P2WPKH nested in BIP16 P2SH <0 <20-byte-key-hash>> // 当该utxo的前置输出是P2SH的时候就需要这样写,20字节长为对应私钥的地址,也就是witness里的公钥的hash160 ffffff00 // sequence,非ffffffff表示locktime有效 e0080049a6c62fee278ed7e11901f21b7dd9b356eedce0ce4f59c230c1e365ba 00000000 1716001406c3d51e041b64e87a577ffd1a4ff5357cefd015ffffff00 6ce4d6d1c2ee3c259989f50991f4f71c4ca96b6e986b470b9a84fd7e97c5f17d 00000000 1716001406c3d51e041b64e87a577ffd1a4ff5357cefd015ffffff00 // output count 02 00e1f50500000000 // value 17 a914 e5394e8a18db94b5e28b74f094718cab23ef9feb 87 // P2SH a06e990700000000 17 a914 1ca5105565408eed39cdf021346313447bd99628 87 // witness P2WPKH 02 48 3045022100b6a271084b68c8b203bf708c6e725020d1e2997be2a88aef345303f62c3ce393022058ca1f83180467a3d0263a0183d28758ab797e6924c843cd797daeade984ed23 01 // sign script 21 0217cf57c2b592c9b00931370fd069b910b0b39c9f89f716d09ef614b1a3854b1c // publicKey 02 47 304402202dc1263af4dc28e2643fb5a1ceac2cd5b2d98bad3ae1d223adf809412db45ff602206c712c80be48cf60c8ce52b3757608fb66c6829f7ebcff807583380a1aff6ebd 01 21 0217cf57c2b592c9b00931370fd069b910b0b39c9f89f716d09ef614b1a3854b1c 02 47 30440220730c98896f0a4edd6ddcf5d5f1e5c04831cb1e7e6ad11e66623bc184e7242ffd02201d18e034c6764892d6dcd310488d6e9364e6abf2f7d51d31bc72ed3ac7b304ca 01 21 0217cf57c2b592c9b00931370fd069b910b0b39c9f89f716d09ef614b1a3854b1c 00000000
二、P2WSH
01000000
00
01
// input
01
b839a180196ce61747b30d2dd98551bed1ca2991377ccbd8bfdede8c339904a6
01000000
00
ffffffff
02 7dba920000000000 17 a914 9bc6f9caddaaab28c2bc0a8bf8531f91109bdd58 87 // P2SH e31c030000000000 22 0020 701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d // P2WSH // witness P2WSH, 0 <1 2 CHECKMULTISIG> 04 // var_int 00, sig1, sig2, 00 // it’s a bitcoin’s bug and remain to now 47 304402204280e3c1c1edca50fb3c8843c410943937ad72f7e167e1f3fa99ff909a1b7a0502201e15e94ff9ce09cdb4cd0ab5d8bba52c408b900b8e4044a740a41eb3e8d34cff 01 48 3045022100a9b09d4f387e90b2ed2e38ea4bdecd901f611b68032566d08600868ce2b3b6a3022058c4ab2770dcea1adc301ff3f84d26e4d3e7dff3fdee1123c378c7e8d209e744 01 69 // var_int, data_length 1 + 66 + 2 = 69 52 // OP_2 210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c 2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff 2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f880 53 // OP_3 ae // OP_CHECKMULTISIG 00000000
三、P2SH-P2WSH
01000000
00 01 01 36641869ca081e70f394c6948e8af409e18b619df2ed74aa106c1ca29787b96e 01000000 23220020a16b5755f7f6f96dbd65f5f0d6ab9418b89af4b1f14a1bb8a09062c35f0dcb54 ffffffff 02 00e9a43500000000 1976a914389ffce9cd9ae88dcc0631e88a821ffdbe9bfe2688ac c0832f0500000000 1976a9147480a33f950689af511e6e84c138dbbd3c3ee41588ac 08 00 47304402206ac44d672dac41f9b00e28f4df20c52eeb087207e8d758d76d92c6fab3b73e2b0220367750dbbe19290069cba53d096f44530e4f98acaa594810388cf7409a1870ce01 473044022068c7946a43232757cbdf9176f009a928e1cd9a1a8c212f15c1e11ac9f2925d9002205b75f937ff2f9f3c1246e547e54f62e027f64eefa2695578cc6432cdabce271502 473044022059ebf56d98010a932cf8ecfec54c48e6139ed6adb0728c09cbe1e4fa0915302e022007cd986c8fa870ff5d2b3a89139c9fe7e499259875357e20fcbb15571c76795403 483045022100fbefd94bd0a488d50b79102b5dad4ab6ced30c4069f1eaa69a4b5a763414067e02203156c6a5c9cf88f91265f5a942e96213afae16d83321c8b31bb342142a14d16381 483045022100a5263ea0553ba89221984bd7f0b13613db16e7a70c549a86de0cc0444141a407022005c360ef0ae5a5d4f9f2f87a56c1546cc8268cab08c73501d6b3be2e1e1a8a0882 4730440220525406a1482936d5a21888260dc165497a90a15669636d8edca6b9fe490d309c022032af0c646a34a44d1f4576bf6a4a74b67940f8faa84c7df9abe12a01a11e2b47 83 // OP_INVERT cf // data_length 1 + cc + 3 = cf 56 // OP_6 210307b8ae49ac90a048e9b53357a2354b3334e9c8bee813ecb98e99a7e07e8c3ba3 2103b28f0c28bfab54554ae8c658ac5c3e0ce6e79ad336331f78c428dd43eea8449b 21034b8113d703413d57761b8b9781957b8c0ac1dfe69f492580ca4195f50376ba4a 21033400f6afecb833092a9a21cfdf1ed1376e58c5d1f47de74683123987e967a8f4 2103a6d48b1131e94ba04d9737d61acdaa1322008af9602b3b14862c07a1789aac16 2102d8b661b0b3302ee2f162b09e07a55ad5dfbe673a9f01d9f0c19617681024306b 56 // OP_6 ae // OP_CHECKMULTISIG 00000000
相关文章:
- 比特币锁定脚本及地址解析(p2pkh p2sh p2wpkh p2wsh p2sh-p2wpkh p2sh-p2wsh格式)
- 隔离验证钱包开发指南
- 比特币锁定脚本带来的“坑”——真正掌握比特币的是“锁定脚本”,而不是私钥
- 比特币隔离见证(segwit)很酷,但它不是短期解决方案?
- 比特币中P2SH(pay-to-script-hash)多重签名的锁定脚本和解锁脚本
- 隔离见证激活,比特币王者归来
- BTC地址与交易原理大剖析:是谁控制了比特币,是你?还是钱包?
- 比特币改进协议BIP16:Pay to Script Hash(P2SH)
- 区块链学习笔记——一些交易脚本(P2PK、P2PKH、P2MS、P2SH)及作业回顾
- 干货 | 详尽解释隔离见证