<p>Addresses are hashed and encoded <code>pubKeyScript</code>. There are different types of address you can derive per a single public-key (or say also private-key). Most prominent ones are <code>P2PKH</code>, <code>P2SH-P2WPKH</code>, native <code>P2WPKH</code> (bech32).</p>

<p>I expect that the address type you are deriving from BTCD is different then the one your getting from Core.</p>

<p>Since a Core 0.16 (until now time of writing Aug 2018), the default address derivation format is "p2sh-segwit" (<code>P2SH-P2WPKH</code>, starting with <code>3</code>). I could imaging that BTCD still derives you P2PKH addresses (starting with <code>1</code>).</p>

<p>Since 0.16, Core has that <code>addresstype</code> argument where you can pass in "legacy" or "bech32" in order to generate either traditional P2PKH addresses or new Bech32 ("bc1...") addresses</p>

CC BY-SA 4.0
2018-08-30T12:37:25.607Z
2018-08-30T12:37:25.607Z
Jonas Schnelli
<p>I found that cause.</p>

<p><code>
wif, err := btcutil.NewWIF(privateKey, conf, false)
</code>
That third parameter is compress and it should be true.
In the ends, generated address by golang and shown on bitcoin core after <code>importprivkey</code> command was matched.</p>

<p>Thanks!</p>

CC BY-SA 4.0
2018-09-01T00:32:38.973Z
2018-09-01T00:32:38.973Z
Harry
<p>For now, I'm generating WIF and address using golang btcutil package programmatically.</p>

<pre><code>    wif, err := btcutil.NewWIF(privateKey, conf, false)
    if err != nil {
        return nil, err
    }
    strPrivateKey := wif.String()

    // Address
    address, err := child.Address(conf)

    walletKeys[i] = WalletKey{WIF: strPrivateKey, Address: address.String(), EncodedAddress: address.EncodeAddress()}
</code></pre>

<p>After generating wif, I import this wif using bitcoin client importprivkey</p>

<pre><code>err := b.client.ImportPrivKeyRescan(privKeyWIF, label, false)
</code></pre>

<p>And then, I make sure this private key is added into wallet using getaddressesbyaccount "label" command.</p>

<p>Somehow listed address and first generated address seems different.</p>

<p>I'd like to know why it's different.</p>

<p>Thanks in advance.</p>

<bitcoin-core><client><btcd>
address format is different from bitcoin core response from btcd
Harry
# address format is different from bitcoin core response from btcd

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

For now, I'm generating WIF and address using golang btcutil package programmatically.

```
    wif, err := btcutil.NewWIF(privateKey, conf, false)
    if err != nil {
        return nil, err
    }
    strPrivateKey := wif.String()

    // Address
    address, err := child.Address(conf)

    walletKeys[i] = WalletKey{WIF: strPrivateKey, Address: address.String(), EncodedAddress: address.EncodeAddress()}

```

After generating wif, I import this wif using bitcoin client importprivkey

```
err := b.client.ImportPrivKeyRescan(privKeyWIF, label, false)

```

And then, I make sure this private key is added into wallet using getaddressesbyaccount "label" command.

Somehow listed address and first generated address seems different.

I'd like to know why it's different.

Thanks in advance.

**Tags:** bitcoin-core, client, btcd


---

## 2 answers

### Answer by username_1 on 2018-08-30. Score: 1 | Accepted answer

Addresses are hashed and encoded `pubKeyScript`. There are different types of address you can derive per a single public-key (or say also private-key). Most prominent ones are `P2PKH`, `P2SH-P2WPKH`, native `P2WPKH` (bech32).

I expect that the address type you are deriving from BTCD is different then the one your getting from Core.

Since a Core 0.16 (until now time of writing Aug 2018), the default address derivation format is "p2sh-segwit" (`P2SH-P2WPKH`, starting with `3`). I could imaging that BTCD still derives you P2PKH addresses (starting with `1`).

Since 0.16, Core has that `addresstype` argument where you can pass in "legacy" or "bech32" in order to generate either traditional P2PKH addresses or new Bech32 ("bc1...") addresses


---

### Answer by username_0 on 2018-09-01. Score: 1

I found that cause.

`wif, err := btcutil.NewWIF(privateKey, conf, false)`
That third parameter is compress and it should be true.
In the ends, generated address by golang and shown on bitcoin core after `importprivkey` command was matched.

Thanks!


---

