1

I have an app that generates 1 public address = 1 transaction using HD Wallet.

However I forgot to put the node path /0 while generating the child address and my Bitcoin Core wallet does not recognize the fund that have been sent.

Is there any way I can recover the funds through scriptPubKey or something ?

or are the funds lost forever ?

Address that received the fund : https://bitcoinexplorer.org/address/1F3PZ1Qjtpmdcg3QGhK5szsPzY9nPLJeNq

Address generated without node path
    getaddressinfo 1F3PZ1Qjtpmdcg3QGhK5szsPzY9nPLJeNq
    
    {
      "address": "1F3PZ1Qjtpmdcg3QGhK5szsPzY9nPLJeNq",
      "scriptPubKey": "76a9149a056b1113775ba165d929461f305d493349a55b88ac",
      "ismine": false,
      "solvable": false,
      "iswatchonly": false,
      "isscript": false,
      "iswitness": false,
      "ischange": false,
      "labels": [
      ]
    }


Address generated with node path

    
    getaddressinfo 1Fq1BbugkWzQyJBoFEJrbcTmsxe44Mhhfz    
    
    {
      "address": "1Fq1BbugkWzQyJBoFEJrbcTmsxe44Mhhfz",
      "scriptPubKey": "76a914a2a5e135a645025d0b87f710ec7d7122fd9c8a3488ac",
      "ismine": true,
      "solvable": true,
      "desc": "pkh([3db26443/44'/0'/0'/0/12]------)#psf0gapz",
      "parent_desc": "pkh([3db26443/44'/0'/0']xpub-----/0/*)#7uthurwc",
      "iswatchonly": false,
      "isscript": false,
      "iswitness": false,
      "pubkey": "------",
      "iscompressed": true,
      "ischange": true,
      "timestamp": 1703084241,
      "hdkeypath": "m/44'/0'/0'/0/12",
      "hdseedid": "0000000000000000000000000000000000000000",
      "hdmasterfingerprint": "3db26443",
      "labels": [
      ]
    }

2 Answers 2

2

If you're only missing part of the derivation path, then the key can still be generated from the master private key. The issue is just that Bitcoin Core doesn't search all derivation paths (that'd be impossible), just those that are explicitly given to it.

So you can take the master private key, construct a descriptor with that key that generates the address that you want, and import that descriptor to your wallet. It should then recognize your funds on a rescan and be able to spend them.

3
  • Thank you Ava! I am trying with Bitcoin Core console importmulti '[{"desc": "pkh([my_xprv/44'"'"'/0'"'"'/0'"'"'/0/12]my_xpub)","timestamp": "now","range": [0,1000],"watchonly": true}]' '{"rescan": true}' But I have "Only legacy wallets are supported by this command" Is my descriptor correct or am I missing something ?
    – stifou
    Commented Mar 11 at 16:16
  • tried to update Bitcoin Core from 25.1 to 26.0.0 - without luck
    – stifou
    Commented Mar 11 at 16:31
  • @stifou importmulti is not available for descriptor wallets, you should use importdescriptors. However, your descriptor is probably constructed incorrectly. You can use listdescriptors true to get the descriptor with the master private key, and then change the derivation path in that to be what you need, and import that.
    – Ava Chow
    Commented Mar 11 at 17:54
1

I managed to recover the funds thanks to Ava Chow's help!

Blog blog with screenshots here

I couldn't properly find the right derivation path so I used https://iancoleman.io/bip39/

  1. I put my master private key in BIP Root Key
  2. check if the BIP32 Extended Public Key matches the master public key I've setup in my app (used cryptocoin_payable)
  3. found the index 284 which was my node path and the public address matches the one which has the funds 1F3PZ1Qjtpmdcg3QGhK5szsPzY9nPLJeNq !

With this I constructed the descriptor :

pkh(my_private_key)

Then find the checksum

getdescriptorinfo "pkh(my_private_key)"
{
  "descriptor": "pkh(my_private_key)#something",
  "checksum": "my_checksum",
  "isrange": false,
  "issolvable": true,
  "hasprivatekeys": true
}

Then import the descriptor :

importdescriptors '[{ "desc": "pkh(my_private_key)#my_checkum", "timestamp":1455191478, "internal": true }]'

Wait for scanning a while...

And voila !

At some point I was expecting this to work (following Ava's help) importdescriptors '[{ "desc": "pkh(master_private_key/44'"'"'/0'"'"'/0'"'"'/0/284)#nnzeerhk", "timestamp":1455191478, "internal": true }]'[{ "success": true }] but didn't... maybe derivation path should be m/0'"'"'/0'"'"'/284 instead.

1
  • Awesome, thank you for letting us know and writing up your own solution!
    – Murch
    Commented Mar 14 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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