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:
Michael Schmoock 2022-12-28 18:44:25 +01:00 committed by Christian Decker
parent 09a96739b3
commit 6f46010417

View file

@ -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':