Simple and intuitive way of watching/monitoring xpub keys? #21546

issue typoworx-de opened this issue on March 29, 2021
  1. typoworx-de commented at 2:08 PM on March 29, 2021: none

    Is your feature request related to a problem? Please describe. Trying to keep track of xpub addresses using core rpc and did not figure out how to do so.

    Describe the solution you'd like Any clear way like importaddress or importmulti to keep track of xpub addresses?

    Is there any way to "monitor" all addresses of xpub-key without having to resolve every path/address adding them each by each manually?

  2. typoworx-de added the label Feature on Mar 29, 2021
  3. sipa commented at 4:30 PM on March 29, 2021: member

    You can import xpub-based descriptors using importmulti (legacy wallets) or importdescriptor (descriptor wallets).

  4. typoworx-de commented at 10:28 AM on March 30, 2021: none

    Ok I think I accidentally found a good example for usage in #17797

  5. typoworx-de closed this on Mar 30, 2021

  6. typoworx-de commented at 10:39 AM on March 30, 2021: none

    @sipa may be you could give me a hint to the code given in #17797

    I run this RPC $ bitcoin-cli -rpcwallet=wallet-my-test-wallet.dat importmulti '[{"desc": "sh(wpkh(xpub6EcgD73U5aQe8F9k1VQmz3bDdnMmgNAouVixdsKVC9YTJb1BNPPq9jSCuDArzxzj2JAWcGyL9sJofgLQHAYovQqCibh3ovuWVtwiagp1x7d/*))#9fdjk2ls", "range": [0, 999999], "timestamp": "now", "watchonly": true}]' '{"rescan": false}'
    

    The notation is clear so far. But what exactly is the '#9fdjk2ls' given after: "sh(wpkh({myXpubKey}/*))#9fdjk2ls"

    The "/*" I assume is some kind of wildcard for the xpub-path? and the string afterwards?

  7. typoworx-de commented at 10:44 AM on March 30, 2021: none

    Just found this document giving a good overview (just for notice to others landing here): https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md

    There are a lot of sub-types mentioned. Is there a "save way" to importmulti without knowing exact sub-type like "sh(multi(...))" or "wpkh()" and so on?

    But still not knowing what the above mentioned string is good for.

  8. typoworx-de commented at 11:31 AM on March 30, 2021: none

    Ok just in case others are landing here searching for a solution: use rpc 'getdescriptorinfo' 'wpkh({yourXpubKey}/*)' and then use the result['descriptor'] for importmulti which then includes an appended XPub-Checksum (the strange string I mentioned above).

  9. i5hi commented at 8:18 PM on April 18, 2021: none

    the type you specify determines the spending conditions. the same xpub can be used to define a spending condition where the xpub is involved in multi sig so you would usewsh(multi(3,xpub,...), or maybe you want a sh address type so you use sh(wpkh(xpub)). if you just want to monitor a single public key for bech32 hdwallet, you would chose wpkh

    wpkh([fingerprint/hardened/path]xpub/0/*)#checksum"
    

    the fingerprint is of the root seed, and the hardened path (purpose/coin/account) that the xpub was made from. eg 84h/0h/0h - for bech32 mainnet addresses at account 0. The xpub has to be followed by the path where new addresses will be derived. The 0 position specifies deposit. You would use 1 for change. If you want to create psbts then you have to also import the change descriptor. the * is the index where new addresses are generated.

    If i am not mistaken this is the standard, but some wallets could just start deriving at xpub/* rather than xpub/0/* for deposits, so you have to make sure you are following the same path as the wallet you are importing from.

    You cant import all addresses and usually should avoid finding yourself in a situation where that is required. You have to set a range, and its usually not the best idea to use such a big range like 0-999999. It would be very memory intensive. If you are for example, recovering an hd wallet, your old wallet has very likely not imported addresses beyond the range of 1000. So you have to make sure you get the correct path your wallet was deriving from; then use that in the descriptor and import small ranges at a time. Then use rescanblockchain to sync.

  10. i5hi commented at 8:23 PM on April 18, 2021: none
  11. DrahtBot locked this on Aug 18, 2022
Labels

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: 2026-05-02 12:14 UTC

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