MCPcopy Create free account
hub / github.com/ElementsProject/lightning / invoice_payment_hooks_done

Function invoice_payment_hooks_done

lightningd/invoice.c:304–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304static void
305invoice_payment_hooks_done(struct invoice_payment_hook_payload *payload STEALS)
306{
307 struct invoice invoice;
308 struct lightningd *ld = payload->ld;
309
310 tal_del_destructor2(payload->set, invoice_payload_remove_set, payload);
311 /* We want to free this, whatever happens. */
312 tal_steal(tmpctx, payload);
313
314 /* If invoice gets paid meanwhile (plugin responds out-of-order?) then
315 * we can also fail */
316 if (!wallet_invoice_find_by_label(ld->wallet, &invoice, payload->label)) {
317 htlc_set_fail(payload->set, take(failmsg_incorrect_or_unknown(
318 NULL, ld, payload->set->htlcs[0])));
319 return;
320 }
321
322 /* Paid or expired in the meantime. */
323 if (!wallet_invoice_resolve(ld->wallet, invoice, payload->msat)) {
324 htlc_set_fail(payload->set, take(failmsg_incorrect_or_unknown(
325 NULL, ld, payload->set->htlcs[0])));
326 return;
327 }
328
329 log_info(ld->log, "Resolved invoice '%s' with amount %s in %zu htlcs",
330 payload->label->s,
331 type_to_string(tmpctx, struct amount_msat, &payload->msat),
332 tal_count(payload->set->htlcs));
333 htlc_set_fulfill(payload->set, &payload->preimage);
334
335 notify_invoice_payment(ld, payload->msat, payload->preimage,
336 payload->label);
337}
338
339static bool
340invoice_payment_deserialize(struct invoice_payment_hook_payload *payload,

Callers

nothing calls this directly

Calls 7

log_infoClass · 0.85
htlc_set_failFunction · 0.70
htlc_set_fulfillFunction · 0.70
notify_invoice_paymentFunction · 0.70
wallet_invoice_resolveFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected