Esempio n. 1
0
    def test_b58check(self):
        vectors = [
            ('', '3QJmnh'),
            ('61', 'C2dGTwc'),
            ('626262', '4jF5uERJAK'),
            ('636363', '4mT4krqUYJ'),
            ('73696d706c792061206c6f6e6720737472696e67', 'BXF1HuEUCqeVzZdrKeJjG74rjeXxqJ7dW'),
            ('00eb15231dfceb60925886b67d065299925915aeb172c06647', '13REmUhe2ckUKy1FvM7AMCdtyYq831yxM3QeyEu4'),
            ('516b6fcd0f', '237LSrY9NUUas'),
            ('bf4f89001e670274dd', 'GwDDDeduj1jpykc27e'),
            ('572e4794', 'FamExfqCeza'),
            ('ecac89cad93923c02321', '2W1Yd5Zu6WGyKVtHGMrH'),
            ('10c8511e', '3op3iuGMmhs'),
            ('00000000000000000000', '111111111146Momb')
        ]

        for v in vectors:
            self.assertEqual(
                convert.bytes_to_b58check(convert.hex_to_bytes(v[0])),
                v[1]
            )
            self.assertEqual(
                convert.b58check_to_bytes(v[1]),
                convert.hex_to_bytes(v[0])
            )
Esempio n. 2
0
def serialize_xpub(k):
    b = b''
    b += HD_HEADER_PUBLIC
    b += convert.int_to_byte(k['depth'])
    b += k['fingerprint']
    b += convert.int_to_bytes(k['i'], 4)
    b += k['chaincode']
    b += ecdsa.serialize_pub(k['pub'])
    return convert.bytes_to_b58check(b)
Esempio n. 3
0
def serialize_xpriv(k):
    b = b''
    b += HD_HEADER_PRIVATE
    b += convert.int_to_byte(k['depth'])
    b += k['fingerprint']
    b += convert.int_to_bytes(k['i'], 4)
    b += k['chaincode']
    b += b'\x00' + ecdsa.serialize_priv(k['priv'])
    return convert.bytes_to_b58check(b)