<p>I'm trying to derive address from pubkeyhash in GoLang. Current i'm getting invalid address
Current i'm getting SegWit address but mine chain doesn't support Segwit.</p>
<pre><code>addr, err := btcutil.NewAddressWitnessPubKeyHash(
        btcutil.Hash160(request.PublicKey.Bytes),
        s.config.Params,
    )
</code></pre>
<p>Params:</p>
<pre><code>Name: &quot;test&quot;,

    Net:         0xba657645,
    DefaultPort: &quot;46464&quot;,

    GenesisBlock: &amp;TestnetGenesisBlock,
    GenesisHash:  &amp;TestnetGenesisHash,

    PubKeyHashAddrID:        0x8B,
    ScriptHashAddrID:        0x13,
    PrivateKeyID:            0xEF,

    HDPrivateKeyID: [4]byte{0x3a, 0x80, 0x58, 0x37},
    HDPublicKeyID:  [4]byte{0x3a, 0x80, 0x61, 0xa0},

    HDCoinType: 1,
</code></pre>
<p>Can someone help me with solving this.
I'm trying to implement rosetta-api</p>

CC BY-SA 4.0
2022-05-11T12:22:40.483Z
You are using `btcutil.NewAddressWitnessPubKeyHash` rather than `NewAddressPubKeyHash` but you don't want Segwit. Is that true?
RedGrittyBrick
CC BY-SA 4.0
2022-05-11T16:53:40.350Z
@RedGrittyBrick, yes you are right, i don't want Segwit addresses
masternode
CC BY-SA 4.0
2022-05-11T17:10:27.950Z
@RedGrittyBrick Thanks for the tip for NewAddressPubKeyHash, i have solved the issue. +1
masternode
<public-key>
WitnessPubKeyHash to address
masternode
# WitnessPubKeyHash to address

(Asked by: username_0 on 2022-05-11)

I'm trying to derive address from pubkeyhash in GoLang. Current i'm getting invalid address
Current i'm getting SegWit address but mine chain doesn't support Segwit.

```
addr, err := btcutil.NewAddressWitnessPubKeyHash(
        btcutil.Hash160(request.PublicKey.Bytes),
        s.config.Params,
    )

```

Params:

```
Name: "test",

    Net:         0xba657645,
    DefaultPort: "46464",

    GenesisBlock: &TestnetGenesisBlock,
    GenesisHash:  &TestnetGenesisHash,

    PubKeyHashAddrID:        0x8B,
    ScriptHashAddrID:        0x13,
    PrivateKeyID:            0xEF,

    HDPrivateKeyID: [4]byte{0x3a, 0x80, 0x58, 0x37},
    HDPublicKeyID:  [4]byte{0x3a, 0x80, 0x61, 0xa0},

    HDCoinType: 1,

```

Can someone help me with solving this.
I'm trying to implement rosetta-api

**Tags:** public-key

> **Comments:**
> **username_1**: You are using `btcutil.NewAddressWitnessPubKeyHash` rather than `NewAddressPubKeyHash` but you don't want Segwit. Is that true?  
> **username_0**: @username_1, yes you are right, i don't want Segwit addresses  
> **username_0**: @username_1 Thanks for the tip for NewAddressPubKeyHash, i have solved the issue. +1  

---

## 0 answers

