Skip to content

Instantly share code, notes, and snippets.

@notmandatory
Last active April 15, 2024 18:51
Show Gist options
  • Save notmandatory/7846a6023627ea8c0a4b646f643ec73f to your computer and use it in GitHub Desktop.
Save notmandatory/7846a6023627ea8c0a4b646f643ec73f to your computer and use it in GitHub Desktop.
How to import bdk descriptor into core wallet
echo create temp diretory to store bitcoind data
mkdir -p /tmp/regtest1/bitcoind

echo start bitcoind in regtest mode
bitcoind -datadir=/tmp/regtest1/bitcoind -regtest -server -fallbackfee=0.0002 -rpcallowip=0.0.0.0/0 -rpcbind=0.0.0.0 -blockfilterindex=1 -peerblockfilters=1 -daemon

echo create blank descriptor wallet
bitcoin-cli -datadir=/tmp/regtest1/bitcoind -regtest -named createwallet wallet_name="regtest1" blank=true disable_private_keys=true
{
  "name": "regtest1"
}

echo bdk generated descriptor, note how it has ' for hardended derivations
echo $EXT
wpkh([34ba6521/45'/1'/11'/2]tpubDF6EsVJHJwMpVRGJfm9WZoEVVBWw771yswALzq3f7TFU2Xhzz5Ea65ThCGboB45PDiCn7yCctLETsPVJUUgvg8rCeHwZUW5FRjaQhQWZndn/*)#j4l6mj4u

echo import descritpor to core wallet
bitcoin-cli -datadir=/tmp/regtest1/bitcoind -regtest importdescriptors "[{ \"desc\": \"$EXT\", \"timestamp\": \"now\", \"active\": true}]"
[
  {
    "success": true,
    "warnings": [
      "Range not given, using default keypool range"
    ]
  }
]

echo verify we can generate an address from our imported descriptor
bitcoin-cli -datadir=/tmp/regtest1/bitcoind -regtest getnewaddress  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment