Bitcoin

Import private key – How do I use a descriptor to put an ancient private key into a newly created wallet.dat file?

I’m running bitcoin core 26.0 on Debian 12. I would like to place my ancient private key in the newly created wallet.dat file. Let’s do a test run first.

$ bitcoin-cli createwallet test
$ bitcoin-cli loadwallet /home/user/.bitcoin/wallets/test/

This wallet.dat exists only for testing purposes and will be deleted soon. Even before it was deleted, Strictly for testing purposes onlyI would like to put my public private key at https://en.bitcoin.it/wiki/Private_key.

Private Key=5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF
Corresponding address = 1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj

…to this For testing only This is the wallet.dat file. Of course, this particular private key is only used as a placeholder here. No one in their right mind would want this private key anywhere near the actual wallet.dat file.

$ bitcoin-cli getdescriptorinfo 'combo(5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF)'

  "descriptor": "combo(04588d202afcc1ee4ab5254c7847ec25b9a135bbda0f2bc69ee1a714749fd77dc9f88ff2a00d7e752d44cbe16e1ebcf0890b76ec7c78886109dee76ccfc8445424)#nf3atn7u",
  "checksum": "qlt7uqzu",
  "isrange": false,
  "issolvable": true,
  "hasprivatekeys": true


$ bitcoin-cli importdescriptors '("desc":"combo(5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF)#qlt7uqzu","timestamp":"now")'
(
  
    "success": true
  
)

…now that the private key should be in wallet.dat, let’s do a simple test:

$ bitcoin-cli getaddressinfo 1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj

  "address": "1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj",
  "scriptPubKey": "76a9147ac00f979ff0df2fdcb65761dc8f9ef8b37142db88ac",
  "ismine": true,
  "solvable": true,
  "desc": "pkh((7ac00f97)04588d202afcc1ee4ab5254c7847ec25b9a135bbda0f2bc69ee1a714749fd77dc9f88ff2a00d7e752d44cbe16e1ebcf0890b76ec7c78886109dee76ccfc8445424)#yyv2g3h5",
  "parent_desc": "combo(04588d202afcc1ee4ab5254c7847ec25b9a135bbda0f2bc69ee1a714749fd77dc9f88ff2a00d7e752d44cbe16e1ebcf0890b76ec7c78886109dee76ccfc8445424)#nf3atn7u",
  "iswatchonly": false,
  "isscript": false,
  "iswitness": false,
  "pubkey": "04588d202afcc1ee4ab5254c7847ec25b9a135bbda0f2bc69ee1a714749fd77dc9f88ff2a00d7e752d44cbe16e1ebcf0890b76ec7c78886109dee76ccfc8445424",
  "iscompressed": false,
  "ischange": false,
  "timestamp": 1231006505,
  "hdkeypath": "m",
  "hdseedid": "0000000000000000000000000000000000000000",
  "hdmasterfingerprint": "7ac00f97",
  "labels": (
    ""
  )

…So I think it’s good. Next is to rescan the blockchain and wait a few hours. The BTC controlled by that private key (which in this case will obviously be equal to 0!) should then be available for use in the Bitcoin Core client after rescanning. Perform.

Did I miss something? If I use this method to put the private key that controls the non-zero btc value into a live wallet.dat file, will I be able to use that wallet.dat file to use btc in Bitcoin Core 26.0?

Related Articles

Back to top button