Skip to content

Commit

Permalink
fix: pylightning to_btc_str precision
Browse files Browse the repository at this point in the history
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
  • Loading branch information
m-schmoock authored and niftynei committed May 8, 2019
1 parent fefe7df commit 1e0aa93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contrib/pylightning/lightning/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def to_btc_str(self):
Return a string of form 12.34567890btc or 12.34567890123btc.
"""
if self.millisatoshis % 1000:
return '{:.8f}btc'.format(self.to_btc())
else:
return '{:.11f}btc'.format(self.to_btc())
else:
return '{:.8f}btc'.format(self.to_btc())

def to_json(self):
return self.__repr__()
Expand Down

0 comments on commit 1e0aa93

Please sign in to comment.