From 46683f4ef435df5ce6343d5dc0e7440f6f4c0b75 Mon Sep 17 00:00:00 2001 From: wqxoxo Date: Mon, 17 Nov 2025 18:07:55 +0000 Subject: [PATCH] Fix BOLT11 annotation loss after sendonion failure Fixes #6978 where bolt11 annotations were lost when sendonion failed early and payment was retried. When sendonion RPC fails before saving payment to database, invstring_used flag would remain true, causing retry attempts to omit bolt11 parameter. Successful retries would then save to DB without bolt11 annotation. Move invstring_used flag setting from payment_createonion_success to payment_sendonion_success. This ensures the flag is only set after sendonion actually succeeds. The bolt11 will be sent with every sendonion attempt until the first successful one, accepting the minor redundancy for cleaner state management. --- plugins/libplugin-pay.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index 58deb4d0aaea..80d269682f30 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -1703,6 +1703,11 @@ static struct command_result *payment_sendonion_success(struct command *cmd, struct payment *p) { struct out_req *req; + struct payment *root = payment_root(p); + + if (p->invstring) + root->invstring_used = true; + req = jsonrpc_request_start(payment_cmd(p), "waitsendpay", payment_waitsendpay_finished, payment_waitsendpay_finished, p); @@ -1765,8 +1770,6 @@ static struct command_result *payment_createonion_success(struct command *cmd, if (p->description) json_add_string(req->js, "description", p->description); - - root->invstring_used = true; } if (p->pay_destination)