<p>What're seeing is a P2SH embedded Segwit address.</p>

<p>It contains the hash of the script <code>OP_0 [20-byte hash160 of compressed pubkey]</code>.</p>

<p>You can configure Bitcoin Core to instead produce legacy P2PKH addresses (start with <code>-addresstype=legacy</code>). You can also make it construct Bech32 (BIP173) addresses using <code>-addresstype=bech32</code>, which represent the <code>OP_0 [20-byte hash160 of compressed pubkey]</code> script directly. These are cheaper to spend, but not all software supports sending to them.</p>

CC BY-SA 4.0
2018-09-03T00:25:31.433Z
2018-09-03T00:25:31.433Z
Pieter Wuille
<p>Thanks to @pieter-wuille, I confirm it is a P2SH embedded Segwit address:</p>

<pre><code>$ echo '0 [a01..pukbKeyHash..e8e]' | bx script-to-address -v  196
2Mu..xxxx..r
</code></pre>

<p>Or:</p>

<pre><code>$ echo '0 [a01..pukbKeyHash..e8e]' &gt; script3
$ bx script-encode &lt; script3 | bx sha256 | bx ripemd160 | bx base58check-encode --version 196
2Mu..xxxx..r
</code></pre>

<p>Which is the address I was looking for.</p>

CC BY-SA 4.0
2018-09-03T07:03:32.727Z
2018-09-03T07:03:32.727Z
robermann
<p>Why does the Testnet Wallet create receiving addresses in the form of script hash addresses (<a href="https://en.bitcoin.it/wiki/List_of_address_prefixes" rel="nofollow noreferrer">prefix</a> <em>2</em>) instead of &quot;plain&quot; <em>m/n</em>-prefixed addresses? Is there any security reason? And, which script does it hash? I was assuming, from <a href="https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki" rel="nofollow noreferrer" title="BIP 16">BIP.16</a>, a single-signature case:</p>
<blockquote>
<p>scriptPubKey: OP_HASH160 [20-byte-hash of {[pubkey] OP_CHECKSIG} ]
OP_EQUAL</p>
</blockquote>
<p>But I was not able to obtain the same script hash (of course I know the private key). I tried the following steps:</p>
<blockquote>
<p>$ echo [<em>02b6d...public key...47f89</em>] checksig &gt; script</p>
<p>$ bx script-encode &lt; script | bx sha256 | bx ripemd160</p>
<p><em>046f...fb3</em></p>
<p>$ echo hash160 [<em>046f...fb3</em>] equal &gt; script2</p>
<p>$ bx script-encode &lt; script2 | bx sha256 | bx ripemd160 | bx base58check-encode --version 196</p>
<p><em>2NxxxexxxxxL</em></p>
</blockquote>
<p>(I had expected to get the same result built by the wallet, but they were different).</p>
<p>Please note that I know for sure both the private and public keys.</p>

<wallet><address><testnet><p2sh>
Testnet Bitcoin wallet: which script in hash addresses?
robermann
# Testnet Bitcoin wallet: which script in hash addresses?

(Asked by: username_0 on 2018-09-02)

Why does the Testnet Wallet create receiving addresses in the form of script hash addresses ([prefix](https://en.bitcoin.it/wiki/List_of_address_prefixes) *2*) instead of "plain" *m/n*-prefixed addresses? Is there any security reason? And, which script does it hash? I was assuming, from [BIP.16](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki "BIP 16"), a single-signature case:

> scriptPubKey: OP\_HASH160 [20-byte-hash of {[pubkey] OP\_CHECKSIG} ]
> OP\_EQUAL

But I was not able to obtain the same script hash (of course I know the private key). I tried the following steps:

> $ echo [*02b6d...public key...47f89*] checksig > script
>
> $ bx script-encode < script | bx sha256 | bx ripemd160
>
> *046f...fb3*
>
> $ echo hash160 [*046f...fb3*] equal > script2
>
> $ bx script-encode < script2 | bx sha256 | bx ripemd160 | bx base58check-encode --version 196
>
> *2NxxxexxxxxL*

(I had expected to get the same result built by the wallet, but they were different).

Please note that I know for sure both the private and public keys.

**Tags:** wallet, address, testnet, p2sh


---

## 2 answers

### Answer by username_1 on 2018-09-03. Score: 3 | Accepted answer

What're seeing is a P2SH embedded Segwit address.

It contains the hash of the script `OP_0 [20-byte hash160 of compressed pubkey]`.

You can configure Bitcoin Core to instead produce legacy P2PKH addresses (start with `-addresstype=legacy`). You can also make it construct Bech32 (BIP173) addresses using `-addresstype=bech32`, which represent the `OP_0 [20-byte hash160 of compressed pubkey]` script directly. These are cheaper to spend, but not all software supports sending to them.


---

### Answer by username_0 on 2018-09-03. Score: 0

Thanks to @username_1-username_1, I confirm it is a P2SH embedded Segwit address:

```
$ echo '0 [a01..pukbKeyHash..e8e]' | bx script-to-address -v  196
2Mu..xxxx..r

```

Or:

```
$ echo '0 [a01..pukbKeyHash..e8e]' > script3
$ bx script-encode < script3 | bx sha256 | bx ripemd160 | bx base58check-encode --version 196
2Mu..xxxx..r

```

Which is the address I was looking for.


---

