1

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?

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.

  • I need to do it via command line because I'm using the electrum command in a bash script. – Patoshi パトシ Feb 3 at 20:09
  • @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 Feb 3 at 21:22
  • no one is going to be on my system except for me. – Patoshi パトシ Feb 3 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.