<p>There is no cli command that can do this. You can do it via 3 methods:</p>

<ul>
<li><p>In the Electrum GUI go to the view menu > show console and switch to the console tab. On the console tab type this:</p>

<pre><code>bitcoin.address_from_private_key("&lt;privkeyhere&gt;")
</code></pre>

<p>Then once you have the address clear the console history or your private key will be saved to disk:</p>

<pre><code>window.console.history = []
</code></pre></li>
<li><p>Another option is to simply import your private key into a new electrum wallet. File > new/restore, enter a unique filename and click next, choose to import addresses or private keys and then follow on-screen instructions for the rest.</p></li>
<li><p>OP has clarified that he wants to do this via bash so a third option is to write a custom python script:</p>

<pre><code>#!/usr/bin/python3
from electrum import bitcoin
import sys
print(bitcoin.address_from_private_key(sys.argv[1]))
</code></pre>

<p>Put the above in a file and <code>chmod +x</code> it. Then run it with the private key as an argument. Obviously anyone else who runs <code>ps</code> on the same system at the same time will see your private key so this approach is not recommended.</p></li>
</ul>

CC BY-SA 4.0
2019-02-03T20:09:27.110Z
I need to do it via command line because I'm using the electrum command in a bash script.
Patoshi パトシ
CC BY-SA 4.0
2019-02-03T21:22:27.637Z
@Patoshiパトシ you could write a custom python script for this but if you pass the priv key to it via bash your priv key will be exposed on the command line. anyone on the same system that runs `ps` at the same time as the command will be able to see your priv key.
Abdussamad
CC BY-SA 4.0
2019-02-03T22:09:05.637Z
no one is going to be on my system except for me.
Patoshi パトシ
CC BY-SA 4.0
2019-02-03T20:02:18.550Z
2019-02-03T21:29:10.347Z
2019-02-03T21:29:10.347Z
Abdussamad
<p>I have a bitcoin private key and I want to get the bitcoin address from it. What is the command in the command line for electrum to extract this address?</p>

<electrum><command-line-options>
What is the command line command in electrum to get my public bitcoin address from my private key?
Patoshi パトシ
# What is the command line command in electrum to get my public bitcoin address from my private key?

(Asked by: username_0 on 2019-02-02)

I have a bitcoin private key and I want to get the bitcoin address from it. What is the command in the command line for electrum to extract this address?

**Tags:** electrum, command-line-options


---

## 1 answers

### Answer by username_1 on 2019-02-03. Score: 1

There is no cli command that can do this. You can do it via 3 methods:

* In the Electrum GUI go to the view menu > show console and switch to the console tab. On the console tab type this:

  ```
  bitcoin.address_from_private_key("<privkeyhere>")

  ```

  Then once you have the address clear the console history or your private key will be saved to disk:

  ```
  window.console.history = []

  ```
* Another option is to simply import your private key into a new electrum wallet. File > new/restore, enter a unique filename and click next, choose to import addresses or private keys and then follow on-screen instructions for the rest.
* OP has clarified that he wants to do this via bash so a third option is to write a custom python script:

  ```
  #!/usr/bin/python3
  from electrum import bitcoin
  import sys
  print(bitcoin.address_from_private_key(sys.argv[1]))

  ```

  Put the above in a file and `chmod +x` it. Then run it with the private key as an argument. Obviously anyone else who runs `ps` on the same system at the same time will see your private key so this approach is not recommended.

> **Comments:**
> **username_0**: I need to do it via command line because I'm using the electrum command in a bash script.  
> **username_1**: @username_0 you could write a custom python script for this but if you pass the priv key to it via bash your priv key will be exposed on the command line. anyone on the same system that runs `ps` at the same time as the command will be able to see your priv key.  
> **username_0**: no one is going to be on my system except for me.  

---

