From 685c413b61cd9ecf5a1fb7d99234db1fd598b70f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 18 Aug 2023 17:13:25 +0930 Subject: [PATCH] renepay: reduce minimum "known" if it proves incorrect. There's a fascinating bug report which suggests this happens on local channels, implying spendable_msat is wrong? See-also: #6567 Signed-off-by: Rusty Russell --- plugins/renepay/flow.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/renepay/flow.c b/plugins/renepay/flow.c index ed65beb93..97523dceb 100644 --- a/plugins/renepay/flow.c +++ b/plugins/renepay/flow.c @@ -178,7 +178,15 @@ void chan_extra_cannot_send( x = AMOUNT_MSAT(0); } - ce->half[dir].known_min = amount_msat_min(ce->half[dir].known_min,x); + /* If we "knew" the capacity was at least this, we just showed we're wrong! */ + if (amount_msat_less_eq(x, ce->half[dir].known_min)) { + debug_paynote(p, "Expected scid=%s, dir=%d min %s, but %s failed! Setting min to 0", + type_to_string(tmpctx,struct short_channel_id,&scid), + dir, + type_to_string(tmpctx,struct amount_msat,&ce->half[dir].known_min), + type_to_string(tmpctx,struct amount_msat,&x)); + ce->half[dir].known_min = AMOUNT_MSAT(0); + } ce->half[dir].known_max = amount_msat_min(ce->half[dir].known_max,x); debug_paynote(p,"Update chan knowledge scid=%s, dir=%d: [%s,%s]",