A few years ago I deposited a specific amount of bitcoins into an address and wrote that address/private key down. I lost the last four characters of the address. I counted that each character can be 26 upper + 26 lower + 10 digits = 62 characters. So missing 4 characters means that my wallet can be an of 62*62*62*62 = 14,776,336 addresses. How can I programmatically check all those combinations? I will find all the addresses with the same bitcoins as I deposited and then check them one by one as I expect (hope) there to be less than 1,000 matching addresses.

I've checked blockchain.info but they timed me out after a few requests, I checked blockonomics.co but they are expensive.

  • Is actually 58*58*58*58 since the address is in Base58 , not that it matters much here. Is it only the public address you are missing the last four characters, do you have the full private key? – Chak Dec 27 '17 at 16:47
  • Yes and yes, I have the full private key. – user1367204 Dec 27 '17 at 16:58
  • 1
    If you have the full private key, why don't you use Electrum and import/sweep the private key? No need to check each address individually unless you also got 10 million private keys/addresses pairs. If you want to check a bunch of addresses you have better chance of doing so by using API. – Chak Dec 27 '17 at 17:28
  • Are you saying that only by knowing the private key I can get the balance? Also, is there an API you can recommend that can serve 10 million requests? – user1367204 Dec 27 '17 at 17:49
  • Yes, and check out the link. – Chak Dec 27 '17 at 18:36

Each private key corresponds to exactly one public key. This public key can be represented in two ways that give different addresses: uncompressed and compressed. This gives you two addresses for a private key.
So no need to check each public addresses individually unless you also got 10+ millions private keys/addresses pairs.

You can check out this simple and easy to use software created by Shorena on bitcointalk.org, that uses blockchain.info Query API. I've checked the source code, clean codes and nothing malicious found.
If you really plan to check 58*58*58*58 addresses, I recommend that you add a delay in the source code so you don't overflow them with requests or hit whatever limiter they've got. Also modify the code to search for multiple address per query(Multiple addresses can be separated by '|' ).

You can also bypass the request limiter on blockchain.info , by requesting an API-key.

| improve this answer | |

You don't need to check the whole 62*62*62*62 addresses online through API. That would be an insanely long journey, and you'll get blacklisted at any free service before finding what you seek, no doubt.

In your place I would:

1) download the daily balance snapshot from blockchair.com

2) either in Windows through Cygwin or in Linux shell, or in MacOS terminal type:

zcat blockchair_bitcoin_addresses_latest.tsv.gz|grep "the part of the address you remember"

Example, I took a random address from the list and removed last 4 digits:

root@ubuntu:~# time zcat blockchair_bitcoin_addresses_latest.tsv.gz |grep 1EpfyhhNnwF2Sv53PUzoJGRawiTVy
1EpfyhhNnwF2Sv53PUzoJGRawiTVybuMTz      1

real    0m9.479s
user    0m9.209s
sys     0m0.746s

I've run the command with time in front just for testing purposes, in order to demonstrate that it took less than 10 seconds to parse the list and find the matching address, and this is not a powerful PC. I don't even have SSD here, I bet if you have one it will be even faster.

Please note the number 1 after the address: this BTC address has indeed 1 satoshi.

If you are in doubt about capital letters in your address just add the -i option after grep so it will not run a case-sensitive search and will return the result even with wrong capitals in the search pattern; here I searched all Bitcoin addresses with non-zero balance containing my name despite any capitals, and it still took 10s:

root@ubuntu:~# time zcat blockchair_bitcoin_addresses_latest.tsv.gz |grep -i marco
3NPjX9BFc3hZdXeqjFqMNMARco2gfna9cR      1512000000
1HTsd6dR5qdKUTghRh8VdfDq3marcoVBdZ      4267964
1LCidVxbHzL4maRcoeaYZrevVVz3KTHnqb      3900000
1AF9enGasTBY1zxsMARCotYP9izc2v3Fzs      2028360
17kaMiiyDa11VGYMArCoZM8wD9enpWXc5K      1009417
1EoDrgLovufWp4BjC4iEqyhSHR2MaRcob1      1003055
14UEd1qtHwvWk3tWjkDsZfRXKUDx7mArCo      483996
1At868R9nWceRRpymarCopNhrywPUooDvE      431629
1Marco12CWtLWwAK9eKxqTZmeQgitBwAhg      200000
1marcoUFS2NyCtW7hH2AGxGVbJ9fpZkrR       184000
17Nw3Ed1vnUQpmzKty2MarcoCskKDZQmAp      167192
18odA7ipASdRFkf1gGAspQ8DQmArCoLrsU      99300
1MArcoSBgoNhnypXD7YhE4T9B7eUFSTLA3      26280
1marco52Uta2SKaLPeNiEczbrwCHnV7Jb       17100
1MaRCoEoSZXpupVVtCcs5chdEVwF78FQ9U      10000
1Kf9aZ21UQmrRBpXfMarcoQoj7VgV2e9H2      3660
1FT4mpGZS4Df8WzjWHhDDCezJJKksmARCo      3607
1MarcoStvKXXkeQJhwfcUdUP1NLnHB2bfr      1
1MArCovVsyQ54sRufEvjCrNCmUfgr3ZsvY      1
1MARcoseSo15DysRD9t2GoRm2aaHPKxgeh      1
1DemArcoSrb2D8RCSvsU7gPBvFbT3sdDL1      1
1MarConm2xEoBveieCcGGZvAvKZi6EHvzn      1
1DemArCozufYcpvVqxsXy3ttLh2iN5keHr      1
1MARCoNioFuSbuX7mgAifgBx8hsF8FVFu8      1

real    0m9.921s
user    0m10.829s
sys     0m0.656s

Relevant note: if you have not a premium API account on blockchair.com the list download (today over 700MB) is rate limited to 128KB/s. The DL takes around two hours but it is updated daily, and I find it's still a tremendous booster for all bulk balance lookups issues, unless you need balances to be real time. In this last case, look to a paid API as only solution.

| improve this answer | |
  • Downvotes would be useful with an explanation! – Marco Oct 1 '19 at 23:03
  • 1
    even though there are better solutions, i thought your answer provided value that could be useful to others – Andrew Oct 15 '19 at 20:37

If you are actually only trying to find the full address from the start of it, you could use walletexplorer.com. On that site you can input the first few (about 8-10) characters of a wallet address and it will find the address for you.

| improve this answer | |

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.