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:
Vpub5fRxfoprsHS9Vnhq1grZcJrWSRmSeBZbLCbnTJcvSDXr3xoBurx8MUt8UmHCsTVPXqk1rNpgt3X3KAvcJzCZvwn9yQymrWhwMJpEYysLqQV
becomes
tpubD8a2g9FwJxvC3c7YBvwvQL35Ph7jJTN4PnarTPCJAND6HGXSizk4ew1JxWKgqLXZuZSZ6KXZTFfgem2ar1itGNUywE1XJTY9azG4WBr25hn
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)
#!/bin/sh
wallet=$1
pub1=$2
pub2=$3
echo "Making wallet '${wallet}' from ${pub1} ${pub2}"
rawdescriptor="wsh(sortedmulti(2,${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