Author

Topic: Python script for testing a bunch of bitcoin private keys (Read 525 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
you just read my mind i was thinking
-when only generating privates keys took only few seconds
-when only generating both privates keys and public address took too many time slow
-even if i try to extract only addresses after generating the privates keys was slow too

Of course 2nd and 3rd operation are slower because there are more task/operation which need to be executed.

any alternatives solutions for me? Huh i can't have my own library for now  Undecided

If you desperately need fast performance, there's no choice other than use more efficient language such as C++.
You also could try multithreading/processing if you insist to use Python, beware with deadlock/livelock if you perform write/update operation though.
member
Activity: 378
Merit: 53
Telegram @keychainX
hello,

can anyone help or direct me where i can find it

it will better if the script test files with 100k to 500k bitcoin privates keys

First download blockparser from github and second convert all your private keys with above  mentioned tool to find a match.

very simple. block parser may take a while depending on your code, disk speed, memory etc.

Setting up a block parser you can read here https://countuponsecurity.com/2016/11/20/blockchain-brainwallet-cracking/

the rest is simple unix scritps

/KX
jr. member
Activity: 56
Merit: 3
why do you have so many keys to check anyways?

many satoshi's bitcoin are missing out there for someone to take them Cool
i want to take my chances of getting one of this lost wallets Grin

haha, cool.
as long as you realize you are wasting your time, it is cool to learn some coding and the underlying cryptography that bitcoin uses.
for your purpose you shouldn't be using a library. you have to write your own code for all the parts.

for starters the library that was introduced is in python, that is slow to begin with. additionally the functions aren't defined to be fast for huge loops.
this part alone will slow it down dramatically: https://github.com/mflaxman/coinkit/blob/8ce28ac4ff56e2320bf452d0559b83baf40b2b51/coinkit/keyspace.py#L25-L37
hashlib.Sha256 is also slow even though it is written in C but the way you are going to be using it in that library is going to be slow.

although one might wonder why you are even looping through base58 (WIF) keys if you are looping through random keys!
you just read my mind i was thinking
-when only generating privates keys took only few seconds
-when only generating both privates keys and public address took too many time slow
-even if i try to extract only addresses after generating the privates keys was slow too

any alternatives solutions for me? Huh i can't have my own library for now  Undecided
legendary
Activity: 3472
Merit: 10611
why do you have so many keys to check anyways?

many satoshi's bitcoin are missing out there for someone to take them Cool
i want to take my chances of getting one of this lost wallets Grin

haha, cool.
as long as you realize you are wasting your time, it is cool to learn some coding and the underlying cryptography that bitcoin uses.
for your purpose you shouldn't be using a library. you have to write your own code for all the parts.

for starters the library that was introduced is in python, that is slow to begin with. additionally the functions aren't defined to be fast for huge loops.
this part alone will slow it down dramatically: https://github.com/mflaxman/coinkit/blob/8ce28ac4ff56e2320bf452d0559b83baf40b2b51/coinkit/keyspace.py#L25-L37
hashlib.Sha256 is also slow even though it is written in C but the way you are going to be using it in that library is going to be slow.

although one might wonder why you are even looping through base58 (WIF) keys if you are looping through random keys!
jr. member
Activity: 56
Merit: 3

Assuming that private key is valid, that means the library doesn't support WIF (with compressed key) format. You might want to convert it to WIF (uncompressed key) or use another library such as https://github.com/ofek/bit.

Besides, library mentioned by @seoincorporation is outdates (last commit in 2014)


yes my key valid and tested: 5JFJnRWLYgPV8vrhzmox8rHru42ACUnM8Y44eG7QtFqPUCyHdRP
this key not (5JFJnRWLYgPV8vrhzmox8rHru42ACUnM8Y44eG7QtFqPUCyHdRP)

i need to work offline  Undecided  this wint help https://github.com/ofek/bit.



could you please take a look and fix this Cry
Code:
from coinkit.keypair import BitcoinKeypair

with open("prvkey.txt","r") as f:
    in_prvkey = f.readlines()
in_prvkey = [x.strip() for x in in_prvkey]
f.close()
#print  in_prvkey

outfile = open("prvkey2add.txt","w")
for x in in_prvkey:
  k = BitcoinKeypair(x)
  print k
 
outfile.write(k.address(x)+"\n")
outfile.close()

-read private keys [and support all keys format] from a file
-give output public addresses all line by line [only addresses]
 Embarrassed
jr. member
Activity: 56
Merit: 3
i found the python script i used in the past for the same propose, it's called coinkit:

Code:
from coinkit.keypair import BitcoinKeypair
k = BitcoinKeypair('5Jx4txgXUCe1kP8mBLEZrLSsZm9WRin8xijWvVW8RACzHn2ZzBH')
d = k.address()
print (d)

For more information look at: https://github.com/mflaxman/coinkit

i made few changes
to read filess contain prvtkey
and give pubadd as output

can you please take a look and fix it Undecided
Code:
from coinkit.keypair import BitcoinKeypair

with open("prvkey.txt","r") as f:
    in_prvkey = f.readlines()
in_prvkey = [x.strip() for x in in_prvkey]
f.close()
#print  in_prvkey

outfile = open("prvkey2add.txt","w")
for x in in_prvkey:
  k = BitcoinKeypair(x)
  print k
 
outfile.write(k.address(x)+"\n")
outfile.close()
jr. member
Activity: 56
Merit: 3
why do you have so many keys to check anyways?

many satoshi's bitcoin are missing out there for someone to take them Cool
i want to take my chances of getting one of this lost wallets Grin

Ridiculous. Why the hell did you even mention that "100k to 500k" range?
this number help me to estimate the time needed to treat for big files all i do after is *10 or *100
500k few sec...etc
legendary
Activity: 1862
Merit: 1505
why do you have so many keys to check anyways?

many satoshi's bitcoin are missing out there for someone to take them Cool
i want to take my chances of getting one of this lost wallets Grin

Ridiculous. Why the hell did you even mention that "100k to 500k" range?
jr. member
Activity: 56
Merit: 3
why do you have so many keys to check anyways?

many satoshi's bitcoin are missing out there for someone to take them Cool
i want to take my chances of getting one of this lost wallets Grin
jr. member
Activity: 56
Merit: 3
I reply again because i found the python script i used in the past for the same propose, it's called coinkit:
Code:
from coinkit.keypair import BitcoinKeypair
k = BitcoinKeypair('5Jx4txgXUCe1kP8mBLEZrLSsZm9WRin8xijWvVW8RACzHn2ZzBH')
d = k.address()
print (d)

For more information look at: https://github.com/mflaxman/coinkit

thank you for the 4 linescode Kiss
but it not working for all keys

Code:
from coinkit.keypair import BitcoinKeypair
k = BitcoinKeypair('5JFJnRWLYgPV8vrhzmox8rHru42ACUnM8Y44eG7QtFqPUCyHdRP')
d = k.address()
print (d)

>getaddress.py
1crof2axcuUxNc6aBkNM9aoawoJxpf8vg

Code:
from coinkit.keypair import BitcoinKeypair
k = BitcoinKeypair('L3inaKfhAkUWJfDP3y7Cu26iAe7BsKPHu71NeZCXZzgVgdXMxrAR')
d = k.address()
print (d)

>getaddress.py
  File "getaddress.py", line 1

    >getaddress.py
    ^
SyntaxError: invalid syntax
legendary
Activity: 3472
Merit: 10611
you won't find any optimized scripts or tools to do what you want because that is not something that people normally want to do. you just don't suddenly come up with hundreds of thousands of keys wanting to check their balances. even big exchanges that handle millions of addresses add them little by little to their database.
so as @ETFbitcoin said you have to create your own. while doing that you have to know that the bottleneck is not just database lookups, it is also the EC multiplications of 500k times and the two hashes that you have to perform 500k times on each of them.

why do you have so many keys to check anyways?
legendary
Activity: 3346
Merit: 3125
The best way is make your own database which have column address and amount. There's big bottleneck if you use Bitcoin Core or block explorer API.
Combining your script with tools mentioned by @seoincorporation and query to local database would save lots of time.

And the second step is the complex one... Verify the address balance, for this, you can use an API from some block explorer to verify if the address has balance, or another way is to do it directly with bitcoin core.

Bitcoin Core don't index balance of each address, unless it's part of your wallet (including watch-only address). You could use chainstate and txindex though.

But i think the best way to do it and to save time is to import all those private keys to bitcoin core, that way you will not waste time calling the API to verify if they have balance or not.

I'm not sure if it's best way when we're talking about hundred thousand of Bitcoin address.

I think bitcoin core was able to show balance but as you say for that we have to add the address as watch only...

And about the best way you are right, is not the best way, is just the easy way.

I reply again because i found the python script i used in the past for the same propose, it's called coinkit:

Code:
from coinkit.keypair import BitcoinKeypair
k = BitcoinKeypair('5Jx4txgXUCe1kP8mBLEZrLSsZm9WRin8xijWvVW8RACzHn2ZzBH')
d = k.address()
print (d)

For more information look at: https://github.com/mflaxman/coinkit
legendary
Activity: 1862
Merit: 1505
The best way is make your own database which have column address and amount. There's big bottleneck if you use Bitcoin Core or block explorer API.

@crofrihosl, if you're going to follow this approach (of creating your own database), the following Python code will definitely help you:

https://github.com/graymauser/btcposbal2csv
jr. member
Activity: 56
Merit: 3
The problem about this is that you need two steps, the first one (and the easy one) is to get the address from the private key, for that you can use a tool like this:

https://github.com/blockstack/pybitcoin

And the second step is the complex one... Verify the address balance, for this, you can use an API from some block explorer to verify if the address has balance, or another way is to do it directly with bitcoin core.

But i think the best way to do it and to save time is to import all those private keys to bitcoin core, that way you will not waste time calling the API to verify if they have balance or not.

thank you for replying

i used electrum to extract public address but crashing

can i find this?

SOMECODES.py  file_contain_private_keys.txt output>> file_contain_public_keys.txt

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
The best way is make your own database which have column address and amount. There's big bottleneck if you use Bitcoin Core or block explorer API.
Combining your script with tools mentioned by @seoincorporation and query to local database would save lots of time.

And the second step is the complex one... Verify the address balance, for this, you can use an API from some block explorer to verify if the address has balance, or another way is to do it directly with bitcoin core.

Bitcoin Core don't index balance of each address, unless it's part of your wallet (including watch-only address). You could use chainstate and txindex though.

But i think the best way to do it and to save time is to import all those private keys to bitcoin core, that way you will not waste time calling the API to verify if they have balance or not.

I'm not sure if it's best way when we're talking about hundred thousand of Bitcoin address.
legendary
Activity: 3346
Merit: 3125
The problem about this is that you need two steps, the first one (and the easy one) is to get the address from the private key, for that you can use a tool like this:

https://github.com/blockstack/pybitcoin

And the second step is the complex one... Verify the address balance, for this, you can use an API from some block explorer to verify if the address has balance, or another way is to do it directly with bitcoin core.

But i think the best way to do it and to save time is to import all those private keys to bitcoin core, that way you will not waste time calling the API to verify if they have balance or not.
jr. member
Activity: 56
Merit: 3

do something like
- read public address from a file
- check for balance and tx
- print output

with more option:
- get the public key from the private key and test it with blockchain api
- check for balance and tx
- print output

jr. member
Activity: 56
Merit: 3
hello,

can anyone help or direct me where i can find it

it will better if the script test files with 100k to 500k bitcoin privates keys
Jump to: