mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-19 21:14:38 +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:
committed by
Christian Decker
parent
09a96739b3
commit
6f46010417
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user