URI: 
       ttests: xpub version bytes - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 58273fc841c8ca80698cdafe790f8152f264183c
   DIR parent ff57c198b4f7acfb981b95bac6e69e769c0a75c4
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Sun,  1 Apr 2018 16:56:17 +0200
       
       ttests: xpub version bytes
       
       Diffstat:
         M lib/tests/test_bitcoin.py           |      76 ++++++++++++++++++++++++++++++-
       
       1 file changed, 75 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/lib/tests/test_bitcoin.py b/lib/tests/test_bitcoin.py
       t@@ -11,8 +11,9 @@ from lib.bitcoin import (
            var_int, op_push, address_to_script, regenerate_key,
            verify_message, deserialize_privkey, serialize_privkey, is_segwit_address,
            is_b58_address, address_to_scripthash, is_minikey, is_compressed, is_xpub,
       -    xpub_type, is_xprv, is_bip32_derivation, seed_type)
       +    xpub_type, is_xprv, is_bip32_derivation, seed_type, EncodeBase58Check)
        from lib.util import bfh
       +from lib import constants
        
        from . import TestCaseForTestnet
        
       t@@ -259,6 +260,79 @@ class Test_xprv_xpub(unittest.TestCase):
                self.assertFalse(is_bip32_derivation(""))
                self.assertFalse(is_bip32_derivation("m/q8462"))
        
       +    def test_version_bytes(self):
       +        xprv_headers_b58 = {
       +            'standard':    'xprv',
       +            'p2wpkh-p2sh': 'yprv',
       +            'p2wsh-p2sh':  'Yprv',
       +            'p2wpkh':      'zprv',
       +            'p2wsh':       'Zprv',
       +        }
       +        xpub_headers_b58 = {
       +            'standard':    'xpub',
       +            'p2wpkh-p2sh': 'ypub',
       +            'p2wsh-p2sh':  'Ypub',
       +            'p2wpkh':      'zpub',
       +            'p2wsh':       'Zpub',
       +        }
       +        for xtype, xkey_header_bytes in constants.net.XPRV_HEADERS.items():
       +            xkey_header_bytes = bfh("%08x" % xkey_header_bytes)
       +            xkey_bytes = xkey_header_bytes + bytes([0] * 74)
       +            xkey_b58 = EncodeBase58Check(xkey_bytes)
       +            self.assertTrue(xkey_b58.startswith(xprv_headers_b58[xtype]))
       +
       +            xkey_bytes = xkey_header_bytes + bytes([255] * 74)
       +            xkey_b58 = EncodeBase58Check(xkey_bytes)
       +            self.assertTrue(xkey_b58.startswith(xprv_headers_b58[xtype]))
       +
       +        for xtype, xkey_header_bytes in constants.net.XPUB_HEADERS.items():
       +            xkey_header_bytes = bfh("%08x" % xkey_header_bytes)
       +            xkey_bytes = xkey_header_bytes + bytes([0] * 74)
       +            xkey_b58 = EncodeBase58Check(xkey_bytes)
       +            self.assertTrue(xkey_b58.startswith(xpub_headers_b58[xtype]))
       +
       +            xkey_bytes = xkey_header_bytes + bytes([255] * 74)
       +            xkey_b58 = EncodeBase58Check(xkey_bytes)
       +            self.assertTrue(xkey_b58.startswith(xpub_headers_b58[xtype]))
       +
       +
       +class Test_xprv_xpub_testnet(TestCaseForTestnet):
       +
       +    def test_version_bytes(self):
       +        xprv_headers_b58 = {
       +            'standard':    'tprv',
       +            'p2wpkh-p2sh': 'uprv',
       +            'p2wsh-p2sh':  'Uprv',
       +            'p2wpkh':      'vprv',
       +            'p2wsh':       'Vprv',
       +        }
       +        xpub_headers_b58 = {
       +            'standard':    'tpub',
       +            'p2wpkh-p2sh': 'upub',
       +            'p2wsh-p2sh':  'Upub',
       +            'p2wpkh':      'vpub',
       +            'p2wsh':       'Vpub',
       +        }
       +        for xtype, xkey_header_bytes in constants.net.XPRV_HEADERS.items():
       +            xkey_header_bytes = bfh("%08x" % xkey_header_bytes)
       +            xkey_bytes = xkey_header_bytes + bytes([0] * 74)
       +            xkey_b58 = EncodeBase58Check(xkey_bytes)
       +            self.assertTrue(xkey_b58.startswith(xprv_headers_b58[xtype]))
       +
       +            xkey_bytes = xkey_header_bytes + bytes([255] * 74)
       +            xkey_b58 = EncodeBase58Check(xkey_bytes)
       +            self.assertTrue(xkey_b58.startswith(xprv_headers_b58[xtype]))
       +
       +        for xtype, xkey_header_bytes in constants.net.XPUB_HEADERS.items():
       +            xkey_header_bytes = bfh("%08x" % xkey_header_bytes)
       +            xkey_bytes = xkey_header_bytes + bytes([0] * 74)
       +            xkey_b58 = EncodeBase58Check(xkey_bytes)
       +            self.assertTrue(xkey_b58.startswith(xpub_headers_b58[xtype]))
       +
       +            xkey_bytes = xkey_header_bytes + bytes([255] * 74)
       +            xkey_b58 = EncodeBase58Check(xkey_bytes)
       +            self.assertTrue(xkey_b58.startswith(xpub_headers_b58[xtype]))
       +
        
        class Test_keyImport(unittest.TestCase):