I'm trying to import an HD multisig wallet created with Electrum into Bitcoin core v0.21.0.0.

I managed to do so with the fantastic cryptoadvance.specter server, but I also would like to import it using the standard bitcoin-cli commands.

This is what I managed to do so far, and it only works if I convert the pub keys Vpub Multi-signature P2WSH to tpub P2PKH, so for example:




then I can run this program and it seems to be working fine, unless it's not because the resulting addresses are very different. (the wallet created with Specter matches perfectly the one in Electrum, it finds the correct transactions as well)



echo "Making wallet '${wallet}' from ${pub1} ${pub2}"

descriptor=$(bitcoin-cli getdescriptorinfo $rawdescriptor | jq -r '.descriptor')
bitcoin-cli deriveaddresses  ${descriptor} "[0,0]"

bitcoin-cli createwallet $wallet true
bitcoin-cli -rpcwallet=$1  importmulti '[{"desc": "'$descriptor'", "internal": false, "range": [0, 1000], "timestamp": 1609459200, "keypool": true, "watchonly": true, "label": "lol"}]' '{ "rescan": true}'
# bitcoin-cli -rpcwallet=$1 rescanblockchain

I can't use the Vpub keys because bitcoin-cli (v0.21.0.0) throws this message:

key 'vpub5UXsYa6RJKsn5DYT52PanEWhidjBRpt11vx7Y3MP4ShSRnEH9TZrGN2Cg4KjK2GVJNg2ynpZzq8YC1Jr1m3cnTfV8wsNT7EwTaYMy4PCDAg' is not valid.

At this stage i’m only interested into a watch only wallet, so i don’t need to use private keys.

Also, I'm in testnet and I have testnet=1 on my bitcoin.conf

I've tried reading as much as I could but I think i hit a wall now and I don't know how to continue. Any help would be greatly appreciated

  • 1
    You're trying this with testnet funds, right? – Murch Feb 11 at 18:45
  • yes, i’ll edit my question – sathia Feb 11 at 18:45
  • Did you ever get this to work? I'm having the exact same issue on 0.21. barely any docs on the matter. – user116697 Mar 3 at 21:14
  • In fact I did! i'll answer my question, hold on – sathia Mar 3 at 21:15
  • Actually I just kind of succeeded too. I wonder if we have the same solution :) So I was using the root key signatures from seedpicker, where I got the Vpubs, but now I tried the master fingerprints from Specter PDF with SLIP132 and got the same addresses. What I still don't know is a. where I can independently get the correct signature without relying on Specter and b. why the addresses imported are completely out of order and c. why bitcoin-qt does not show past transactions (I'm on a pruned node, so that could be the reason...) – user116697 Mar 3 at 21:26

this is a script that works for me, it imports a 2of3 HD multisig wallet.

I have very basic knowledge of bash so you may want to double check it before running it, anyway, what finally worked for me was to understand that I had to wsh(sortedmulti(2,${pub1}/0/*,${pub2}/0/*,${pub3}/0/*))to derive the receive descriptor and wsh(sortedmulti(2,${pub1}/1/*,${pub2}/0/*,${pub3}/0/*))for receiver.

I also found this good converter here: https://jlopp.github.io/xpub-converter/




p1=$(echo $pub1 | cut -c1-10)
p2=$(echo $pub2 | cut -c1-10)
p3=$(echo $pub3 | cut -c1-10)

printf "\n\nWorking on '${wallet}' from ${p1}... ${p2}... ${p3} starting from ${rescanblockchain}\n\n"

# create wallet if needed
if [[ $(bitcoin-cli listwallets | jq '. | index("'$wallet'")' ) == "null" ]]; then
    echo "Making wallet '${wallet}' from ${pub1} ${pub2} ${pub3}"
    bitcoin-cli createwallet $wallet  true

# convert keys format from vpub to tpub https://jlopp.github.io/xpub-converter/
pub1=$(node converter.js ${pub1})
pub2=$(node converter.js ${pub2})
pub3=$(node converter.js ${pub3})

# get descriptor for receive addresses
receive_descriptor=$(bitcoin-cli getdescriptorinfo $raw_receive_descriptor | jq -r '.descriptor')

# get descriptor for change addresses
change_descriptor=$(bitcoin-cli getdescriptorinfo $raw_change_descriptor | jq -r '.descriptor')

# import receive addresses
bitcoin-cli -rpcwallet=$wallet importmulti  '[{"desc": "'$receive_descriptor'", "internal": false, "range": '${range}', "timestamp": "now", "keypool": true, "watchonly": true}]'  '{"rescan": false}' | jq .

# import change addresses
bitcoin-cli -rpcwallet=$wallet importmulti  '[{"desc": "'$change_descriptor'", "internal": true, "range": '${range}', "timestamp": "now", "keypool": true, "watchonly": true}]'  '{"rescan": false}' | jq .

# rescan blockchain
bitcoin-cli -rpcwallet=$wallet rescanblockchain "${rescanblockchain}" | jq .

# just print out few receive addresses
bitcoin-cli deriveaddresses  ${receive_descriptor} "${range}" | jq .

# print out balance
bitcoin-cli -rpcwallet=$wallet getbalance

So just to make this post more clear, this can be run directly on bitcoin-cli or in the bitcoin-qt console. Mostly I followed this guide. instead of Vpubs, I used Jameson Lopp's converter to convert the Vpubs into tpubs, and while there I get the matching fingerprints, so I have everything I need. Mind you, this is just to verify receive addresses independently from any other wallet (Electrum, Specter).

Sorry I can't upvote or do anything else, I am a first time user with 0 reputation :(

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.