Bitcoin Forum
May 07, 2024, 11:20:48 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Python script for testing a bunch of bitcoin private keys  (Read 486 times)
crofrihosl (OP)
Jr. Member
*
Offline Offline

Activity: 56
Merit: 3


View Profile
September 09, 2019, 03:07:28 PM
 #1

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
1715124049
Hero Member
*
Offline Offline

Posts: 1715124049

View Profile Personal Message (Offline)

Ignore
1715124049
Reply with quote  #2

1715124049
Report to moderator
1715124049
Hero Member
*
Offline Offline

Posts: 1715124049

View Profile Personal Message (Offline)

Ignore
1715124049
Reply with quote  #2

1715124049
Report to moderator
1715124049
Hero Member
*
Offline Offline

Posts: 1715124049

View Profile Personal Message (Offline)

Ignore
1715124049
Reply with quote  #2

1715124049
Report to moderator
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, which will follow the rules of the network no matter what miners do. Even if every miner decided to create 1000 bitcoins per block, full nodes would stick to the rules and reject those blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715124049
Hero Member
*
Offline Offline

Posts: 1715124049

View Profile Personal Message (Offline)

Ignore
1715124049
Reply with quote  #2

1715124049
Report to moderator
1715124049
Hero Member
*
Offline Offline

Posts: 1715124049

View Profile Personal Message (Offline)

Ignore
1715124049
Reply with quote  #2

1715124049
Report to moderator
crofrihosl (OP)
Jr. Member
*
Offline Offline

Activity: 56
Merit: 3


View Profile
September 09, 2019, 03:24:08 PM
 #2


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

seoincorporation
Legendary
*
Offline Offline

Activity: 3150
Merit: 2931


Top Crypto Casino


View Profile
September 09, 2019, 04:36:44 PM
 #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.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
ABCbits
Legendary
*
Offline Offline

Activity: 2870
Merit: 7483


Crypto Swap Exchange


View Profile
September 09, 2019, 07:10:48 PM
Merited by seoincorporation (1), Raja_MBZ (1)
 #4

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.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
crofrihosl (OP)
Jr. Member
*
Offline Offline

Activity: 56
Merit: 3


View Profile
September 09, 2019, 07:59:36 PM
 #5

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

Raja_MBZ
Legendary
*
Offline Offline

Activity: 1862
Merit: 1505



View Profile
September 09, 2019, 10:35:12 PM
 #6

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
seoincorporation
Legendary
*
Offline Offline

Activity: 3150
Merit: 2931


Top Crypto Casino


View Profile
September 10, 2019, 03:40:14 AM
 #7

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

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10555



View Profile
September 10, 2019, 04:42:31 AM
 #8

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?

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
crofrihosl (OP)
Jr. Member
*
Offline Offline

Activity: 56
Merit: 3


View Profile
September 10, 2019, 12:10:38 PM
 #9

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
crofrihosl (OP)
Jr. Member
*
Offline Offline

Activity: 56
Merit: 3


View Profile
September 10, 2019, 12:59:47 PM
 #10

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
Raja_MBZ
Legendary
*
Offline Offline

Activity: 1862
Merit: 1505



View Profile
September 10, 2019, 01:09:45 PM
 #11

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?
crofrihosl (OP)
Jr. Member
*
Offline Offline

Activity: 56
Merit: 3


View Profile
September 10, 2019, 01:23:42 PM
 #12

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
crofrihosl (OP)
Jr. Member
*
Offline Offline

Activity: 56
Merit: 3


View Profile
September 10, 2019, 01:29:49 PM
 #13

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()
crofrihosl (OP)
Jr. Member
*
Offline Offline

Activity: 56
Merit: 3


View Profile
September 10, 2019, 07:29:20 PM
 #14


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
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10555



View Profile
September 11, 2019, 04:26:14 AM
 #15

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!

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
crofrihosl (OP)
Jr. Member
*
Offline Offline

Activity: 56
Merit: 3


View Profile
September 11, 2019, 01:17:35 PM
 #16

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
keychainX
Member
**
Offline Offline

Activity: 374
Merit: 53

Telegram @keychainX


View Profile WWW
September 15, 2019, 01:37:24 PM
 #17

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

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!