Testnet Bitcoin wallet: which script in hash addresses? Why does the Testnet Wallet create receiving addresses in the form of script hash addresses (prefix 2) instead of &quot;plain&quot; 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 &gt; script
$ bx script-encode &lt; script | bx sha256 | bx ripemd160
046f...fb3
$ echo hash160 [046f...fb3] equal &gt; script2
$ bx script-encode &lt; 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.
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.