renepay: bug fix, local channel information

Listpeerchannels would update the local channel information setting the
liquidity in the outgoing channel to known_min=known_max=capacity,
when in fact it should be known_min=known_max=spendable.
This commit is contained in:
Lagrang3 2024-05-06 09:45:12 +01:00 committed by Rusty Russell
parent 4adf9b4080
commit 16d00e09ef
3 changed files with 44 additions and 6 deletions

View file

@ -484,9 +484,13 @@ static void gossmod_cb(struct gossmap_localmods *mods,
payment_disable_chan(payment, scidd->scid, LOG_DBG,
"listpeerchannels says not enabled");
/* Also update the uncertainty network */
uncertainty_update_from_listpeerchannels(pay_plugin->uncertainty, scidd, max,
enabled, buf, chantok);
/* Also update the uncertainty network by fixing the liquidity of the
* outgoing channel. If we try to set the liquidity of the incoming
* channel as well we would have conflicting information because our
* knowledge model does not take into account channel reserves. */
if (scidd->dir == node_id_idx(self, peer))
uncertainty_update_from_listpeerchannels(
pay_plugin->uncertainty, scidd, max, enabled, buf, chantok);
}
static struct command_result *getmychannels_done(struct command *cmd,

28
tests/plugins/no_fail.py Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env python3
"""Plugin that breaks the node if a fail notification is received.
"""
from pyln.client import Plugin, RpcError
import os
plugin = Plugin()
@plugin.init()
def init(plugin, options, configuration):
plugin.log("no_fail initialized")
@plugin.subscribe("sendpay_failure")
def channel_opened(plugin, sendpay_failure, **kwargs):
os._exit(1)
@plugin.method("nofail")
def nofail(plugin):
"""Checks that the plugin is still running.
"""
return {"status": "active"}
plugin.run()

View file

@ -435,11 +435,14 @@ def test_fee_allocation(node_factory):
| |
3----4
This a payment that fails if fee is not allocated as part of the flow
constraints.
constraints. The payment should be straightforward, no failures are
expected.
"""
# High fees at 3%
# We set high fees at 3% and load a plugin that breaks if a sendpay_failure
# notification is received.
opts = [
{"disable-mpp": None, "fee-base": 1000, "fee-per-satoshi": 30000},
{"disable-mpp": None, "fee-base": 1000, "fee-per-satoshi": 30000,
'plugin': os.path.join(os.getcwd(), 'tests/plugins/no_fail.py')},
]
l1, l2, l3, l4 = node_factory.get_nodes(4, opts=opts * 4)
start_channels(
@ -452,6 +455,9 @@ def test_fee_allocation(node_factory):
invoice = only_one(l4.rpc.listinvoices("inv")["invoices"])
assert invoice["amount_received_msat"] >= Millisatoshi("1500000sat")
# is the no_fail.py plugin still running?
l1.rpc.call("nofail")
def test_htlc_max(node_factory):
"""