mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
pyln-client: to_whole_satoshi returns the rounded up satoshi value
A fractional satoshi value isn't really useful; rounding up loses precision but that's why you called "whole satoshi", wasn't it? Changelog-Changed: pyln-client: Millisatoshi has new method, `to_whole_satoshi`; *rounds value up* to the nearest whole satoshi
This commit is contained in:
committed by
Christian Decker
parent
cce0020568
commit
e3a1d1a7f3
@@ -92,6 +92,13 @@ class Millisatoshi:
|
||||
"""
|
||||
return Decimal(self.millisatoshis) / 1000
|
||||
|
||||
def to_whole_satoshi(self) -> int:
|
||||
"""
|
||||
Return an int respresenting the number of satoshis;
|
||||
rounded up to the nearest satoshi
|
||||
"""
|
||||
return (self.millisatoshis + 999) // 1000
|
||||
|
||||
def to_btc(self) -> Decimal:
|
||||
"""
|
||||
Return a Decimal representing the number of bitcoin.
|
||||
|
||||
Reference in New Issue
Block a user