Why Nostr? What is Njump?
2023-06-07 02:03:39
in reply to

Pieter Wuille [ARCHIVE] on Nostr: 📅 Original date posted:2011-07-07 🗒️ Summary of this message: Bitcoin aims to ...

📅 Original date posted:2011-07-07
🗒️ Summary of this message: Bitcoin aims to standardize the version bytes used in addresses and other base58-encoded data structures to avoid confusion.
📝 Original message:On Thu, Jul 07, 2011 at 01:15:57PM +0200, Pieter Wuille wrote:
> Hello everyone,
>
> after a discussion on IRC, we decided to try to standardize the version bytes
> used by bitcoin for several applications.

I realize my mail may have been a bit unclear. This is about the version bytes
used in addresses and other base58-encoded data structures. I'd like to see some
convention adopted before everyone starts defining their own.

The proposal in the previous mail could be summarized by the following functions
(for non-alternate chains). It is compatible with all currently-used version bytes
that i know of (testnet, realnet, addresses, private keys, namecoin, multicoin):

enum dataclass_t
{
address = 0,
privkey = 4,
masterkey = 6,
extended = 7
}

int EncodeVersionByte(dataclass_t class, int nVersion, bool fTestNet)
{
return (class << 5 + nVersion << 1) ^ fTestNet*111;
}

void DecodeVersionByte(int nByte, dataclass_t& class, int& nVersion, bool& fTestNet)
{
fTestNet = false;
if (nByte & 1)
{
fTestNet = true;
nByte ^= 111;
}
class = (nByte & 224) >> 5;
nVersion = (nByte & 14) >> 1;
}

--
Pieter
Author Public Key
npub1tjephawh7fdf6358jufuh5eyxwauzrjqa7qn50pglee4tayc2ntqcjtl6r