<p>Because a "segwit address" starting with a <code>3</code> is actually a specific type of P2SH, the scriptPubKey will just be a normal P2SH scriptPubKey, which doesn't reveal anything about the script itself (only a hash of the script). You need the redeem script, which will be a null byte followed by a push of the public key hash. From what I can recall, the script is output in the <code>hex</code> field of the validateaddress result.</p>

<p>Again, the public key hash doesn't actually reveal the public key, so once you have that there will probably be an extra step required, perhaps conversion of the public key hash into an address starting with a <code>1</code> and then validateaddress on that.</p>

<p>It is unfortunate that the support for segwit addresses is not great in version 0.15.x, it'll be much better in 0.16 when Peter Wuille's segwit wallet PR is merged</p>

CC BY-SA 3.0
2018-01-03T18:57:10.430Z
This did the trick! I took the "hex" field from "validateaddress" and decoded it using command "decodescript". There in the "asm" field I found the public key hash (the second string). Then using blockchain.info I searched for that hash and I landed in the legacy address behind the SegWit address. Using "validateaddress" one more time I found the public key in the "pubkey" field. Thanks a lot!
Paul
CC BY-SA 3.0
2018-01-03T07:38:32.157Z
2018-01-03T07:38:32.157Z
meshcollider
<p>I'm using bitcoin-cli and I need to get the public key of one of my SegWit addresses. My first attempt was to use 'validateaddress' command and take the 'scriptPubKey' field but that doesn't seem to be the public key of the address. Any ideas?</p>

<segregated-witness><public-key><bitcoin-cli>
Get public key of SegWit address
Paul
# Get public key of SegWit address

(Asked by: username_0 on 2018-01-03)

I'm using bitcoin-cli and I need to get the public key of one of my SegWit addresses. My first attempt was to use 'validateaddress' command and take the 'scriptPubKey' field but that doesn't seem to be the public key of the address. Any ideas?

**Tags:** segregated-witness, public-key, bitcoin-cli


---

## 1 answers

### Answer by username_1 on 2018-01-03. Score: 1 | Accepted answer

Because a "segwit address" starting with a `3` is actually a specific type of P2SH, the scriptPubKey will just be a normal P2SH scriptPubKey, which doesn't reveal anything about the script itself (only a hash of the script). You need the redeem script, which will be a null byte followed by a push of the public key hash. From what I can recall, the script is output in the `hex` field of the validateaddress result.

Again, the public key hash doesn't actually reveal the public key, so once you have that there will probably be an extra step required, perhaps conversion of the public key hash into an address starting with a `1` and then validateaddress on that.

It is unfortunate that the support for segwit addresses is not great in version 0.15.x, it'll be much better in 0.16 when Peter Wuille's segwit wallet PR is merged

> **Comments:**
> **username_0**: This did the trick! I took the "hex" field from "validateaddress" and decoded it using command "decodescript". There in the "asm" field I found the public key hash (the second string). Then using blockchain.info I searched for that hash and I landed in the legacy address behind the SegWit address. Using "validateaddress" one more time I found the public key in the "pubkey" field. Thanks a lot!  

---

