0

Using only command line (no GUI), how can I create watch only wallet based on descriptor and get first unused address?

This is the descriptor:

"wpkh([00000000/84h/0h/0h]xpub6DP....xyz/0/*)#checksum"

this is the bitcoin-cli command to list addresses based on this descriptor:

./bitcoin-cli deriveaddresses "wpkh([00000000/84h/0h/0h]xpub6DP....xyz/0/*)#checksum" "[0,2]"

How to create actuall watch only wallet so that I can get automatically first unused address?

2

First create a descriptor wallet with createwallet:

bitcoin-cli -named createwallet wallet_name=mywallet descriptors=true

This will make a descriptor wallet named mywallet.

Then import a descriptor into that wallet using `importdescriptors:

bitcoin-cli -rpcwallet=mywallet importdescriptors '[{"desc": "wpkh([00000000/84h/0h/0h]xpub6DP....xyz/0/*)#checksum", "range": [0, 1000], "timestamp": "now", "internal": false, "watchonly": true, "active": true}]

This will import the descriptor with an initial keypool of 1000. Any new bech32 addresses you request (with getnewaddress or from the GUI) will come from this descriptor.

3
  • The second command ends with error: "Cannot import descriptor without private keys to a wallet with private keys enabled".
    – urza.cc
    Jan 19 at 12:34
  • Ah, the first command must contain: ddisable_private_keys=true
    – urza.cc
    Jan 19 at 12:37
  • ./bitcoin-cli -named createwallet wallet_name=mywallet descriptors=true disable_private_keys=true
    – urza.cc
    Jan 19 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.