getnewaddress returns unsolvable addresses after import from descriptors in a watchonly wallet. Exported addresses using https://github.com/bitcoin-core/hwi and its getkeypool command. Imported using the importmulti command.
getnewaddress returns solvable addresses.
Behavior varies based on which descriptors are imported.
Example of all three types together [ output of ./hwi.py getkeypool --all
]:
[{"desc": "pkh([b5f66c19/44h/0h/0h]xpub6D8yeA6gG4MgNTANfvqvZTg3jyrs63YzDiJVnQ3o9Bn425a8zAqu3VQEaKQr3hkeBLE21AuJbZHApnJjWzWGmR4fjS2YBtpKraDKY5esNbp/0/*)#lfa0d60w", "range": [0, 300], "timestamp": "now", "internal": false, "keypool": true, "active": true, "watchonly": true}, {"desc": "pkh([b5f66c19/44h/0h/0h]xpub6D8yeA6gG4MgNTANfvqvZTg3jyrs63YzDiJVnQ3o9Bn425a8zAqu3VQEaKQr3hkeBLE21AuJbZHApnJjWzWGmR4fjS2YBtpKraDKY5esNbp/1/*)#wacws0lk", "range": [0, 300], "timestamp": "now", "internal": true, "keypool": true, "active": true, "watchonly": true}, {"desc": "wpkh([b5f66c19/84h/0h/0h]xpub6Bf8q3qTbFC3So4JoLBsEjMbCMHNhNUxiaZox3aEVumoE584mHhTq8wBr8jkw5ukoTW5K14nSssx8MyUq5fcmdoGcoo7wsVfPfbX5t2e51w/0/*)#vknsa5l5", "range": [0, 300], "timestamp": "now", "internal": false, "keypool": true, "active": true, "watchonly": true}, {"desc": "wpkh([b5f66c19/84h/0h/0h]xpub6Bf8q3qTbFC3So4JoLBsEjMbCMHNhNUxiaZox3aEVumoE584mHhTq8wBr8jkw5ukoTW5K14nSssx8MyUq5fcmdoGcoo7wsVfPfbX5t2e51w/1/*)#azk3qp0v", "range": [0, 300], "timestamp": "now", "internal": true, "keypool": true, "active": true, "watchonly": true}, {"desc": "sh(wpkh([b5f66c19/49h/0h/0h]xpub6DWmKTzgzCoPEtxSxAP5pnEXxfF8UNRSHWyDMeCivSqokTzK7owDh3GGficKiGuqBMcuTUZE32oe7wevwRZaotXYfE8ig2Lt6Jr1Ry6BwbU/0/*))#9j0eptl9", "range": [0, 300], "timestamp": "now", "internal": false, "keypool": true, "active": true, "watchonly": true}, {"desc": "sh(wpkh([b5f66c19/49h/0h/0h]xpub6DWmKTzgzCoPEtxSxAP5pnEXxfF8UNRSHWyDMeCivSqokTzK7owDh3GGficKiGuqBMcuTUZE32oe7wevwRZaotXYfE8ig2Lt6Jr1Ry6BwbU/1/*))#snp0e526", "range": [0, 300], "timestamp": "now", "internal": true, "keypool": true, "active": true, "watchonly": true}]
If only legacy address descriptors (pkh) imported, then getnewaddress returns a solvable address for any address type.
If bech32 address descriptors (wpkh) imported:
bitcoin-cli getnewaddress
returns a solvable addressbitcoin-cli getnewaddress -addresstype legacy
returns an unsolvable addressbitcoin-cli getnewaddress -addresstype p2sh-segwit
returns a solvable address
If ‘sh(wpkh(’ descriptors imported:
bitcoin-cli getnewaddress
returns an unsolvable addressbitcoin-cli getnewaddress -addresstype legacy
returns an unsolvable addressbitcoin-cli getnewaddress -addresstype p2sh-segwit
returns a solvable address
Unsure of behavior when all are imported together. Depends on how the addresses are stored/retrieved in the keypool. Unsolvable addresses are definitely possible to be returned (lost funds while attempting to create a psbt with hardware wallet which sent change to an unsolvable address).
Steps to reproduce
- create new watchonly wallet
- unload default wallet
- export descriptors
- use importmulti to import descriptors
- call getnewaddress
Can reliably reproduce. Returns the exact same (un)solvable addresses each time running through process.
System information
Self-compiled bitcoin core v0.20.0.
Running Debian with Intel i5-3570 cpu, ssd.