<p>Yes, you will be able to spend the coins found through a rescan when importing a private key by the means of a descriptor in a Bitcoin Core descriptor wallet.</p>

CC BY-SA 4.0
2024-01-18T07:19:54.883Z
2024-01-18T07:19:54.883Z
Antoine Poinsot
<p>Running bitcoin core 26.0 on debian 12. I want to put an ancient priv-key into a newly created wallet.dat file. First, I'll do a test run:</p>
<pre><code>$ bitcoin-cli createwallet test
$ bitcoin-cli loadwallet /home/user/.bitcoin/wallets/test/
</code></pre>
<p>This wallet.dat exists only for testing purposes and will be deleted shortly. Before it's deleted though, and <em>strictly for testing only</em>, I want to put the priv-key revealed on <a href="https://en.bitcoin.it/wiki/Private_key" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Private_key</a>:</p>
<p>priv-key= 5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF  <br/>
corresponding address= 1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj</p>
<p>... into this <em>test-only</em> wallet.dat file. This particular priv-key is of course here only as a place-holder; nobody in their right mind would want this priv-key anywhere near a live wallet.dat file.</p>
<pre><code>$ bitcoin-cli getdescriptorinfo 'combo(5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF)'
{
  &quot;descriptor&quot;: &quot;combo(04588d202afcc1ee4ab5254c7847ec25b9a135bbda0f2bc69ee1a714749fd77dc9f88ff2a00d7e752d44cbe16e1ebcf0890b76ec7c78886109dee76ccfc8445424)#nf3atn7u&quot;,
  &quot;checksum&quot;: &quot;qlt7uqzu&quot;,
  &quot;isrange&quot;: false,
  &quot;issolvable&quot;: true,
  &quot;hasprivatekeys&quot;: true
}

$ bitcoin-cli importdescriptors '[{&quot;desc&quot;:&quot;combo(5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF)#qlt7uqzu&quot;,&quot;timestamp&quot;:&quot;now&quot;}]'
[
  {
    &quot;success&quot;: true
  }
]
</code></pre>
<p>... so that priv-key should be in the wallet.dat now, so I do a quick test:</p>
<pre><code>$ bitcoin-cli getaddressinfo 1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj
{
  &quot;address&quot;: &quot;1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj&quot;,
  &quot;scriptPubKey&quot;: &quot;76a9147ac00f979ff0df2fdcb65761dc8f9ef8b37142db88ac&quot;,
  &quot;ismine&quot;: true,
  &quot;solvable&quot;: true,
  &quot;desc&quot;: &quot;pkh([7ac00f97]04588d202afcc1ee4ab5254c7847ec25b9a135bbda0f2bc69ee1a714749fd77dc9f88ff2a00d7e752d44cbe16e1ebcf0890b76ec7c78886109dee76ccfc8445424)#yyv2g3h5&quot;,
  &quot;parent_desc&quot;: &quot;combo(04588d202afcc1ee4ab5254c7847ec25b9a135bbda0f2bc69ee1a714749fd77dc9f88ff2a00d7e752d44cbe16e1ebcf0890b76ec7c78886109dee76ccfc8445424)#nf3atn7u&quot;,
  &quot;iswatchonly&quot;: false,
  &quot;isscript&quot;: false,
  &quot;iswitness&quot;: false,
  &quot;pubkey&quot;: &quot;04588d202afcc1ee4ab5254c7847ec25b9a135bbda0f2bc69ee1a714749fd77dc9f88ff2a00d7e752d44cbe16e1ebcf0890b76ec7c78886109dee76ccfc8445424&quot;,
  &quot;iscompressed&quot;: false,
  &quot;ischange&quot;: false,
  &quot;timestamp&quot;: 1231006505,
  &quot;hdkeypath&quot;: &quot;m&quot;,
  &quot;hdseedid&quot;: &quot;0000000000000000000000000000000000000000&quot;,
  &quot;hdmasterfingerprint&quot;: &quot;7ac00f97&quot;,
  &quot;labels&quot;: [
    &quot;&quot;
  ]
}
</code></pre>
<p>... so that looks good. Next thing is to rescan the blockchain, wait a few hours, and the btc controlled by that priv-key (likely an amount equal to zero in this case, obviously!) should be available to be spent by the bitcoin core client after the rescan is done.</p>
<p>Did I miss anything out? If I use this method to put a priv-key that controls a non-zero btc value into a live wallet.dat file, will I be able to use that wallet.dat file in bitcoin core 26.0 to spend the btc?</p>

<wallet.dat><private-key-import><output-script-descriptors>
How do I use descriptors to put an ancient priv-key into a newly created wallet.dat file?
Lilacrail
# How do I use descriptors to put an ancient priv-key into a newly created wallet.dat file?

(Asked by: username_0 on 2024-01-17)

Running bitcoin core 26.0 on debian 12. I want to put an ancient priv-key into a newly created wallet.dat file. First, I'll do a test run:

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

```

This wallet.dat exists only for testing purposes and will be deleted shortly. Before it's deleted though, and *strictly for testing only*, I want to put the priv-key revealed on <https://en.bitcoin.it/wiki/Private_key>:

priv-key= 5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF   
corresponding address= 1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj

... into this *test-only* wallet.dat file. This particular priv-key is of course here only as a place-holder; nobody in their right mind would want this priv-key anywhere near a live 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
  }
]

```

... so that priv-key should be in the wallet.dat now, so I do a quick 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 that looks good. Next thing is to rescan the blockchain, wait a few hours, and the btc controlled by that priv-key (likely an amount equal to zero in this case, obviously!) should be available to be spent by the bitcoin core client after the rescan is done.

Did I miss anything out? If I use this method to put a priv-key that controls a non-zero btc value into a live wallet.dat file, will I be able to use that wallet.dat file in bitcoin core 26.0 to spend the btc?

**Tags:** wallet.dat, private-key-import, output-script-descriptors


---

## 1 answers

### Answer by username_1 on 2024-01-18. Score: 4

Yes, you will be able to spend the coins found through a rescan when importing a private key by the means of a descriptor in a Bitcoin Core descriptor wallet.


---

