From 847208f5d80cffea30482cfca561609266be8dff Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 14 May 2024 21:11:10 +0930 Subject: [PATCH] offers: put correct CLTV limit inside blinded paths. At plugin startup, we don't have an accurate blockheight and can get 0! Fixes: https://github.com/ElementsProject/lightning/issues/7161 Reported-by: @carlaKC Signed-off-by: Rusty Russell --- lightningd/peer_htlcs.c | 3 ++- plugins/offers.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index c0fcfe28c..4236dc755 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -1102,7 +1102,8 @@ htlc_accepted_hook_final(struct htlc_accepted_hook_payload *request STEALS) /* *Now* we barf if it failed to decode */ if (!request->payload) { log_debug(channel->log, - "Failing HTLC because of an invalid payload"); + "Failing HTLC because of an invalid payload (TLV %"PRIu64" pos %zu)", + request->failtlvtype, request->failtlvpos); local_fail_in_htlc(hin, take(towire_invalid_onion_payload( NULL, request->failtlvtype, diff --git a/plugins/offers.c b/plugins/offers.c index 9b2fa26d5..03360d1a5 100644 --- a/plugins/offers.c +++ b/plugins/offers.c @@ -1227,8 +1227,12 @@ static const char *init(struct plugin *p, { rpc_scan(p, "getinfo", take(json_out_obj(NULL, NULL, NULL)), - "{id:%}", JSON_SCAN(json_to_pubkey, &id), - "{blockheight:%}", JSON_SCAN(json_to_u32, &blockheight)); + "{id:%}", JSON_SCAN(json_to_pubkey, &id)); + + rpc_scan(p, "getchaininfo", + take(json_out_obj(NULL, "last_height", "0")), + "{headercount:%}", JSON_SCAN(json_to_u32, &blockheight)); + assert(blockheight); rpc_scan(p, "listconfigs", take(json_out_obj(NULL, NULL, NULL)),