| 261 | } |
| 262 | |
| 263 | static void |
| 264 | invoice_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 | |
| 299 | static bool |
| 300 | invoice_payment_deserialize(struct invoice_payment_hook_payload *payload, |
nothing calls this directly
no test coverage detected