When I use bitcoin-cli -testnet to generate a 2-of-3 address, the code:

bitcoin-cli -testnet createmultisig 2 '''

the result is

"address": "2MzSwUwBc1xuNHwRotwrdFugLvju8VV9uPT",

But when I use bitcoinjs-lib, the code is:

var pubKeys = [
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


How could this happen? Did I do something wrong?

1 Answer 1


you run bitcoinjs-lib in main-net mode and it generates the human-readable address for main-net

bitcoin-cli you execute with -testnet parameter and got address for test-net

you can check that these hashes are the same:



both are 4f0017ef9291b625bec1d7efacc246a37b293682

  • 1
    Thanks for your answer. I want upvote your answer but I don't have enough reputations. Thanks again. Aug 31, 2017 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.