I want to create bitcoin address from extended public key, without exposing private key but did not get any success till now. Do someone know how to do it? I am using bitcore-lib package

  • can you provide any code and the problems you're having?
    – JBaczuk
    Commented Jul 24, 2018 at 13:36

1 Answer 1


According to BIP32 you're trying to generate a non-hardened child address, see BIP32 - Public parent key → public child key.

Using bitcore-lib, to derive a non-hardened child public key and a P2PKH address:

var bitcore = require('bitcore-lib');
var Address = bitcore.Address;
var PublicKey = bitcore.PublicKey;
var Networks = bitcore.Networks;

var hdPublickey = new bitcore.HDPublicKey('tpubD6NzVbkrYhZ4XLMmry7XriYJ6Xgx1vQqoUZHLUXQPDB32n7pQYaWSMpRttm2sHzYjsQqrsAZYyJCmoEJB51oSdqZxq7epGjP4vHriCYz7Tp');
var orderPublickey = hdPublickey.deriveChild("m/44/145/0/0");
var pubkey = new PublicKey(orderPublickey.publicKey);
var address = Address.fromPublicKey(pubkey, Networks.testnet);
console.log("address", address);

address <Address: mkVBk6gZ7rBLYXvpdcKwTEq6SjHvSeLwZ8, type: pubkeyhash, network: testnet>

  • could we convert this publicKey into bitcoin base58 address?
    – rahul_eth
    Commented Jul 24, 2018 at 13:51
  • I got this method bitcore.Address.fromPublicKey() but it is not working
    – rahul_eth
    Commented Jul 24, 2018 at 13:58
  • What is it doing? Also, try var address = Address(publicKey, 'mainnet').toString(); Also it depends on what type of address you want (p2sh or p2pkh)
    – JBaczuk
    Commented Jul 24, 2018 at 14:02
  • please define Address? do you have any working code that can generate bitcoin address from xpub?
    – rahul_eth
    Commented Jul 24, 2018 at 14:05
  • Have you tried the above? Is it not working for you?
    – JBaczuk
    Commented Jul 24, 2018 at 14:14

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.