Script

MULTISIG 驗證交易不會在測試網上被探勘

  • December 5, 2018

我正在嘗試在比特幣測試網上檢查以下簡單的 MULTISIG P2SH 腳本(使用python-bitcoinlib):

Redeem = CScript([2, J1_public_key, J2_public_key, J3_public_key, 3, OP_CHECKMULTISIG])
ex31a_txout_scriptPubKey = Redeem.to_p2sh_scriptPubKey()

我的第一筆交易被挖了。這是連結。經python庫驗證,python-bitcoinlib以下scriptSig可以兌換幣。

J2_signature = create_OP_CHECKSIG_signature(txin, txout, Redeem,
                                         J2_private_key)
J3_signature = create_OP_CHECKSIG_signature(txin, txout, Redeem,
                                         J3_private_key)

dummy = 123
txin_scriptSig = CScript([dummy, J2_signature, J3_signature, Redeem])   

但是,我的兌換交易不會在測試網上被探勘。我不知道為什麼!


編輯

一個最小的例子被替換而不是前一個。

新腳本使用 P2SH。

這是交易的API程式碼:

{
 "block_height": -1,
 "block_index": -1,
 "hash": "6371461a476ae87dd31b89e7deb9ff59b9679306b23ff86036dc3d7851a76a3c",
 "hex": "01000000019d8e6c705ba87c12f785542ea6253478585a24d871624036c3cfa30b1c0bfbe400000000fddb01017b483045022100dc369db54ceaa7b182969f23a176ae21d14272dff8d941360a5140d17f196e24022044ed2a8c05c5eff115fd5536478027b74a8aeea8f8e393377fcf7c8c232b352201483045022100c227a4fa63b5040bc85a5e7b15c0b081aadd4c538223fa9d8c90cadbc04e649702205a72760687a8c9e74202bfd11b6661f44f093e51a7a4eb4d89876303a9bc94d8014730440220586615cbc74089d7ab4aaf96dc857c0d523df77260159dced512f72c9d3d88b30220177c6f3eb5622ed263c28052ffcda89062a1bda74fdf8e398fba76dd85942bbd014cfd6e51210245aef9640296f238a04b0ee9af1e8dc62a6fe51214af7d3c5bfe518a9cd5afaf2103482de8ad8bf744318b97063544d2fc59322f63baad3d1054ea57609cdb059b6452af6e52210245aef9640296f238a04b0ee9af1e8dc62a6fe51214af7d3c5bfe518a9cd5afaf2103482de8ad8bf744318b97063544d2fc59322f63baad3d1054ea57609cdb059b6452ae635167522102e1183cefc9b3fb15e15bfc53703a6d2e626ccf42cc017f84ec41486114d8cefe210200139f5a548a7cebce4be1308a0262fbb04ec2ea6fc5b38bb3c4ac140ccb5d852102259a3b4527adf82a32e06fb177f27e0606c10f329a22ba7b206ea3eef0e5aa2853ae68ffffffff01a0860100000000001976a9149f9a7abd600c0caa03983a77c8c3df8e062cb2fa88ac00000000",
 "addresses": [
   "2Mz66CzbFYADatUbwXWqHxayRrMHoTCAqXn",
   "mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB"
 ],
 "total": 100000,
 "fees": 400000,
 "size": 562,
 "preference": "high",
 "relayed_by": "194.225.46.158",
 "received": "2018-11-18T21:19:22.298Z",
 "ver": 1,
 "double_spend": false,
 "vin_sz": 1,
 "vout_sz": 1,
 "confirmations": 0,
 "inputs": [
   {
     "prev_hash": "e4fb0b1c0ba3cfc336406271d8245a58783425a62e5485f7127ca85b706c8e9d",
     "output_index": 0,
     "script": "017b483045022100dc369db54ceaa7b182969f23a176ae21d14272dff8d941360a5140d17f196e24022044ed2a8c05c5eff115fd5536478027b74a8aeea8f8e393377fcf7c8c232b352201483045022100c227a4fa63b5040bc85a5e7b15c0b081aadd4c538223fa9d8c90cadbc04e649702205a72760687a8c9e74202bfd11b6661f44f093e51a7a4eb4d89876303a9bc94d8014730440220586615cbc74089d7ab4aaf96dc857c0d523df77260159dced512f72c9d3d88b30220177c6f3eb5622ed263c28052ffcda89062a1bda74fdf8e398fba76dd85942bbd014cfd6e51210245aef9640296f238a04b0ee9af1e8dc62a6fe51214af7d3c5bfe518a9cd5afaf2103482de8ad8bf744318b97063544d2fc59322f63baad3d1054ea57609cdb059b6452af6e52210245aef9640296f238a04b0ee9af1e8dc62a6fe51214af7d3c5bfe518a9cd5afaf2103482de8ad8bf744318b97063544d2fc59322f63baad3d1054ea57609cdb059b6452ae635167522102e1183cefc9b3fb15e15bfc53703a6d2e626ccf42cc017f84ec41486114d8cefe210200139f5a548a7cebce4be1308a0262fbb04ec2ea6fc5b38bb3c4ac140ccb5d852102259a3b4527adf82a32e06fb177f27e0606c10f329a22ba7b206ea3eef0e5aa2853ae68",
     "output_value": 500000,
     "sequence": 4294967295,
     "addresses": [
       "2Mz66CzbFYADatUbwXWqHxayRrMHoTCAqXn"
     ],
     "script_type": "pay-to-script-hash",
     "age": 0
   }
 ],
 "outputs": [
   {
     "value": 100000,
     "script": "76a9149f9a7abd600c0caa03983a77c8c3df8e062cb2fa88ac",
     "addresses": [
       "mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB"
     ],
     "script_type": "pay-to-pubkey-hash"
   }
 ]
}

看來問題與測試網本身有關。由於測試網中的費用不是真實的,未成年人沒有動力去探勘複雜的腳本。因此,諸如 MULTISIG 之類的腳本可能不會被探勘(對我來說很有可能接近一個!)。

要看到這一點,您可以在 scriptSig 的開頭添加一個大數字。

對於 MULTISIG,不使用 P2SH 方法就足夠了。IE

ex32a_txout_scriptPubKey = CScript([2, J1_public_key, J2_public_key, J3_public_key, 3, OP_CHECKMULTISIG])

scriptSig 可以是:

CScript([dummy, dummy, J2_signature, J3_signature])

該交易被辨識為pay-to-multi-pubkey-hash並被開採

然而,這並不能解決測試網上更複雜的腳本的問題。

引用自:https://bitcoin.stackexchange.com/questions/81142