Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Patrick349 on August 09, 2016, 10:01:56 AM



Title: Mass Private Key to Bitcoin Address Converter
Post by: Patrick349 on August 09, 2016, 10:01:56 AM
I search a Mass Private Key to Bitcoin Address Converter.


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: xcbtrader on August 09, 2016, 10:59:58 AM
Hey Guys,

I have a list of private keys and I want translate them to their Bitcoin Addresses. Is their any tool (with GUI) that can easily transform a textfile with private keys inside it to a list of their addresses?

I hope somebody can help me. :)

Best regards,

Patrick :)

easy in python

Code:
__author__ = 'xcbtrader'
# -*- coding: utf-8 -*-

from bitcoin import *

f = open('file with private.txt', "r")
privates = []
linia = f.readline()

while linia != "":
    linia = linia[0 :-1]
    privates.append (linia)
    linia = f.readline()

f.close()

for priv in privates:
    pub = privtopub(priv)
    addr = pubtoaddr(pub)
    wif = encode_privkey(priv, 'wif')
    print addr
    print wif



Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: fbueller on August 09, 2016, 12:07:11 PM
Find someone to google it for you!


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: chrisvl on August 09, 2016, 01:17:36 PM
Hey Guys,

I have a list of private keys and I want translate them to their Bitcoin Addresses. Is their any tool (with GUI) that can easily transform a textfile with private keys inside it to a list of their addresses?

I hope somebody can help me. :)

Best regards,

Patrick :)

easy in python

Code:
__author__ = 'xcbtrader'
# -*- coding: utf-8 -*-

from bitcoin import *

f = open('file with private.txt', "r")
privates = []
linia = f.readline()

while linia != "":
    linia = linia[0 :-1]
    privates.append (linia)
    linia = f.readline()

f.close()

for priv in privates:
    pub = privtopub(priv)
    addr = pubtoaddr(pub)
    wif = encode_privkey(priv, 'wif')
    print addr
    print wif


Sorry, I istalled python but I don't really know how to use it... could you just say me how to use your code? :)
open your favorite text editor / notepad paste in the code and save it as .py e.g converter.py


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: xcbtrader on August 09, 2016, 02:26:09 PM
Hey Guys,

I have a list of private keys and I want translate them to their Bitcoin Addresses. Is their any tool (with GUI) that can easily transform a textfile with private keys inside it to a list of their addresses?

I hope somebody can help me. :)

Best regards,

Patrick :)

easy in python

Code:
__author__ = 'xcbtrader'
# -*- coding: utf-8 -*-

from bitcoin import *

f = open('file with private.txt', "r")
privates = []
linia = f.readline()

while linia != "":
    linia = linia[0 :-1]
    privates.append (linia)
    linia = f.readline()

f.close()

for priv in privates:
    pub = privtopub(priv)
    addr = pubtoaddr(pub)
    wif = encode_privkey(priv, 'wif')
    print addr
    print wif


Sorry, I istalled python but I don't really know how to use it... could you just say me how to use your code? :)
open your favorite text editor / notepad paste in the code and save it as .py e.g converter.py

Only you need a text editor. Copy this code, and save to address.py (or other name)
You need the bitcoin library for run the program.
If you have pip installed  open comand window and type:

pip install bitcoin

Please, this library and program works fine in python 2.7, but not in python 3.4

The link of the library is:

https://github.com/vbuterin/pybitcointools (https://github.com/vbuterin/pybitcointools)



Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: hhanh00 on August 10, 2016, 01:38:19 PM
Somewhat shorter

Code:
from bitcoin import *

with open("privkeys.txt") as f:
for line in f:
print(pubtoaddr(privtopub(line.strip())))


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: gsciservices on March 28, 2021, 08:12:21 AM
Somewhat shorter

Code:
from bitcoin import *

with open("privkeys.txt") as f:
for line in f:
print(pubtoaddr(privtopub(line.strip())))





Hi,
Any possibilities to making addrtopub as above:

from bitcoin import *

with open("addr.txt") as f:
   for line in f:
      print(addrtopub(addrtopub(line.strip())))


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: plexasm on April 03, 2021, 10:34:28 PM
Electrum supports this, just use Electrum


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: pooya87 on April 04, 2021, 02:37:44 AM
Electrum supports this, just use Electrum
Electrum, as a wallet, has the option to import private keys and will add those keys with their corresponding addresses to its wallet file. The file that is a plain JSON and slows down the application significantly when the size of this wallet file grows big.


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: gsciservices on April 04, 2021, 08:46:08 PM
Electrum supports this, just use Electrum


Already tried it Electrum; output is not public key. Only tx hash avaiable....
I have addr to pubkey python script:
python2.2.18

import time
import requests

addresses = open('addr.txt', 'r').read().split('\n')

for address in addresses:
    if address == '':
        continue

    response = requests.get('https://blockchain.info/q/pubkeyaddr/' + address)
    if response.status_code == 200:
        if response.text != '':
            open('pubkeys.txt', 'a').write(address + ' : ' + response.text+"\n")


It was published pub key only spent from address; unfortunately 16jY7qLJnxb7CHZyqBP8qca9d51gAjyXQN not find pub key. Could you please modified it which output any wallet address to pub key.


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: pooya87 on April 05, 2021, 02:16:10 AM
It was published pub key only spent from address; unfortunately 16jY7qLJnxb7CHZyqBP8qca9d51gAjyXQN not find pub key. Could you please modified it which output any wallet address to pub key.
Block explorers can not perform magic, they simply look up the history involving that address and if any coin has ever been spent from that address they simply extract its public key. In this case this address has never been used (spent from) which means the public key is not yet revealed.
To be more specific, if any of its coins were spent then it is too late for you because it means someone already solved the puzzle involving this address ;)


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: fxsniper on April 07, 2021, 12:56:37 PM
Can possible update code to write file output

may be good for export to file is better print out if it is massive may be 1 million or billion key it need to save to file


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: marissia on April 08, 2021, 10:42:12 AM
 :'( still no answer!! people please update code to output file!!


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: HCP on April 15, 2021, 11:06:10 PM
Can possible update code to write file output

may be good for export to file is better print out if it is massive may be 1 million or billion key it need to save to file
:'( still no answer!! people please update code to output file!!

Are you wanting the code to be updated for the private key to address converter that this thread was originally about... or for the "address to pubkey" converter that gsciservices was looking for?

For the former... You don't need to bother with opening a file and writing the output in the Python script itself. Simply redirect the output of the script to a file from the commandline... ie. for linux:
Code:
python your_script.py > your_outfile_name.txt

Windows supports something similar.


If you're wanting the address to public key... well as pooya87 noted, it's asking the impossible if the address has not been "spent" from... you cannot go from address -> public key as public key -> address uses one way hash functions.


Title: Re: Mass Private Key to Bitcoin Address Converter
Post by: btc-room101 on April 19, 2021, 02:26:29 AM
I search a Mass Private Key to Bitcoin Address Converter.

There is a tool called 'KU' in the pycoin python library, it gets installed in your bin when you install the lib

Here using private-key '1' as an example

DOS-Prompt: "ku 1"

input                        : 1
network                      : Bitcoin mainnet
symbol                       : BTC
secret exponent              : 1
 hex                         : 1
wif                          : KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn
 uncompressed                : 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf
public pair x                : 55066263022277343669578718895168534326250603453777594175500187360389116729240
public pair y                : 32670510020758816978083085130507043184471273380659243275938904335757337482424
 x as hex                    : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
 y as hex                    : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
y parity                     : even
key pair as sec              : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
 uncompressed                : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\
                                 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
hash160                      : 751e76e8199196d454941c45d1b3a323f1433bd6
 uncompressed                : 91b24bf9f5288532960ac687abb035127b1d28a5
Bitcoin address              : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
Bitcoin address uncompressed : 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm
Bitcoin segwit address       : bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4
p2sh segwit                  : 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN
 corresponding p2sh script   : 0014751e76e8199196d454941c45d1b3a323f1433bd6

Note that you get all this info, you pick what you want, 'bitcoin address' is there, then use awk/sed to strip which line/data u want, write a batch file to convert all your private keys to addresses, if you want fast, then study 'ku' source, and write your own python script

Most people use the h160 format as it requires the least storage, and is easy to map to any address format.

If you have say 100M private keys, then you want to use h160, and you'll need 4TB disk-storage on your desktop.

Study the output of KU, learn what all this stuff is, the source can show you which call's in python do the transformation of format