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
This commit is contained in:
Michael Schmoock
2022-12-27 12:56:16 +01:00
parent ec75211f0a
commit 81899006e2

View File

@@ -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