From f99c461fedaab78a74f96928188683987b3665c9 Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Mon, 29 Apr 2019 17:28:57 +0200 Subject: [PATCH] fix: pylightning msat round multiply and division Currently, when a multiplication operator is invoked that does not result in an even integer result but a floating result, the pylightning code will raise an exception: Millisatoshi must be string with msat/sat/btc suffix or int This is because the internal float result will be used as contructor argument like this: return Millisatoshi(10000.5) This happens especially on fee calculations where small uneven amounts are calculated. --- contrib/pylightning/lightning/lightning.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/pylightning/lightning/lightning.py b/contrib/pylightning/lightning/lightning.py index 70d71e4d0..a79a6ee95 100644 --- a/contrib/pylightning/lightning/lightning.py +++ b/contrib/pylightning/lightning/lightning.py @@ -113,10 +113,10 @@ class Millisatoshi: return Millisatoshi(int(self) - int(other)) def __mul__(self, other): - return Millisatoshi(int(self) * other) + return Millisatoshi(int(int(self) * other)) def __truediv__(self, other): - return Millisatoshi(int(self) / other) + return Millisatoshi(int(int(self) / other)) def __floordiv__(self, other): return Millisatoshi(int(self) // other)