Skip to content

Commit

Permalink
fix: pylightning msat round multiply and division
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
m-schmoock authored and cdecker committed Apr 29, 2019
1 parent f82e779 commit f99c461
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 @@ -113,10 +113,10 @@ def __sub__(self, other):
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)
Expand Down

0 comments on commit f99c461

Please sign in to comment.