From 81899006e2cb20b5853babb7a4100c04267a0ed7 Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Tue, 27 Dec 2022 12:56:16 +0100 Subject: [PATCH] feeadjuster: fix forward_event hook msat parsing Subscribed notifications have never been handled by `pyln.client.Plugin()` in a way that for `_msat` keys values have been replaced by `Millisatoshi()` on the fly. This only was the case for normal JSON request/responses. On recent cln versions, having `--allow-deprecated-apis=True`, cln actually returns a string ending with `msat`, which is not compatible with a `Millisatoshi()` when doing arithmetic operations. See: https://github.com/ElementsProject/lightning/pull/5798 --- feeadjuster/feeadjuster.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/feeadjuster/feeadjuster.py b/feeadjuster/feeadjuster.py index 992ab2d..a1376c5 100755 --- a/feeadjuster/feeadjuster.py +++ b/feeadjuster/feeadjuster.py @@ -214,11 +214,11 @@ def forward_event(plugin: Plugin, forward_event: dict, **kwargs): maybe_add_new_balances(plugin, [in_scid, out_scid]) if plugin.rpcversion[0] == 0 and plugin.rpcversion[1] < 12: - plugin.adj_balances[in_scid]["our"] += int(forward_event["in_msatoshi"]) - plugin.adj_balances[out_scid]["our"] -= int(forward_event["out_msatoshi"]) + plugin.adj_balances[in_scid]["our"] += int(Millisatoshi(forward_event["in_msatoshi"])) + plugin.adj_balances[out_scid]["our"] -= int(Millisatoshi(forward_event["out_msatoshi"])) else: - plugin.adj_balances[in_scid]["our"] += int(forward_event["in_msat"]) - plugin.adj_balances[out_scid]["our"] -= int(forward_event["out_msat"]) + plugin.adj_balances[in_scid]["our"] += int(Millisatoshi(forward_event["in_msat"])) + plugin.adj_balances[out_scid]["our"] -= int(Millisatoshi(forward_event["out_msat"])) try: # Pseudo-randomly add some hysterisis to the update