fix: pylightning to_btc_str precision

The old codes if % 1000 statement logic was simply inverted
and produced the opposite output of the intention behin it.

Before Fix:
 - Millisatoshi('42sat').to_btc_str() => 0.00000042000btc
 - Millisatoshi('42001msat').to_btc_str() => 0.00000042btc

After  Fix:
 - Millisatoshi('42sat').to_btc_str() => 0.00000042btc
 - Millisatoshi('42001msat').to_btc_str() => 0.00000042001btc
This commit is contained in:
Michael Schmoock 2019-05-08 01:34:18 +02:00 committed by neil saitug
parent fefe7dfbab
commit 1e0aa9329d

View file

@ -81,9 +81,9 @@ class Millisatoshi:
Return a string of form 12.34567890btc or 12.34567890123btc. Return a string of form 12.34567890btc or 12.34567890123btc.
""" """
if self.millisatoshis % 1000: if self.millisatoshis % 1000:
return '{:.8f}btc'.format(self.to_btc())
else:
return '{:.11f}btc'.format(self.to_btc()) return '{:.11f}btc'.format(self.to_btc())
else:
return '{:.8f}btc'.format(self.to_btc())
def to_json(self): def to_json(self):
return self.__repr__() return self.__repr__()