From 83a21138b8e994a51025d130d32cf2b1cc624d56 Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Tue, 1 Dec 2020 13:38:43 +0100 Subject: [PATCH] pyln: fix msat from float str Changelog-fixed: pyln: parsing msat from a float string --- contrib/pyln-client/pyln/client/lightning.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/pyln-client/pyln/client/lightning.py b/contrib/pyln-client/pyln/client/lightning.py index 4a7ee33f0..febc4b944 100644 --- a/contrib/pyln-client/pyln/client/lightning.py +++ b/contrib/pyln-client/pyln/client/lightning.py @@ -49,19 +49,19 @@ class Millisatoshi: """ if isinstance(v, str): if v.endswith("msat"): - self.millisatoshis = int(v[0:-4]) + parsed = Decimal(v[0:-4]) elif v.endswith("sat"): - self.millisatoshis = int(v[0:-3]) * 1000 + parsed = Decimal(v[0:-3]) * 1000 elif v.endswith("btc"): - self.millisatoshis = int(v[0:-3]) * 1000 * 10**8 + parsed = Decimal(v[0:-3]) * 1000 * 10**8 else: raise TypeError( "Millisatoshi must be string with msat/sat/btc suffix or" " int" ) - if self.millisatoshis != int(self.millisatoshis): + if parsed != int(parsed): raise ValueError("Millisatoshi must be a whole number") - self.millisatoshis = int(self.millisatoshis) + self.millisatoshis = int(parsed) elif isinstance(v, Millisatoshi): self.millisatoshis = v.millisatoshis