Wednesday, December 25, 2024

non-public key import – How do I take advantage of descriptors to place an historical priv-key right into a newly created pockets.dat file?

Working bitcoin core 26.0 on debian 12. I wish to put an historical priv-key right into a newly created pockets.dat file. First, I will do a take a look at run:

$ bitcoin-cli createwallet take a look at
$ bitcoin-cli loadwallet /dwelling/consumer/.bitcoin/wallets/take a look at/

This pockets.dat exists just for testing functions and can be deleted shortly. Earlier than it is deleted although, and strictly for testing solely, I wish to put the priv-key revealed on https://en.bitcoin.it/wiki/Private_key:

priv-key= 5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF
corresponding handle= 1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj

… into this test-only pockets.dat file. This explicit priv-key is after all right here solely as a place-holder; no person of their proper thoughts would need this priv-key wherever close to a reside pockets.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
  }
]

… in order that priv-key ought to be within the pockets.dat now, so I do a fast take a look at:

$ bitcoin-cli getaddressinfo 1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj
{
  "handle": "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 that appears good. Subsequent factor is to rescan the blockchain, wait just a few hours, and the btc managed by that priv-key (possible an quantity equal to zero on this case, clearly!) ought to be out there to be spent by the bitcoin core shopper after the rescan is finished.

Did I miss something out? If I take advantage of this technique to place a priv-key that controls a non-zero btc worth right into a reside pockets.dat file, will I be capable to use that pockets.dat file in bitcoin core 26.0 to spend the btc?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles