Multi-Signature
與 coinb.in 部分簽署交易
我正在嘗試生成 2-of-2 多重簽名地址:
pubkey1``privkey1
在coinb.in上pubkey2
和privkey2
一個比特幣核心客戶端- 我
createmultisig 2 '''["<pubkey1>", "<pubkey2>']'''
在核心上使用生成 2-of-2 多重簽名地址。.
{ "address": "38RmRDRp4YedPXdh9Vu82akPRtXwvsPeRp", "redeemScript": "5221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae" }
我將 0.00001BTC 轉移到 txid 20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a 中的該地址,我 的目標是從多重簽名地址中花費這筆金額:
- 我在 bitcoincore 上創建了一個原始交易:
.
createrawtransaction '''[{ "txid": "20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a", "vout": 1 }]''' '''{ "1BT8tmV9Exfrx7FUjNvLQaUBgpZJaHyXMT": 0.00000900 }'''
- 我嘗試在 coinb.in 上簽署此交易
privkey2
:
- 我嘗試在核心上簽署第二筆交易:
.
signrawtransaction "01000000011a1f40dba3ab5c208b165d47bdcf2aadc517c4f2b90b781eab53dadcb35d6120010000006b483045022100d4367946074622b6e22a936adbded609fba5d2501c603b630d3e2edadcb5bcc402203ac6693fbf2ac7ac4d4234ef19be348b6511a0fcdf5991cb26ac2b695876534c0121020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ceffffffff0184030000000000001976a91472a2a94468e42593656cc9803c7a48c1863fc3e588ac00000000" '''[ { "txid": "20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a", "vout": 1, "scriptPubKey": "a91449e688475c78033674b8a645f4339fe41366251587", "redeemScript": "5221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae"} ]''' '''["privkey2"]'''
輸出
{ "hex": "01000000011a1f40dba3ab5c208b165d47bdcf2aadc517c4f2b90b781eab53dadcb35d6120010000009200473044022015ededd076573807b25a4e7facef5ad132683d54ffde8d28c1dbcab4be8e852e02204a063aec61cf6e1eee4825b9f19566a06f87db02913b283f9281a133127002030100475221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52aeffffffff0184030000000000001976a91472a2a94468e42593656cc9803c7a48c1863fc3e588ac00000000", "complete": false, "errors": [ { "txid": "20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a", "vout": 1, "scriptSig": "00473044022015ededd076573807b25a4e7facef5ad132683d54ffde8d28c1dbcab4be8e852e02204a063aec61cf6e1eee4825b9f19566a06f87db02913b283f9281a133127002030100475221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae", "sequence": 4294967295, "error": "Script evaluated without error but finished with a false/empty top stack element" } ] }
我究竟做錯了什麼?不幸的是,我無法指定
pubkeyscript
或redeemscrit
到 coinb.in,所以這可能是簽名未驗證的原因嗎?**注意:**當我在命令中指定兩個私鑰時,我可以在比特幣核心上成功簽署交易。
sign
好吧,我設法通過在呼叫coinbin的方法之前手動修改javascript中的事務來解決這個問題。我已在此處送出了有關詳細資訊的問題。這就是我最終在 Javascript 中解決問題的方式(這是一種 hack,我只是為每個輸入指定了相同的兌換腳本,這適用於我的特定案例):var rawtx2 = "01000000021a1f40dba3ab5c208b165d47bdcf2aadc517c4f2b90b781eab53dadcb35d61200100000000ffffffff05ec447a886d8711db0d5f4cbf1f61956cf227c82c5594ee195bb179e86faa910100000000ffffffff0138c70000000000001976a91472a2a94468e42593656cc9803c7a48c1863fc3e588ac00000000"; (function partialSignMultisig(window) { var coinjs = window.coinjs; var wifkey = "<WIFKEYHERE>"; var script = rawtx2; var redeemScript = "5221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae"; var tx = coinjs.transaction(); var t = tx.deserialize(script); // Manually specify scripts for inputs .. for (var i = 0; i < t.ins.length; i++) { t.ins[i].script = coinjs.script(redeemScript); } var signed = t.sign(wifkey); console.log( signed ); })(window);