Clarify BTC wallet export format
Currently, the output of export-bitcoin-wallet looks something like this:
{"descriptor":"wpkh(xprv9s21gel82lxs8nvu49v2839189932ddkjdf2j6Ymmk/84'/0'/0'/0/*)","blockheight":31337,"label":"asb-bitcoin"}
As it stands this cannot be imported into Electrum directly.
I tried converting it to a zprv using https://github.com/AbdussamadA/electrum-xprv however that didn't work either.
The documentation for export-bitcoin-wallet should explain how to convert the wallet descriptor into a format that works with standard wallets (like Electrum). Alternately, there should be an option to export the wallet in a compatible format.
Have you tried this API
https://developer.bitcoin.org/reference/rpc/importdescriptors.html
eg.
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}]
What error message do you get?
After adding a trailing ' (omitted in your example) and the -rpcuser and -rpcpassword entries, I get a Bash syntax error : Syntax error at unexpected symbol: )
This is probably because the descriptor emitted by asb contains single quotes:
{"descriptor":"wpkh(xprv9s21gel82lxs8nvu49v2839189932ddkjdf2j6Ymmk/84'/0'/0'/0/*)","blockheight":31337,"label":"asb-bitcoin"}
It's not actually possible to escape single quotes within a single quoted string: https://stackoverflow.com/questions/1250079/how-to-escape-single-quotes-within-single-quoted-strings
Therefore, I'm still at a loss on how to import this descriptor.
More generally, using the importdescriptors API is really terrible, absolutely awful, downright dirty UX. It would be dramatically nicer to have a way that does not require the user to
- look up the command syntax in developer docs, and
- edit the example JSON block
The bare minimum ought to be documenting that the given format only works for a small set of wallets since we are using the FullyNoded export format produced by bdk.
If we want to support bitcoin-cli then we should (optionally?) convert the current export format to something that can be fed directly to importdescriptors.
I personally use Electrum for everything. Electrum can theoretically handle xprv using the command line. However I haven't worked out how to feed it the correct derivation path:
$ electrum --offline convert_xkey "xprv9s21Zrgelkihsage983z98w2ghlknsvh23iubkjnbyo92mk/84'/0'/0'/0/*" p2wpkh
xkey should be a master public/private key
Sparrow wallet properly handles the private key. I switched to that as I spent hours with Electrum trying to input it same as you. Sparrow has many other added features worth using too.
I installed Sparrow wallet. It does not directly handle the descriptor. Importing the private key, I haven't managed to get the derivation path right... the resulting imported wallet has no transaction.
Can you explain the exact process you used to import the private key into Sparrow, and the derivation path you used?
Using bdk-cli (see here) I also am unable to import the wallet descriptor:
$ sudo -u asb ./asb --config /etc/asb/config.toml export-bitcoin-wallet
2023-01-12 10:26:44 INFO Initialized tracing level=debug
2023-01-12 10:26:44 INFO Reading config file path=/etc/asb/config.toml
2023-01-12 10:26:44 DEBUG Using existing sqlite database.
2023-01-12 10:26:44 DEBUG Reading in seed from /etc/asb/seed.pem
2023-01-12 10:26:44 DEBUG Opening Bitcoin wallet
{"descriptor":"wpkh(xprv9sfoobar/84'/0'/0'/0/*)","blockheight":750145,"label":"asb-bitcoin"}
$ bdk-cli wallet -w atomic --server localhost --descriptor "wpkh(xprv9sfoobar/84'/0'/0'/0/*)" sync
[2023-01-12T10:25:10Z ERROR bdk_cli] Descriptor(Key(InvalidNetwork))
$ bdk-cli wallet -w atomic --descriptor "wpkh(xprv9sfoobar/84'/0'/0'/0/*)" sync
[2023-01-12T10:25:48Z ERROR bdk_cli] Descriptor(Key(InvalidNetwork))
$ bdk-cli wallet -w atomic --descriptor "wpkh(xprv9sfoobar/84\'/0\'/0\'/0/*)" sync
[2023-01-12T10:48:00Z ERROR bdk_cli] Descriptor(Miniscript(Unexpected("unexpected «Public keys must be 64/66/130 characters in size»")))
$ bdk-cli wallet -w atomic --descriptor 'wpkh(xprv9sfoobar/84'\''/0'\''/0'\''/0/*)' sync
[2023-01-12T10:54:52Z ERROR bdk_cli] Descriptor(Key(InvalidNetwork))
bdk-cli is probably the "right" way to import these descriptors, since they're generated by bdk.
The BDK export format is FullyNodedExport.
First use swap or asb with the export-bitcoin-wallet subcommand.
Output example:
{"descriptor":"wpkh(tprv8Zgredacted.../84'/1'/0'/0/*)","blockheight":2415616,"label":"asb-testnet"}
Sparrow wallet import works as follows:
- File -> New wallet -> Give it a name
- Select "New or Imported Software Wallet"
- Click "Enter Private Key" for "Master Private Key (BIP32)"
- Enter the
xprv...ortprv...part of the descriptor (example above istprv8Zgredacted...:

- Click "Import"
- Leave the derivation path as
m/84'/1'/0'and click "Import Keystore" button - Click "Apply" and then supply password

- Click Transactions tab
- ???
- Profit!

Using the derivation path you specified (m/84'/1'/0') I see no transactions. Using the default derivation path shown in Sparrow (m/84'/0'/0') I see transactions.
Made this correction to your text and added it to the asb documentation, see #1280
That’s interesting, I think it’s actually a specific difference between Mainnet and Testnet.
https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types