Lost funds in generated child address (BIP32 - HD Wallet) not recognized by Bitcoin Core Wallet?

I am using cryptocoin_payable to accept bitcoin payments by derivating adresses 1 address = 1 transaction.

I received a BTC payment https://bitcoinexplorer.org/address/1F3PZ1Qjtpmdcg3QGhK5szsPzY9nPLJeNq

But on my wallet the funds didnt show up :

Panic !


I realized the derived address was not properly recognize because I didn't setup the  node_path

CryptocoinPayable.configure do |config|
  
  config.configure_btc do |btc_config|
    # btc_config.confirmations = 3
    # btc_config.node_path = ''

    btc_config.master_public_key = 'tpub...'
  end

end

which is used here

      def create_address(id)
        raise MissingMasterPublicKey, 'master_public_key is required' unless coin_config.master_public_key

        master = MoneyTree::Node.from_bip32(coin_config.master_public_key)
        master.node_for_path(coin_config.node_path + id.to_s)
      end

So when an address is derived it uses m/44/0/0/{coin_payment_id}

Also use `getaddressinfo` to verify the adress generated

Then I reached out bitcoin stack exchange :

Lost funds? Generated child address (HD Wallet BIP32) without Node path
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 recogn...

Solution

Recover the funds

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

I put my master private key xprv... in BIP Root Key then check if the BIP32 Extended Public Key matches the master public key I setup in cryptocoin_payable

Then I could find the 284 which was my  node path (coin payment.id) and the public address matches.. !

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 a while...

And voila !

Fix cryptocoin_payable for future payments

Set config.node_path = '0/ but always test your derived address with getaddressinfo my_derived_address

 getaddressinfo 1Fq1BbugkWzQyJBoFEJrbcTmsxe44Mhhfz    
    
    {
      "address": "1Fq1BbugkWzQyJBoFEJrbcTmsxe44Mhhfz",
      "scriptPubKey": "76a914a2a5e135a645025d0b87f710ec7d7122fd9c8a3488ac",
      "ismine": true,
      "solvable": true,
      "desc": "pkh([3db2xxx/44'/0'/0'/0/12]------)#psf0gapz",
      "parent_desc": "pkh([3dbxxx/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": [
      ]
    }
ismine should be true