From 207600e00cdff7e6a08ec21daddccda8d10162e7 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 1 Apr 2022 21:31:50 +0200 Subject: [PATCH] transaction.py: TxOutpoint: nicer __str__ and __repr__ useful e.g. when TxOutpoint is used as key in a dict (and the dict is printed) --- electrum/transaction.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/electrum/transaction.py b/electrum/transaction.py index 7e4d206ce..1f18cee6a 100644 --- a/electrum/transaction.py +++ b/electrum/transaction.py @@ -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}"