Multi-Signature

來自相同公鑰的不同多重簽名地址

  • August 11, 2019

當我使用bitcoin-cli -testnet生成 2-of-3 地址時,程式碼:

bitcoin-cli -testnet createmultisig 2 '''
[
  "03b91ff254ae3bb3861e4a6c16ab356d6c52ccfd2b58bedf0dda84657dfd9d9afc",
  "039f1475fb37d91ed65765c897acbdc37da3a7aba19f5b8ad5ff22a994e8350798", 
  "030ee8793fa2cb93f0cfd475b990cbaa48a28d83bd8f434348607368e52644febf"
]'''

結果是

"address": "2MzSwUwBc1xuNHwRotwrdFugLvju8VV9uPT",

但是當我使用時bitcoinjs-lib,程式碼是:

var pubKeys = [
'03b91ff254ae3bb3861e4a6c16ab356d6c52ccfd2b58bedf0dda84657dfd9d9afc',
'039f1475fb37d91ed65765c897acbdc37da3a7aba19f5b8ad5ff22a994e8350798',
'030ee8793fa2cb93f0cfd475b990cbaa48a28d83bd8f434348607368e52644febf'
].map(function(hex){
return new Buffer(hex, 'hex');
});


var redeemScript = bitcoin.script.multisig.output.encode(2, pubKeys); // 2 of 3
var scriptPubkey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript));
var address = bitcoin.address.fromOutputScript(scriptPubkey);

現在地址改為

38tjRCFaQWQ269oGDpEkdxh5iPgxh7kvtB

這怎麼可能發生?我做錯什麼了嗎?

你在其中執行 bitcoinjs-lib,main-net mode它會為 main-net 生成人類可讀的地址

使用參數執行的 bitcoin-cli-testnet並獲得了 test-net 的地址

您可以檢查這些雜湊是否相同:

<https://testnet.smartbit.com.au/tx/8c67e4d3264696d222d5a72c70c8806eb3f12b9a02d1bc80554ab00803be86c0>

<https://blockchain.info/address/38tjRCFaQWQ269oGDpEkdxh5iPgxh7kvtB>

兩者都是4f0017ef9291b625bec1d7efacc246a37b293682

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