| 302 | } |
| 303 | |
| 304 | static void |
| 305 | invoice_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 | |
| 339 | static bool |
| 340 | invoice_payment_deserialize(struct invoice_payment_hook_payload *payload, |
nothing calls this directly
no test coverage detected