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

Function fulfill_htlc

lightningd/peer_htlcs.c:429–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427}
428
429void fulfill_htlc(struct htlc_in *hin, const struct preimage *preimage)
430{
431 u8 *msg;
432 struct channel *channel = hin->key.channel;
433
434 if (hin->hstate != RCVD_ADD_ACK_REVOCATION) {
435 log_debug(channel->log,
436 "HTLC fulfilled, but not ready any more (%s).",
437 htlc_state_name(hin->hstate));
438 return;
439 }
440
441 hin->preimage = tal_dup(hin, struct preimage, preimage);
442
443 /* We update state now to signal it's in progress, for persistence. */
444 htlc_in_update_state(channel, hin, SENT_REMOVE_HTLC);
445
446 htlc_in_check(hin, __func__);
447
448 /* Update channel stats */
449 channel_stats_incr_in_fulfilled(channel, hin->msat);
450
451 /* No owner? We'll either send to channeld in peer_htlcs, or
452 * onchaind in onchaind_tell_fulfill. */
453 if (!channel->owner) {
454 log_debug(channel->log, "HTLC fulfilled, but no owner.");
455 return;
456 }
457
458 if (streq(channel->owner->name, "onchaind")) {
459 msg = towire_onchaind_known_preimage(hin, preimage);
460 } else {
461 struct fulfilled_htlc fulfilled_htlc;
462 fulfilled_htlc.id = hin->key.id;
463 fulfilled_htlc.payment_preimage = *preimage;
464 msg = towire_channeld_fulfill_htlc(hin, &fulfilled_htlc);
465 }
466 subd_send_msg(channel->owner, take(msg));
467}
468
469/* HTLC-specific wrappers */
470static void htlc_set_fulfill_htlc(struct htlc_in *hin,

Callers 4

htlc_set_fulfill_htlcFunction · 0.70
fulfill_our_htlc_outFunction · 0.70
check_already_failedFunction · 0.70

Calls 7

htlc_in_update_stateFunction · 0.85
htlc_in_checkFunction · 0.70
subd_send_msgFunction · 0.70
htlc_state_nameFunction · 0.50

Tested by

no test coverage detected