<blockquote>
  <p>looks like address from dump is multisig?</p>
</blockquote>

<p>It is not multisig. Bitcoin Core does not generate multisig addresses.</p>

<p>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 <code>bitcoinjs-lib</code> are P2PKH addresses. However Bitcoin Core is making P2SH-P2WPKH addresses.</p>

<p>You should be able to get the same address if you do something like</p>

<pre><code>bitcoin.payments.p2sh({
      redeem: bitcoin.payments.p2wpkh({ pubkey: key.derivePath("m/0'/0'/0'").publicKey })
})
</code></pre>

CC BY-SA 4.0
2018-08-28T23:40:28.040Z
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
CC BY-SA 4.0
2018-08-28T23:50:57.053Z
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
CC BY-SA 4.0
2018-08-28T23:58:13.103Z
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
CC BY-SA 4.0
2018-08-29T00:32:34.943Z
Yes, those will be different addresses.
Ava Chow
CC BY-SA 4.0
2018-08-28T22:06:29.813Z
2018-08-28T22:06:29.813Z
Ava Chow
<p>First of all all addresses below are for testing purposes so I don't care about private keys.</p>

<p>So dumped wallet created by Bitcoin-qt v0.16.2:</p>

<p><code>extended private masterkey: xprv9s21ZrQH143K3mYiBBH7MwWV9VTkeB5q5sxEFGgvLbLqRZ3xPVAKvwyxSLVtTcL2tz665vdZnHLrMQPr6MWGKdDHYoncZmUNiUgtShGCmZE
</code></p>

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

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

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

<p>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?</p>

<p>If so how should I generate wallet.dat that is not multisig and is HD.</p>

<bitcoin-core><bitcoind><bip32-hd-wallets><bitcoinjs>
Can't generate same addresses as bitcoincore using xprv from bitcoin-core
elderapo
# Can't generate same addresses as bitcoincore using xprv from bitcoin-core

(Asked by: username_0 on 2018-08-28)

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(
 "xprv9s21ZrQH143K3mYiBBH7MwWV9VTkeB5q5sxEFGgvLbLqRZ3xPVAKvwyxSLVtTcL2tz665vdZnHLrMQPr6MWGKdDHYoncZmUNiUgtShGCmZE"
);
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.

**Tags:** bitcoin-core, bitcoind, bip32-hd-wallets, bitcoinjs


---

## 1 answers

### Answer by username_1 on 2018-08-28. Score: 2 | Accepted answer

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
bitcoin.payments.p2sh({
      redeem: bitcoin.payments.p2wpkh({ pubkey: key.derivePath("m/0'/0'/0'").publicKey })
})

> **Comments:**
> **username_0**: 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.  
> **username_1**: 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.  
> **username_0**: If I remove `'` from keypath now I can generate addresses using xpub now I believe that bitcoin-qt won't monitor these addresses right?  
> **username_1**: Yes, those will be different addresses.  

---

