mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 22:31:48 +01:00
pyln-client: make Millisatoshi comparable to int
This often helps the msat purge and pyln msat replacement mischmasch issues. I changed it in a way that the `AttributeError: 'int' object has no attribute 'millisatoshis'` Error will still be raised whever a `Millisatoshi` is compared to something else then a `Millisatoshi` or `int`. Changelog-None
This commit is contained in:
parent
09a96739b3
commit
6f46010417
1 changed files with 8 additions and 0 deletions
|
@ -163,9 +163,13 @@ class Millisatoshi:
|
|||
return self.millisatoshis
|
||||
|
||||
def __lt__(self, other: 'Millisatoshi') -> bool:
|
||||
if isinstance(other, int):
|
||||
return self.millisatoshis < other
|
||||
return self.millisatoshis < other.millisatoshis
|
||||
|
||||
def __le__(self, other: 'Millisatoshi') -> bool:
|
||||
if isinstance(other, int):
|
||||
return self.millisatoshis <= other
|
||||
return self.millisatoshis <= other.millisatoshis
|
||||
|
||||
def __eq__(self, other: object) -> bool:
|
||||
|
@ -177,9 +181,13 @@ class Millisatoshi:
|
|||
return False
|
||||
|
||||
def __gt__(self, other: 'Millisatoshi') -> bool:
|
||||
if isinstance(other, int):
|
||||
return self.millisatoshis > other
|
||||
return self.millisatoshis > other.millisatoshis
|
||||
|
||||
def __ge__(self, other: 'Millisatoshi') -> bool:
|
||||
if isinstance(other, int):
|
||||
return self.millisatoshis >= other
|
||||
return self.millisatoshis >= other.millisatoshis
|
||||
|
||||
def __add__(self, other: 'Millisatoshi') -> 'Millisatoshi':
|
||||
|
|
Loading…
Add table
Reference in a new issue