From bdd19f82a8a05ac268ed854efd0e9ec6044a0a4d Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Mon, 2 Sep 2019 14:27:40 +0200 Subject: [PATCH] sendinvoiceless: round HTLC fees up --- sendinvoiceless/sendinvoiceless.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sendinvoiceless/sendinvoiceless.py b/sendinvoiceless/sendinvoiceless.py index 9a9057f..f5afe62 100755 --- a/sendinvoiceless/sendinvoiceless.py +++ b/sendinvoiceless/sendinvoiceless.py @@ -15,7 +15,8 @@ def setup_routing_fees(plugin, route, msatoshi, payload): channels = plugin.rpc.listchannels(r['channel']) ch = next(c for c in channels.get('channels') if c['destination'] == r['id']) fee = Millisatoshi(ch['base_fee_millisatoshi']) - fee += msatoshi * ch['fee_per_millionth'] // 10**6 + # BOLT #7 requires fee >= fee_base_msat + ( amount_to_forward * fee_proportional_millionths / 1000000 ) + fee += (msatoshi * ch['fee_per_millionth'] + 999_999) // 1_000_000 # integer math trick to round up if ch['source'] == payload['nodeid']: fee += payload['msatoshi'] msatoshi += fee