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

Function tell_if_missing

lightningd/onchain_control.c:90–129  ·  view source on GitHub ↗

If we want to know if this HTLC is missing, return depth. */

Source from the content-addressed store, hash-verified

88
89/* If we want to know if this HTLC is missing, return depth. */
90static bool tell_if_missing(const struct channel *channel,
91 struct htlc_stub *stub,
92 bool *tell_immediate)
93{
94 struct htlc_out *hout;
95
96 /* Keep valgrind happy. */
97 *tell_immediate = false;
98
99 /* Don't care about incoming HTLCs, just ones we offered. */
100 if (stub->owner == REMOTE)
101 return false;
102
103 /* Might not be a current HTLC. */
104 hout = find_htlc_out(channel->peer->ld->htlcs_out, channel, stub->id);
105 if (!hout)
106 return false;
107
108 /* BOLT #5:
109 *
110 * - for any committed HTLC that does NOT have an output in this
111 * commitment transaction:
112 * - if the payment preimage is known:
113 * - MUST fulfill the corresponding incoming HTLC (if any).
114 * - otherwise:
115 * - once the commitment transaction has reached reasonable depth:
116 * - MUST fail the corresponding incoming HTLC (if any).
117 * - if no *valid* commitment transaction contains an output
118 * corresponding to the HTLC:
119 * - MAY fail the corresponding incoming HTLC sooner.
120 */
121 if (hout->hstate >= RCVD_ADD_REVOCATION
122 && hout->hstate < SENT_REMOVE_REVOCATION)
123 *tell_immediate = true;
124
125 log_debug(channel->log,
126 "We want to know if htlc %"PRIu64" is missing (%s)",
127 hout->key.id, *tell_immediate ? "immediate" : "later");
128 return true;
129}
130
131static void handle_onchain_init_reply(struct channel *channel, const u8 *msg)
132{

Callers 1

Calls 1

find_htlc_outFunction · 0.85

Tested by

no test coverage detected