Ejemplo n.º 1
0
 def test_raw_public_keys(self, raw_hex, coin):
     public_key = PublicKey.from_hex(raw_hex)
     x_pubkey = XPublicKey(raw_hex)
     assert x_pubkey.to_bytes() == bytes.fromhex(raw_hex)
     assert x_pubkey.to_hex() == raw_hex
     assert not x_pubkey.is_bip32_key()
     assert x_pubkey.to_public_key() == public_key
     assert x_pubkey.to_address() == public_key.to_address(coin=coin)
     assert x_pubkey.to_address().coin() is coin
Ejemplo n.º 2
0
 def test_addresses(self, raw_hex, address, coin):
     address = Address.from_string(address)
     address._coin = coin
     x_pubkey = XPublicKey(raw_hex)
     assert x_pubkey.to_bytes() == bytes.fromhex(raw_hex)
     assert x_pubkey.to_hex() == raw_hex
     assert not x_pubkey.is_bip32_key()
     assert x_pubkey.to_public_key() == address
     assert x_pubkey.to_address() == address
     assert x_pubkey.to_address().coin() is coin
Ejemplo n.º 3
0
 def test_old_keystore(self, raw_hex, public_key_hex, coin):
     public_key = PublicKey.from_hex(public_key_hex)
     assert public_key.is_compressed() is False
     x_pubkey = XPublicKey(raw_hex)
     assert x_pubkey.to_bytes() == bytes.fromhex(raw_hex)
     assert x_pubkey.to_hex() == raw_hex
     assert not x_pubkey.is_bip32_key()
     assert x_pubkey.to_public_key() == public_key
     assert x_pubkey.to_public_key().is_compressed() is False
     assert x_pubkey.to_address() == public_key.to_address(coin=coin)
     assert x_pubkey.to_address().coin() is coin
Ejemplo n.º 4
0
    def test_bip32_extended_keys(self, raw_hex, path, coin):
        # see test_keystore.py
        xpub = ('xpub661MyMwAqRbcH1RHYeZc1zgwYLJ1dNozE8npCe81pnNYtN6e5KsF6cmt17Fv8w'
                'GvJrRiv6Kewm8ggBG6N3XajhoioH3stUmLRi53tk46CiA')
        root_key = bip32_key_from_string(xpub)
        True_10_public_key = root_key.child(path[0]).child(path[1])

        x_pubkey = XPublicKey(bytes.fromhex(raw_hex))
        assert x_pubkey.to_bytes() == bytes.fromhex(raw_hex)
        assert x_pubkey.to_hex() == raw_hex
        assert x_pubkey.is_bip32_key()
        assert x_pubkey.bip32_extended_key_and_path() == (xpub, path)
        assert x_pubkey.to_public_key() == True_10_public_key
        assert x_pubkey.to_address() == True_10_public_key.to_address(coin=coin)
        assert x_pubkey.to_address().coin() is coin