Allow direct importing of xpubs #14449

issue ch4ot1c openend this issue on October 9, 2018
  1. ch4ot1c commented at 7:59 pm on October 9, 2018: contributor

    With the new HD wallet code, importing wallets by xpub is now a possibility.

    This would facilitate the creation of watch-only wallets. The current process, as I understand it, includes:

    • Create a new wallet.dat (with createwallet or on first-run)
    • Use dumpwallet to create a file with the extended private masterkey
    • Delete the wallet
    • Recreate the wallet from its xprv with createwallet "name" true, so it is watch-only

    This doesn’t consider the use case where an offline external client generates the xprv and xpub

    We should be allowed to import an xpub:

    • At the root
    • At a given derivation path
  2. fanquake added the label Wallet on Oct 9, 2018
  3. ch4ot1c commented at 9:28 pm on October 10, 2018: contributor
    I now see #13926. Adding xpubs via bitcoin-cli could still be useful, though.
  4. Sjors commented at 9:32 am on October 17, 2018: member

    Concept ACK.

    I think the best approach would be to add descriptor support to createwallet. Alternatively you would create an empty wallet and then import using an ~improved~ alternative to importmulti with descriptor support (e.g. importdescriptor).

    Take for example a bech32 enabled (BIP84) hardware wallet:

    0bitcoin-cli createwallet "my_hardware_wallet" true 
    1   '{"receiveDescriptor": "wpkh(tprv8Z...bK/84h/0h/0h/0/[0-1000]",
    2      "changeDescriptor": "wpkh(tprv8Z...bK/84h/0h/0h/1/[0-1000]"}'`
    

    (or however we want to add ranges to descriptors)

    This above example uses the master private key to derive everything, which is obviously unsafe. Instead you would use the account xpub, but keep the full derivation info (needed for signing) #14150:

    0bitcoin-cli createwallet "my_hardware_wallet" true 
    1   '{"receiveDescriptor": "wpkh(fingerprint/84h/0h/0h:account_xpub/0/[0-1000]",
    2      "changeDescriptor": "wpkh(fingerprint/84h/0h/0h:account_xpub/1/[0-1000]"}'`
    

    @sipa does this make sense?

  5. Sjors commented at 5:01 pm on November 20, 2018: member
    The importmulti approach now has a PR #14491.
  6. Sjors commented at 11:14 am on December 12, 2018: member

    In addition to #14491 you need #14075 to make direct importing of xpubs useful.

    Out of scope, but note that the current importmulti descriptor approach only works with xpubs, not for private keys, due to how the keypool works.

  7. prusnak commented at 5:17 pm on December 18, 2019: contributor
    @Sjors can you please update us on how to use importmulti command to create a watch-only wallet from xpub? One example per BIP44 (legacy non-segwit), BIP49 (p2sh segwit) and BIP84 (native segwit) standard accounts will be much appreciated.
  8. Sjors commented at 5:01 pm on December 21, 2019: member
    @prusnak try the (undocumented) getdescriptors HWI command on a Trezor to get all three :-) https://github.com/bitcoin-core/HWI/pull/137
  9. prusnak commented at 5:17 pm on December 21, 2019: contributor
    @Sjors Thanks!
  10. Sjors commented at 6:21 pm on December 21, 2019: member
    Also see the getkeys command for the other options you’ll need with importmulti: set watchonly and keypool to true, and use internal for the change address descriptor.
  11. Sjors commented at 11:40 am on June 25, 2021: member
    Descriptor wallets (and HWI integration) now allow all this cool stuff, suggest closing.
  12. prusnak commented at 11:46 am on June 25, 2021: contributor
    +1 for closing in favor of using descriptors
  13. jarolrod commented at 2:33 pm on August 25, 2021: member
    reiterating the statements above, importdescriptors and hwi integration would have solved this in my opinion.
  14. achow101 closed this on Oct 26, 2022

  15. bitcoin locked this on Oct 26, 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-11-17 12:12 UTC

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