getnewaddress returns unsolvable addresses in watchonly wallet #19686

issue infinitis openend this issue on August 8, 2020
  1. infinitis commented at 9:13 am on August 8, 2020: none

    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 address
    • bitcoin-cli getnewaddress -addresstype legacy returns an unsolvable address
    • bitcoin-cli getnewaddress -addresstype p2sh-segwit returns a solvable address

    If ‘sh(wpkh(’ descriptors imported:

    • bitcoin-cli getnewaddress returns an unsolvable address
    • bitcoin-cli getnewaddress -addresstype legacy returns an unsolvable address
    • bitcoin-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.

  2. infinitis added the label Bug on Aug 8, 2020
  3. achow101 commented at 3:25 pm on August 8, 2020: member

    It’s surprising to me that the pkh descriptor always returns a solvable address while the sh(wpkh( descriptor only returns a solvable for p2sh-segwit. I would have expected this to be the opposite since sh(wpkh( imports more information.

    For 0.21 onwards, you should use descriptor wallets which fix this entirely. You will only be able to get addresses for the descriptors that you import and there won’t be any of this address type mutation.

  4. adamjonas commented at 3:20 pm on July 25, 2022: member
    Confirmed with achow that this was solved by descriptors. Closing.
  5. adamjonas closed this on Jul 25, 2022

  6. bitcoin locked this on Jul 25, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-30 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me