From 71c45dc55c85b2f133430165b291053e3a38b16e Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 17 Mar 2021 13:22:17 +0100 Subject: [PATCH] plugin: Call invoice_payment hook before the matching notification As @fiatjaf points out we were notifying before we were actually set on accepting, since the hook could also still reject. Switched them around does and calling the notification only once it's been decided is the correct thing to do. Changelog-Fixed: plugin: The `invoice_payment` notification was being sent before the hook was called, which could still abort it. Suggested-by: Fiatjaf <@fiatjaf> Signed-off-by: Christian Decker <@cdecker> --- lightningd/invoice.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lightningd/invoice.c b/lightningd/invoice.c index b7e3b372c..d3f4744bb 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -287,6 +287,9 @@ invoice_payment_hooks_done(struct invoice_payment_hook_payload *payload STEALS) type_to_string(tmpctx, struct amount_msat, &payload->msat), tal_count(payload->set->htlcs)); htlc_set_fulfill(payload->set, &payload->preimage); + + notify_invoice_payment(ld, payload->msat, payload->preimage, + payload->label); } static bool @@ -431,8 +434,6 @@ void invoice_try_pay(struct lightningd *ld, payload->set = set; tal_add_destructor2(set, invoice_payload_remove_set, payload); - notify_invoice_payment(ld, payload->msat, payload->preimage, payload->label); - plugin_hook_call_invoice_payment(ld, payload); }