Author

Topic: How to check if a string is a bitcoin address? (Read 126 times)

member
Activity: 96
Merit: 36
September 23, 2021, 11:39:17 AM
#7

thanks a lot. if I cannot do it myself, I will definitely use your suggestion Smiley
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
September 23, 2021, 11:32:32 AM
#6
I am trying to get a list of all used bitcoin addresses. Only with balances does not fit

I was going to recommend you looking this: List of all Bitcoin addresses ever used, but it is currently unavailable from LoyceV's web server.

I then saw that it was uploaded in notatether.com: https://files.notatether.com/public/loycev/addresses_sorted.txt.gz

Quoting the message itself:
For anyone stumbling open this in the future, I have created a torrent for this file, which accesses the web link.

Web Link: https://files.notatether.com/public/loycev/addresses_sorted.txt.gz

Torrent Magnet URL

.torrent file, good until 2022-09

This is up to date as of 2021-08-12. It will not be updated in the future, but is being left here to help, at least for now.
member
Activity: 96
Merit: 36
September 23, 2021, 11:25:58 AM
#5

I am trying to get a list of all used bitcoin addresses. Only with balances does not fit
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
September 23, 2021, 10:59:45 AM
#4
Answering to how to distinguish a Bitcoin address from a regular text:

A bitcoin address is an encoding of three things:

  • A prefix that indicates the network. (“00” is for legacy addresses and “05” for p2sh on main net)
  • A 160-bit hash.
  • A 4-byte checksum.

For example, this is an address: 1EKdAmcXiSXXAL18eJuWCZYj7k7zLGwXXx, because once we decode it we get:

00   921f507bd82b94dabe9f8f281dccdfc2c6bd3ecc   5774bebb

The first one is indeed the prefix. The second one is indeed a 160-bit number. The third one is indeed the first 4 bytes of the doubled hashed with SHA256 prefix plus 160-bit hash.

So, if someone gave you a string that once decoded with base58, it satisfies the above, it can be used as an address.



trying to get all used bitcoin addresses
I don't know if you care about the way you'll get them, but there are already written in a frequently-updated txt file: List of all Bitcoin addresses with a balance
member
Activity: 96
Merit: 36
September 23, 2021, 10:56:24 AM
#3
I have this type of text. I do not know how to extract addresses from it without regrex.

Quote
Transaction{9765217169a5c37df0a24726b03d603b282281ebf3227fab4eefc123c0c2b0f7, wtxid 20aaad5571b9ffcb42794328ef479c0f497bb663315aeeb9ffb15b786766106a
purpose: UNKNOWN
   in   PUSHDATA(22)[0014d444cfdbb531f64a15d775641b149cbe32a6e0f7]
        witness:304402204baba958a7f9c983f3dceb3ed8f6d33e308556f57a35412149ae095514cfa2e202201fe afe9c9fbf1b80215c898ab3eb086c10a76b176ee223410f8facab4533b2cb01 029955feded3d9df36c4818c140192ba293ee0d061a74374fcf3a0a34a5c6aa276
        unconnected  outpoint:3866a7e64bc6d710bf0126a8055c47acfadc78833298d8f05bc3fecd4ab65b7a:0
   out  HASH160 PUSHDATA(20)[f08ed8d7b2f18ef711a3525479e3f0495181c8ef] EQUAL  0.00345947 BTC
        P2SH addr:3PcyDmaoLtujB7hWckbb72ckebN6r9QKqY
}, Transaction{b7c7082b997a6b066148a51f70213e305fac92330658f954c4f3ba0e632abc56, wtxid 1ba51843ce633b50c2e196519faa2d1c1f80e012f947f122af94f670ac918e43
purpose: UNKNOWN
   in   
        witness:30450221008d2061aacb2b99695f538678c199d8d93af8ce1e862bb5ca5cbab1dc5f6b8c8202206 7128cd39179a0f0e1ccb12a05f62a7d430f29d0e900650eb7194ebf6daa163001 0236f22b41ebd088769bf983bf9f3fc4958cd2f40bacbf65d2674159a527d9a7cd
        unconnected  outpoint:cca00b28b775405caeafd41498ee69d4bd74eddaf457c13b8e74d7c588cb56ed:3903
   out  DUP HASH160 PUSHDATA(20)[e8907b70e241625bdf81919feed7a38c47d925ef] EQUALVERIFY CHECKSIG  0.005046 BTC
        P2PKH addr:1NCgrJbHZ4C9kAm5rK5TrKPPeskmveE8vn
   out  0[] PUSHDATA(20)[023283edc8d89341442f126da2948b0da58a11f2]  0.00001611 BTC
        P2WPKH addr:bc1qqgeg8mwgmzf5z3p0zfk699ytpkjc5y0jate9ne
}, Transaction{0e39828097ff4e573c7c08b1593f20e7d832cdae54511613dc507118b1ea4e19, wtxid 18650554da529a6dc1bf88797b99f246c7fb9d7adecea6c228dd04de35e2e0ea
purpose: UNKNOWN
   in   PUSHDATA(72)[30450221009beab428c2f8efabf325d3f6152608c0958dd0ddd4da958dd094d4a64890dc2502204b8e941789eae073c85e930fc2cf685e6c5be12e932f1d57a125bb18b57a02ff01] PUSHDATA(33)[035bc75385336ba1474ab8bbaa5781ef7a15958f400455d1ab74639ada42fc18ee]
        unconnected  outpoint:014c341d0d5b350f00004c88b719991e935fa89f2361ec0e3f1782c755e17e8b:29
   in   
        witness:3045022100bac951be2e3b7434a597a4a71504da34618b6893c73de6d5e03576b0bdb1737802201 1042c2123cc5e40db49e0255aaad428f9ab9bae5b031403530120b7272b525101 02b36cb12d22183ac56bd3fbb97fbe003b0f6b4a68df41270467749041ec65ec4f
        unconnected  outpoint:89663cd52d5b8c5074651df1f1bafe16ab7dec9fb36b7f55c75132dd25b7ec2e:1
   out  0[] PUSHDATA(20)[8d28519d3c099e7f0da8ae041745f9f90a7919cd]  0.00084586 BTC
        P2WPKH addr:bc1q3559r8fupx087rdg4czpw30ely98jxwdvuaaav
   out  0[] PUSHDATA(20)[902ed59947adc280c7c359a0d1164ecf0c068028]  0.0007 BTC
        P2WPKH addr:bc1qjqhdtx284hpgp37rtxsdz9jweuxqdqpg2wvjnp
}, Transaction{a1b1d1d08bfe75a47f8a9dc0e06aa9ce92fd145c3706ebabeb30219cc58be920
purpose: UNKNOWN
   in   PUSHDATA(71)[304402203b0ee9382b4be567dce18e8c6ab265a52c8383f1edd7f18f5c4d832285c446d80220483f3560738b747cea9c3da8dcfa49054de78219aeb67f4cd4333bb0dfa006f301] PUSHDATA(33)[03923b6c163169a117307d4f536e7094a8b6ceeb9113d492f76cc67534e479e183]
        unconnected  outpoint:dcab4816743b0a8526b7305792b429f04b7d6c8da230f12cdf2d05346f77ff20:43
   out  DUP HASH160 PUSHDATA(20)[10a11a7038b8c532cf9443b793be1a320707bb3b] EQUALVERIFY CHECKSIG  0.00008846 BTC
        P2PKH addr:12Wvoipeu4oJNwfwHk38M5k78tUMPWpVUR
   out  DUP HASH160 PUSHDATA(20)[2fc47c0f17a750322515c4264d1f0106607a1476] EQUALVERIFY CHECKSIG  0.01210824 BTC
        P2PKH addr:15Ma91LK7GewB11KA5qDBSnHjhkPsbyKj9
}, Transaction{2290eb083d326b0c214c1150665431d46547b49cea3e70246abe432f9b27f4a6, wtxid e353c6d37226d6d4eb54171a35147f678bab7c46ab8de908395549a3b7bdf996
version 2
time locked until block 682382
a.a
member
Activity: 126
Merit: 36
September 23, 2021, 10:47:40 AM
#2
Does it have to be regex? Or can it be any other function?
member
Activity: 96
Merit: 36
September 23, 2021, 10:28:44 AM
#1
I am parsing by regular expression transactions from BitcoinCore base.
trying to get all used bitcoin addresses

Quote
Pattern   "(1|bc1)[a-km-zA-HJ-NP-Z1-9]{25,34}[^A-Za-z0-9\\p{P}]"
start  1 or bc1, the correct set of letters in the middle, long, and ending with anything other than a letter and a number to cut from the text

 the result is
Quote
185EVzhyGhS6guJ8qmxddAqKxz4ZnH7xia
1DTdkgwGugz5cRGgScamGRaQrYv8UoYMoU
179f29fc9125d44855d23833aa1b5c5 ---------------
1B3doy3pzzT5CoNxz3euZMqtEkksfwx3hY
1BeysPkUXr8MYbhQiDvbypc6jBrentMRCj
1jmmV7fwJsppj5GRSXeMFo79v5gPtx        --------------
1YpkqaE1TJLYbHseGxWowMrrCNJDLMNY  ------------
17146647f7a4992bb61b227c271843d1    --------------
1NpLfY5VRiEmk6e65NhnK6SdyfNx2TgbwV
1gmohVXc1A5GGPHsrGhPzN84sPUWhL    ----------------
128U9yEHB9zJqzEohBTkySPNNzjPJAkf8X
1usVaTvJUXdue6B6A6jAFGg7u8bRgh9bG --------------
1E9gfEykFQXGgeE2RKa3hjJfdSv2Q5SEY4

"--------" these are NOT bitcoin addresses, although the pattern matches

the crux of the problem: how to distinguish whether a string is a bitcoin address or not? I can't check on the site. a lot of them)
maybe you can count the sum of letters or something like that or change the pattern?
Jump to: