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:
@@ -194,6 +194,12 @@ class TxOutpoint(NamedTuple):
|
|||||||
return TxOutpoint(txid=bfh(hash_str),
|
return TxOutpoint(txid=bfh(hash_str),
|
||||||
out_idx=int(idx_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:
|
def to_str(self) -> str:
|
||||||
return f"{self.txid.hex()}:{self.out_idx}"
|
return f"{self.txid.hex()}:{self.out_idx}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user