1
0

transaction.py: TxOutpoint: nicer __str__ and __repr__

useful e.g. when TxOutpoint is used as key in a dict (and the dict is printed)
This commit is contained in:
SomberNight
2022-04-01 21:31:50 +02:00
parent 0226e7196d
commit 207600e00c

View File

@@ -194,6 +194,12 @@ class TxOutpoint(NamedTuple):
return TxOutpoint(txid=bfh(hash_str),
out_idx=int(idx_str))
def __str__(self) -> str:
return f"""TxOutpoint("{self.to_str()}")"""
def __repr__(self):
return f"<{str(self)}>"
def to_str(self) -> str:
return f"{self.txid.hex()}:{self.out_idx}"