What is the reference algorithm for validating a Bitcoin address?

0

0

I need to validate Bitcoin addresses in an application I'm developing; I have found various code samples for various languages (even on StackOverflow), but none specific for the one I am using (C#); also, all of those samples seem to come from volunteers around the world, but I've been unable to find an "official" reference algorithm for address validation.

This links explains how an address is generated, but even it has some dubious statements, like "this is the most commonly used Bitcoin Address format" at the end of the article; also, it doesn't explain how to actually validate one if you're not doing the address generation.

What is the official, reference algorithm for checking the validity of a Bitcoin address?

Of course, I'm only interested in syntactic validity; I don't care if the address was ever actually used, if it has any Bitcoin balance, or if the user really is in possession of the associated private key.

Please avoid code samples, as they are language-specific; what I'm asking for is a detailed description of the steps required for validation, so that it can be implemented in any language of choice.

Massimo

Posted 2014-03-05T13:25:53.203

Reputation: 978

1

While you indicated you weren't interested in code samples, this one is in C# and may have a solution for you: https://github.com/casascius/Bitcoin-Address-Utility/. I've been meaning to check it out myself.

ChrisW 2014-03-05T22:18:59.503

Answers

1

Please avoid code samples, as they are language-specific; what I'm asking for is a detailed description of the steps required for validation, so that it can be implemented in any language of choice.

You won't find any documentation other than the wiki which is generally out of date and incorrect, so code samples will have to do. Check the reference client Bitcoin Core, and some of the JavaScript implementations in BitcoinJS. It's not difficult, just base58 encoding with a version byte of 0x01 at the front and a truncated hash at the rear. P2SH transactions have a different version byte but are still valid in the same fashion.

user13413

Posted 2014-03-05T13:25:53.203

Reputation: 890

...are you seriously saying that there is no official documentation and all you can do is reverse-engineer it from the client software?!? :-oMassimo 2014-03-05T19:41:19.123

The Bitcoin Core software the documentation, and the wiki has some generally out of date technical details. I'm quite serious, but thankfully the core client is extremely readable. If you want to change things you can write some documentation, but nobody likes doing that.user13413 2014-03-05T19:43:12.733