From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1QeuQv-0007ZH-9o for bitcoin-development@lists.sourceforge.net; Thu, 07 Jul 2011 19:40:21 +0000 X-ACL-Warn: Received: from rhcavuit01.kulnet.kuleuven.be ([134.58.240.129] helo=cavuit01.kulnet.kuleuven.be) by sog-mx-3.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1QeuQt-0003OV-Tw for bitcoin-development@lists.sourceforge.net; Thu, 07 Jul 2011 19:40:21 +0000 X-KULeuven-Envelope-From: sipa@ulyssis.org X-Spam-Status: not spam, SpamAssassin (not cached, score=-48.788, required 5, autolearn=disabled, DKIM_ADSP_CUSTOM_MED 0.00, FREEMAIL_FROM 0.00, KUL_SMTPS -50.00, NML_ADSP_CUSTOM_MED 1.20, T_TO_NO_BRKTS_FREEMAIL 0.01) X-KULeuven-Scanned: Found to be clean X-KULeuven-ID: 79CC51380BD.A6F43 X-KULeuven-Information: Katholieke Universiteit Leuven Received: from smtps01.kuleuven.be (smtpshost01.kulnet.kuleuven.be [134.58.240.74]) by cavuit01.kulnet.kuleuven.be (Postfix) with ESMTP id 79CC51380BD for ; Thu, 7 Jul 2011 21:40:08 +0200 (CEST) Received: from smtp.ulyssis.org (mail.ulyssis.student.kuleuven.be [193.190.253.235]) by smtps01.kuleuven.be (Postfix) with ESMTP id 5D1D631E702 for ; Thu, 7 Jul 2011 21:40:08 +0200 (CEST) Received: from wop.ulyssis.org (wop.intern.ulyssis.org [192.168.0.182]) by smtp.ulyssis.org (Postfix) with ESMTP id B47A310067 for ; Thu, 7 Jul 2011 21:41:26 +0200 (CEST) Received: by wop.ulyssis.org (Postfix, from userid 615) id 5E64187C1AB; Thu, 7 Jul 2011 21:40:08 +0200 (CEST) Date: Thu, 7 Jul 2011 21:40:08 +0200 X-Kuleuven: This mail passed the K.U.Leuven mailcluster From: Pieter Wuille To: bitcoin-development@lists.sourceforge.net Message-ID: <20110707194007.GA27416@ulyssis.org> References: <20110707111557.GA5231@ulyssis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110707111557.GA5231@ulyssis.org> X-PGP-Key: http://sipa.ulyssis.org/pubkey.asc User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam-Score: 1.2 (+) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (pieter.wuille[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list 0.0 T_TO_NO_BRKTS_FREEMAIL To: misformatted and free email service -0.0 AWL AWL: From: address is in the auto white-list X-Headers-End: 1QeuQt-0003OV-Tw Subject: Re: [Bitcoin-development] Version bytes X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 19:40:21 -0000 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