First of all all addresses below are for testing purposes so I don't care about private keys.

So dumped wallet created by Bitcoin-qt v0.16.2:

extended private masterkey: xprv9s21ZrQH143K3mYiBBH7MwWV9VTkeB5q5sxEFGgvLbLqRZ3xPVAKvwyxSLVtTcL2tz665vdZnHLrMQPr6MWGKdDHYoncZmUNiUgtShGCmZE

From what I can understand from the rest of the dump the first receive address is: addr=3DhmoRSx2bjxyJm7A1Crs3bCPnVcEx51fE hdkeypath=m/0'/0'/0'

Now I am trying to generate same addess using bitcoinjs-lib but haven't had any success so far with it.

import { HDNode } from "bitcoinjs-lib";
const key = HDNode.fromBase58(
console.log(key.derivePath("m/0'/0'/0'").getAddress()); // prints 1NoQERVA18v5WcFUbgvz22tDGigmAkqy4U

Now I get confused becuase I use same derive path but I get 2 different addresses and on top of that looks like address from dump is multisig? Is it becuase of multisig?

If so how should I generate wallet.dat that is not multisig and is HD.

1 Answer 1


looks like address from dump is multisig?

It is not multisig. Bitcoin Core does not generate multisig addresses.

That address is a P2SH wrapped Segwit address. The same private key can be associated with multiple addresses since there are different types of addresses. The type of address you that you are generating with bitcoinjs-lib are P2PKH addresses. However Bitcoin Core is making P2SH-P2WPKH addresses.

You should be able to get the same address if you do something like

      redeem: bitcoin.payments.p2wpkh({ pubkey: key.derivePath("m/0'/0'/0'").publicKey })
  • Thanks! One more question. Is it possible to use this api to generate addresses using from xpub? I get TypeError: Missing private key for hardened child key error.
    – elderapo
    Commented Aug 28, 2018 at 23:40
  • No, you cannot derive hardened keys from an xpub. However you can use the xpub and derive keys with a non-hardened path. This means that your keypath cannot contain ', h, or H which indicate that that index should use hardened derivation.
    – Ava Chow
    Commented Aug 28, 2018 at 23:50
  • If I remove ' from keypath now I can generate addresses using xpub now I believe that bitcoin-qt won't monitor these addresses right?
    – elderapo
    Commented Aug 28, 2018 at 23:58
  • Yes, those will be different addresses.
    – Ava Chow
    Commented Aug 29, 2018 at 0:32

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.