2

Is there a python script that i could use to convert a list of private hex keys to there import format in bulk?

How would I go about this..

Could this be adjusted to take a .txt list of hex addresses and convert the to private import format, then print the results to a txt file?

In [1]: import base58
In [2]: hexstring= "00010966776006953D5567439E5E39F86A0D273BEED61967F6"
In [3]: unencoded_string = bytes.fromhex(hexstring)
In [4]: encoded_string= base58.b58encode(unencoded_string)
In [5]: print(encoded_string)
16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM
1
  • can this be adjusted to take a list of hex addresses and then convert them to private import format and print results to a txt file?
    – ryan
    Nov 28 '15 at 18:49
1

You should consider using this (or a similar) python library to import your keys, as straight conversion from hex to base58 can have a few gotchas:

https://github.com/vbuterin/pybitcointools

Check the examples in the README and you should be on your way to making your script.

0

You can use these little scripts in command line, so you don't have to program a single line (also run in Windows if you have Python), or easily modify them if you want:

https://github.com/circulosmeos/bitcoin-in-tiny-pieces

For your private key example:

$ ./bitcoin-wif-from-private-key.py 00010966776006953D5567439E5E39F86A0D273BEED61967F6

privkey = 8000010966776006953D5567439E5E39F86A0D273BEED61967F6

For uncompressed public key:
checksum =      02d037e84dee212e14b823a8c9ac01409f6c1504e558d86116a4302d4d68bbdf
key + checksum =        8000010966776006953D5567439E5E39F86A0D273BEED61967F6 02d037e8
bitcoin address =       Sea2qLkneYfbTv29SLY8QvhkAZDxwgDfMuWprqj4b

For compressed public key:
checksum =      021538258480bbb46a846ef24bb2927d24f7c90bf354d76d6da3bd52c47e633d
key + checksum =        8000010966776006953D5567439E5E39F86A0D273BEED61967F601 02153825
bitcoin address =       2xCpo6NCGUimM7o24EqEPic2qXBEDvL6tKGne3Avisv

If you modifiy the script setting this variable to False, only WIF addresses are printed:

VERBOSE = False

(Once you have programmed the desired output) you can make a batch file (.sh in linux, .bat in Windows) with a command line per private key (an editor like Sublime Text for example can edit and paste multiple lines at once, so it's easy) each appending to the a file, and the run this batch file:

./bitcoin-wif-from-private-key.py 1stkey >> mytextfile.txt
./bitcoin-wif-from-private-key.py 2ndkey >> mytextfile.txt
...

PS: there're two ways of produce the WIF from a private key (compressed and uncompressed): any of them both will do the job.

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.