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
Published at
2023-06-07 02:03:39Event JSON
{
"id": "616e851f83dd705c5f034d7eb42e6cc36a9196236c159144382555147703064f",
"pubkey": "5cb21bf5d7f25a9d46879713cbd32433bbc10e40ef813a3c28fe7355f49854d6",
"created_at": 1686103419,
"kind": 1,
"tags": [
[
"e",
"3a6afd5ff34641f5be9f2e62336683df2e1248a1aa2cdee551b6833c651c6625",
"",
"root"
],
[
"e",
"f4de055d9636aa41593dc76fd0e1090cfcada631a6d00ebd833f5d3d90711c4a",
"",
"reply"
],
[
"p",
"5cb21bf5d7f25a9d46879713cbd32433bbc10e40ef813a3c28fe7355f49854d6"
]
],
"content": "📅 Original date posted:2011-07-07\n🗒️ Summary of this message: Bitcoin aims to standardize the version bytes used in addresses and other base58-encoded data structures to avoid confusion.\n📝 Original message:On Thu, Jul 07, 2011 at 01:15:57PM +0200, Pieter Wuille wrote:\n\u003e Hello everyone,\n\u003e \n\u003e after a discussion on IRC, we decided to try to standardize the version bytes\n\u003e used by bitcoin for several applications.\n\nI realize my mail may have been a bit unclear. This is about the version bytes\nused in addresses and other base58-encoded data structures. I'd like to see some\nconvention adopted before everyone starts defining their own.\n\nThe proposal in the previous mail could be summarized by the following functions\n(for non-alternate chains). It is compatible with all currently-used version bytes\nthat i know of (testnet, realnet, addresses, private keys, namecoin, multicoin):\n\nenum dataclass_t \n{\n address = 0,\n privkey = 4,\n masterkey = 6,\n extended = 7\n}\n\nint EncodeVersionByte(dataclass_t class, int nVersion, bool fTestNet)\n{\n return (class \u003c\u003c 5 + nVersion \u003c\u003c 1) ^ fTestNet*111;\n}\n\nvoid DecodeVersionByte(int nByte, dataclass_t\u0026 class, int\u0026 nVersion, bool\u0026 fTestNet)\n{\n fTestNet = false;\n if (nByte \u0026 1)\n {\n fTestNet = true;\n nByte ^= 111;\n }\n class = (nByte \u0026 224) \u003e\u003e 5;\n nVersion = (nByte \u0026 14) \u003e\u003e 1;\n}\n\n-- \nPieter",
"sig": "c0fd5bdc958aec6a5b870f3e1f38d6e186b138c13dc93a1e8bd6c45144869b370170e5e78b6654554888bd10c0d0fac1c63196561903bcc8e7e3e5a950827162"
}