示例#1
0
def get_datacarrier_tx() -> Transaction:
    """datacarrier tx with one op_return output >6000 bytes and an xpubkey in the
    input - only for testing obj size calculation"""
    path = Path(dirname(os.path.realpath(__file__))).joinpath(
        "data/transactions/data_carrier.txt")
    with open(path, "r") as f:
        rawtx = f.read()

    tx = Transaction.from_hex(rawtx)
    priv_key_bytes = bitcoinx.PrivateKey(
        bytes.fromhex(
            'a2d9803c912ab380c1491d3bd1aaab34ca06742d7885a224ec8d386182d26ed2')
    ).public_key.to_bytes()
    tx.inputs[0].x_pubkeys.append(XPublicKey.from_bytes(priv_key_bytes))
    return tx
示例#2
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.from_bytes(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