When I use bitcoin-cli -testnet
to generate a 2-of-3 address, the code:
bitcoin-cli -testnet createmultisig 2 '''
[
"03b91ff254ae3bb3861e4a6c16ab356d6c52ccfd2b58bedf0dda84657dfd9d9afc",
"039f1475fb37d91ed65765c897acbdc37da3a7aba19f5b8ad5ff22a994e8350798",
"030ee8793fa2cb93f0cfd475b990cbaa48a28d83bd8f434348607368e52644febf"
]'''
the result is
"address": "2MzSwUwBc1xuNHwRotwrdFugLvju8VV9uPT",
But when I use bitcoinjs-lib
, the code is:
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);
Now the address changed to
38tjRCFaQWQ269oGDpEkdxh5iPgxh7kvtB
How could this happen? Did I do something wrong?