A non-descriptor watch-only wallet with imported sh(wpkh( descriptor can generate Bech32 addresses that don't match the descriptor.
Steps to reproduce:
$ bitcoind -regtest -daemon -addresstype=bech32
$ bitcoin-cli -regtest createwallet test true
$ bitcoin-cli -regtest -rpcwallet=test importmulti \
'[{"desc":"sh(wpkh(tpubDCJtdt5dgJpdhW4MtaVYDhG4T4tF6jcLR1PxL43q9pq1mxvXgMS9Mzw1HnXG15vxUGQJMMSqCQHMTy3F1eW5VkgVroWzchsPD5BUojrcWs8/0/*))#e8nc36sh",
"timestamp":0, "range":1000, "watchonly":true, "keypool":true}]'
[
{
"success": true
}
]
$ bitcoin-cli -regtest -rpcwallet="test" getnewaddress
bcrt1quecj0a95x3s570h0rs7l2rxgmcudhphzl0g2q4
$ bitcoin-cli -regtest -rpcwallet="test" getaddressinfo bcrt1quecj0a95x3s570h0rs7l2rxgmcudhphzl0g2q4
{
"address": "bcrt1quecj0a95x3s570h0rs7l2rxgmcudhphzl0g2q4",
"scriptPubKey": "0014e67127f4b434614f3eef1c3df50cc8de38db86e2",
"ismine": false,
"solvable": false,
"iswatchonly": false,
"isscript": false,
"iswitness": true,
"witness_version": 0,
"witness_program": "e67127f4b434614f3eef1c3df50cc8de38db86e2",
"ischange": false,
"labels": [
""
]
}
This is quite unexpected. It's generating Bech32 address from a sh(wpkh( descriptor. And not only that, the wallet isn't watching the generated address. So it can be quite a footgun, which could lead to (perceived) funds loss.
For example with HWI, coming from Trezor software which defaults to p2sh-segwit, people will be importing, say, sh(wpkh(m/49'/1'/0'/0/*)). If they forget to set the address type to p2sh-segwit, they'll generate addresses that seem to come out of the blue.
Expected behavior: getnewaddress fails with no key available.