def test_out_point() -> None: out_point = OutPoint() assert out_point.tx_id == b"\x00" * 32 assert out_point.vout == 0xFFFFFFFF assert out_point.hash == int.from_bytes(out_point.tx_id, "big", signed=False) assert out_point.n == out_point.vout assert out_point.is_coinbase() assert out_point == OutPoint.parse(out_point.serialize()) assert out_point == OutPoint.from_dict(out_point.to_dict()) tx_id = "d5b5982254eebca64e4b42a3092a10bfb76ab430455b2bf0cf7c4f7f32db1c2e" vout = 0 out_point = OutPoint(tx_id, vout) assert out_point.tx_id.hex() == tx_id assert out_point.vout == vout assert out_point.hash == int.from_bytes(out_point.tx_id, "big", signed=False) assert out_point.n == out_point.vout assert not out_point.is_coinbase() assert out_point == OutPoint.parse(out_point.serialize()) assert out_point == OutPoint.from_dict(out_point.to_dict())
def parse(cls: Type["TxIn"], data: BinaryData, check_validity: bool = True) -> "TxIn": stream = bytesio_from_binarydata(data) prev_out = OutPoint.parse(stream) script_sig = var_bytes.parse(stream) sequence = int.from_bytes(stream.read(4), byteorder="little", signed=False) return cls(prev_out, script_sig, sequence, Witness(), check_validity)