user86618: Why does the Testnet Wallet create receiving addresses in the form of script hash addresses (prefix 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, 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.

user208: 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.

86618: <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>
 208: <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>
