0

DuckDuckGo turns up nothing of interest. How to import multiple priv keys in Electrum from a file using Electrum console or shell script, for all derivable valid BTC addresses? (1,3,bc1)

Eventually I would like to pipe the output of one script directly into an import script.

The file is in format:

BTC Pattern: <pattern>  
BTC Address: <bitcoin address beginning with one>  
BTC Privkey: <bitcoin address beginning with five>
...
2
  • Does this help? Apr 12, 2019 at 23:34
  • @KappaDev Thank you, I can filter my input file and paste a bunch. Updated question for derivable addresses.
    – user93729
    Apr 12, 2019 at 23:40

1 Answer 1

0

First of all get rid of all that junk. One priv key per line is all you need. So use grep privkey filename|cut -d":" -f2 > clean-file.txt. Then call this python script with that file as an argument:

import sys
from electrum import bitcoin
f = open(sys.argv[1], "r")
for privkey in f:
    privkey=privkey.strip()
    orig_format,secret,compressed=bitcoin.deserialize_privkey( privkey)
    formats = [ bitcoin.serialize_privkey( secret, False, "p2pkh"), bitcoin.serialize_privkey( secret, True, "p2pkh"), bitcoin.serialize_privkey( secret, True, "p2wpkh"), bitcoin.serialize_privkey( secret, True, "p2wpkh-p2sh") ]
    for thing in formats:
        print(thing)

It'll output all the private keys in the various formats.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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