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

Function invoice_payment_hooks_done

lightningd/invoice.c:263–298  ·  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 if (payload->set)
277 htlc_set_fail(payload->set, NULL);
278 return;
279 }
280
281 /* Paid or expired in the meantime. */
282 if (!invoices_resolve(ld->wallet->invoices, inv_dbid, payload->msat,
283 payload->label, payload->outpoint)) {
284 if (payload->set)
285 htlc_set_fail(payload->set, NULL);
286 return;
287 }
288
289 log_info(ld->log, "Resolved invoice '%s' with amount %s in %zu htlcs",
290 payload->label->s,
291 fmt_amount_msat(tmpctx, payload->msat),
292 payload->set ? tal_count(payload->set->inpays) : 0);
293 if (payload->set)
294 htlc_set_fulfill(payload->set, &payload->preimage);
295
296 notify_invoice_payment(ld, payload->msat, &payload->preimage,
297 payload->label, payload->outpoint);
298}
299
300static bool
301invoice_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