<p>Yes, it is possible to create a Wallet Import Format (WIF) from a private key using the bitcoin-cli command. Here's an example of how you can do it:</p>
<ul>
<li>[step.1] Generate a new private key:</li>
</ul>
<pre class="lang-bash prettyprint-override"><code>bitcoin-cli -regtest getnewaddress
bitcoin-cli -regtest dumpprivkey &lt;address&gt;
</code></pre>
<ul>
<li>[step.2] Convert the private key to WIF format:</li>
</ul>
<pre class="lang-bash prettyprint-override"><code>$ bitcoin-cli -regtest dumpprivkey &lt;private_key&gt;
</code></pre>
<p>Replace &lt;private_key&gt; with the actual private key you generated in step 2.</p>
<p>The <code>dumpprivkey</code> command will output the corresponding WIF for the given private key. The WIF can be used for various purposes, such as importing the key into a wallet or performing other operations.</p>
<p>Using the <code>bitcoin-cli</code> command with the <code>-regtest</code> flag ensures that you are operating in the regression test mode, which is suitable for testing purposes.</p>
<p>By following these steps, you should be able to easily generate <code>regtest WIFs</code> for testing without relying on external programs or libraries.</p>

CC BY-SA 4.0
2023-06-11T14:50:26.797Z
@PieterWuille There was a typo in the text, I fixed it, what does it have to do with Ai?
Mmdrza
CC BY-SA 4.0
2023-06-07T17:52:25.267Z
2023-06-07T18:56:41.260Z
2023-06-07T18:56:41.260Z
Mmdrza
<h1>Questions</h1>
<ol>
<li><p>Is it possible for the <code>bitcoin-cli</code> command to extract WIFs from a ranged descriptor with a derivation path?</p>
</li>
<li><p>If a descriptor is ranged it <strong>must have</strong> a xpriv key?</p>
</li>
<li><p>If a descriptor has a xpriv it <strong>must have</strong> a derivation path?</p>
</li>
<li><p>If yes to 2,3 than the only other type would be a simple desc(wif) which would have neither a derivation path nor range?</p>
</li>
</ol>
<p>I understand this is probably a bad idea (defeats the purpose of descriptors), but for curiosity reasons I'm asking.</p>
<h1>Goal</h1>
<p>My goal is to learn more about descriptors/WIFs/etc for testing alongside with the bitcoin-cli.</p>

CC BY-SA 4.0
2023-06-07T16:41:09.953Z
As far as Bitcoin Core is concerned, WIFs *are* the way private keys are encoded. If you're talking about "from" private keys, you must have some other encoding in mind. I don't believe any other encodings are supported besides WIF (and xprvs).
Pieter Wuille
CC BY-SA 4.0
2023-06-07T23:42:39.820Z
I think my confusion is/was mainly around descriptors. You typically wouldn't be able to grab a single key or wif from a descriptor output (or at least you typically wouldn't want to do this because then you lose what makes a descriptor a descriptor)?. I was given a key for a tr descriptor which now seems unusual I guess?. I'm wondering how you would one start with descriptor and then give someone a wif to a tr output? (updated question)
Michael Tidwell
<bitcoin-cli><regtest><output-script-descriptors><wallet-import-format><private-key-format>
bitcoin-cli WIF from xpriv, descriptor outputs clarity
Michael Tidwell
# bitcoin-cli WIF from xpriv, descriptor outputs clarity

(Asked by: username_0 on 2023-06-07)

# Questions

1. Is it possible for the `bitcoin-cli` command to extract WIFs from a ranged descriptor with a derivation path?
2. If a descriptor is ranged it **must have** a xpriv key?
3. If a descriptor has a xpriv it **must have** a derivation path?
4. If yes to 2,3 than the only other type would be a simple desc(wif) which would have neither a derivation path nor range?

I understand this is probably a bad idea (defeats the purpose of descriptors), but for curiosity reasons I'm asking.

# Goal

My goal is to learn more about descriptors/WIFs/etc for testing alongside with the bitcoin-cli.

**Tags:** bitcoin-cli, regtest, output-script-descriptors, wallet-import-format, private-key-format

> **Comments:**
> **username_1**: As far as Bitcoin Core is concerned, WIFs *are* the way private keys are encoded. If you're talking about "from" private keys, you must have some other encoding in mind. I don't believe any other encodings are supported besides WIF (and xprvs).  
> **username_0**: I think my confusion is/was mainly around descriptors. You typically wouldn't be able to grab a single key or wif from a descriptor output (or at least you typically wouldn't want to do this because then you lose what makes a descriptor a descriptor)?. I was given a key for a tr descriptor which now seems unusual I guess?. I'm wondering how you would one start with descriptor and then give someone a wif to a tr output? (updated question)  

---

## 1 answers

### Answer by username_2 on 2023-06-07. Score: -3

Yes, it is possible to create a Wallet Import Format (WIF) from a private key using the bitcoin-cli command. Here's an example of how you can do it:

[step.1] Generate a new private key:

bitcoin-cli -regtest getnewaddress
bitcoin-cli -regtest dumpprivkey 


[step.2] Convert the private key to WIF format:

$ bitcoin-cli -regtest dumpprivkey 

Replace  with the actual private key you generated in step 2.
The dumpprivkey command will output the corresponding WIF for the given private key. The WIF can be used for various purposes, such as importing the key into a wallet or performing other operations.
Using the bitcoin-cli command with the -regtest flag ensures that you are operating in the regression test mode, which is suitable for testing purposes.
By following these steps, you should be able to easily generate regtest WIFs for testing without relying on external programs or libraries.

> **Comments:**
> **username_2**: @PieterWuille There was a typo in the text, I fixed it, what does it have to do with Ai?  

---

