p2sh交易脚本例子

区块链 比特币

1、四对地址、公私密钥

mzQap8EAm5tywEBNwxVuAPo8yEqiJqc315  0204dad9c51db6162243c3c640ecd0028d4de99b69e3f933d7f413072ed0be9957  cUEoostggeK2NbgXcML5w4UK973rVRhJHuNh4ZHTwA2y2K1mfLfy
mmAjouEHRYNYeDG8U1EMMYBqRzgmecqevf  0297cc8765d5848f6838c94baf946fb1a3828a76b26971abce42792243035198c0  cU3Qzxw2S5bK7qhy3Sy847yvBfmTusDjJKAUinjCKQECQVKTGmzq
mxbw4DK1En8dyq3uavyc5aiw1DtA6nwtia  03aced0d5e71ae61f471c80f9d672560421c402690d135e15f687f50657dfcaaed  cNhm5FbQURmpp57r1cjWnjUwWDZLyejvSD4kGQJn9isc3Y5qAD1z
n2HxwFE7pMg872aEjhNHh2KoCDrxue18gd  02a1c41cc3abc41cc2509fea0311cfef73a08b6018f37a4da2f42407cb9bc9d6d8  cPwS2ujirizqJMVyi891vikACi1aDYdagjXJAcsMP61eDmKMgw6r

2、生成地址

addmultisigaddress 2 "[\"0204dad9c51db6162243c3c640ecd0028d4de99b69e3f933d7f413072ed0be9957\",\"0297cc8765d5848f6838c94baf946fb1a3828a76b26971abce42792243035198c0\",\"03aced0d5e71ae61f471c80f9d672560421c402690d135e15f687f50657dfcaaed\",\"02a1c41cc3abc41cc2509fea0311cfef73a08b6018f37a4da2f42407cb9bc9d6d8\"]" "" "p2sh-segwit" 

{
  "address": "2MtzyMhqgBpt68Df6fipwGgkhXVk2vjtj3z",
  "redeemScript": "52210204dad9c51db6162243c3c640ecd0028d4de99b69e3f933d7f413072ed0be9957210297cc8765d5848f6838c94baf946fb1a3828a76b26971abce42792243035198c02103aced0d5e71ae61f471c80f9d672560421c402690d135e15f687f50657dfcaaed2102a1c41cc3abc41cc2509fea0311cfef73a08b6018f37a4da2f42407cb9bc9d6d854ae"
}

3、创建交易

createrawtransaction '[{"txid":"355a42bf30840adb09bd869bf58559e5979742949a54c16ee75d31a077b01484","vout":0}]' '{"mvPKDSBZuGC4BxF1kPvrCjG6ZPKzc1H1vx":0.20000000,"2MtzyMhqgBpt68Df6fipwGgkhXVk2vjtj3z":0.01980000}'

02000000018414b077a0315de76ec1549a94429797e55985f59b86bd09db0a8430bf425a350000000000ffffffff02002d3101000000001976a914a31805c29bca9034539bd38505e632542062141088ac60361e000000000017a914133e370c576028a6d010fae4e76779b08c2697c28700000000

4、签名

signrawtransaction '[{"scriptPubKey":"a914133e370c576028a6d010fae4e76779b08c2697c287","amount":0.22,"txid":"355a42bf30840adb09bd869bf58559e5979742949a54c16ee75d31a077b01484","redeemScript":"52210204dad9c51db6162243c3c640ecd0028d4de99b69e3f933d7f413072ed0be9957210297cc8765d5848f6838c94baf946fb1a3828a76b26971abce42792243035198c02103aced0d5e71ae61f471c80f9d672560421c402690d135e15f687f50657dfcaaed2102a1c41cc3abc41cc2509fea0311cfef73a08b6018f37a4da2f42407cb9bc9d6d854ae","vout":0}]'
'["cUEoostggeK2NbgXcML5w4UK973rVRhJHuNh4ZHTwA2y2K1mfLfy","cU3Qzxw2S5bK7qhy3Sy847yvBfmTusDjJKAUinjCKQECQVKTGmzq"]'

{
  "hex": "020000000001018414b077a0315de76ec1549a94429797e55985f59b86bd09db0a8430bf425a35000000002322002072345680240a467d24e590590142dca1b31df46ca938471bc7faceb197ec67ecffffffff02002d3101000000001976a914a31805c29bca9034539bd38505e632542062141088ac60361e000000000017a914133e370c576028a6d010fae4e76779b08c2697c287040047304402201398be33ba76fed3abca2aded0669f9e1d04566ed431cada13875321e03aaee30220040f97b29992485ccb32cfbe2bffbbdb79da897deede0655b3abeb1bd9bf96cb01473044022024c4b4888a47b5ab58f675bdba20d802cb7c2e06b5ee5751e7ce3b741488eedd02203fa200ad02115944e19d5c670ea46cc7dede6d840364a9e9b6315fbe604e91c0018b52210204dad9c51db6162243c3c640ecd0028d4de99b69e3f933d7f413072ed0be9957210297cc8765d5848f6838c94baf946fb1a3828a76b26971abce42792243035198c02103aced0d5e71ae61f471c80f9d672560421c402690d135e15f687f50657dfcaaed2102a1c41cc3abc41cc2509fea0311cfef73a08b6018f37a4da2f42407cb9bc9d6d854ae00000000",
  "complete": true
}

5、广播

sendrawtransaction '020000000001018414b077a0315de76ec1549a94429797e55985f59b86bd09db0a8430bf425a35000000002322002072345680240a467d24e590590142dca1b31df46ca938471bc7faceb197ec67ecffffffff02002d3101000000001976a914a31805c29bca9034539bd38505e632542062141088ac60361e000000000017a914133e370c576028a6d010fae4e76779b08c2697c287040047304402201398be33ba76fed3abca2aded0669f9e1d04566ed431cada13875321e03aaee30220040f97b29992485ccb32cfbe2bffbbdb79da897deede0655b3abeb1bd9bf96cb01473044022024c4b4888a47b5ab58f675bdba20d802cb7c2e06b5ee5751e7ce3b741488eedd02203fa200ad02115944e19d5c670ea46cc7dede6d840364a9e9b6315fbe604e91c0018b52210204dad9c51db6162243c3c640ecd0028d4de99b69e3f933d7f413072ed0be9957210297cc8765d5848f6838c94baf946fb1a3828a76b26971abce42792243035198c02103aced0d5e71ae61f471c80f9d672560421c402690d135e15f687f50657dfcaaed2102a1c41cc3abc41cc2509fea0311cfef73a08b6018f37a4da2f42407cb9bc9d6d854ae00000000'

2a7dca88e791bcf1e6440813ac91bb81d91c566fa749a54b86ca5c8cacf5816b

以上5步是p2sh交易在测试网络下的例子。

发表评论