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

Function invoice_payment_hooks_done

lightningd/invoice.c:263–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263static void
264invoice_payment_hooks_done(struct invoice_payment_hook_payload *payload STEALS)
265{
266 u64 inv_dbid;
267 struct lightningd *ld = payload->ld;
268
269 tal_del_destructor2(payload->set, invoice_payload_remove_set, payload);
270 /* We want to free this, whatever happens. */
271 tal_steal(tmpctx, payload);
272
273 /* If invoice gets paid meanwhile (plugin responds out-of-order?) then
274 * we can also fail */
275 if (!invoices_find_by_label(ld->wallet->invoices, &inv_dbid, payload->label)) {
276 htlc_set_fail(payload->set, NULL);
277 return;
278 }
279
280 /* Paid or expired in the meantime. */
281 if (!invoices_resolve(ld->wallet->invoices, inv_dbid, payload->msat,
282 payload->label, payload->outpoint)) {
283 if (payload->set)
284 htlc_set_fail(payload->set, NULL);
285 return;
286 }
287
288 log_info(ld->log, "Resolved invoice '%s' with amount %s in %zu htlcs",
289 payload->label->s,
290 fmt_amount_msat(tmpctx, payload->msat),
291 payload->set ? tal_count(payload->set->inpays) : 0);
292 if (payload->set)
293 htlc_set_fulfill(payload->set, &payload->preimage);
294
295 notify_invoice_payment(ld, payload->msat, &payload->preimage,
296 payload->label, payload->outpoint);
297}
298
299static bool
300invoice_payment_deserialize(struct invoice_payment_hook_payload *payload,

Callers

nothing calls this directly

Calls 6

log_infoClass · 0.85
htlc_set_fulfillFunction · 0.70
notify_invoice_paymentFunction · 0.70
invoices_find_by_labelFunction · 0.50
invoices_resolveFunction · 0.50
fmt_amount_msatFunction · 0.50

Tested by

no test coverage detected