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

Function update_out_htlc

lightningd/peer_htlcs.c:2151–2191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2149}
2150
2151static bool update_out_htlc(struct channel *channel,
2152 u64 id, enum htlc_state newstate)
2153{
2154 struct lightningd *ld = channel->peer->ld;
2155 struct htlc_out *hout;
2156
2157 hout = find_htlc_out(ld->htlcs_out, channel, id);
2158 if (!hout) {
2159 channel_internal_error(channel, "Can't find out HTLC %"PRIu64, id);
2160 return false;
2161 }
2162
2163 if (!hout->dbid) {
2164 wallet_htlc_save_out(ld->wallet, channel, hout);
2165 /* Update channel stats */
2166 channel_stats_incr_out_offered(channel, hout->msat);
2167
2168 if (hout->in) {
2169 struct short_channel_id scid;
2170 scid = channel_scid_or_local_alias(channel);
2171
2172 wallet_forwarded_payment_add(ld->wallet, hout->in,
2173 FORWARD_STYLE_TLV,
2174 &scid, hout,
2175 FORWARD_OFFERED, 0);
2176 }
2177 }
2178
2179 if (!htlc_out_update_state(channel, hout, newstate))
2180 return false;
2181
2182 /* First transition into commitment; now it outlives peer. */
2183 if (newstate == SENT_ADD_COMMIT) {
2184 tal_del_destructor(hout, destroy_hout_subd_died);
2185 hout->timeout = tal_free(hout->timeout);
2186 tal_steal(ld, hout);
2187 } else if (newstate == RCVD_REMOVE_ACK_REVOCATION) {
2188 remove_htlc_out(channel, hout);
2189 }
2190 return true;
2191}
2192
2193static bool changed_htlc(struct channel *channel,
2194 const struct changed_htlc *changed)

Callers 2

changed_htlcFunction · 0.85
peer_sending_revocationFunction · 0.85

Calls 9

find_htlc_outFunction · 0.85
wallet_htlc_save_outFunction · 0.85
htlc_out_update_stateFunction · 0.85
tal_freeFunction · 0.85
remove_htlc_outFunction · 0.85
channel_internal_errorFunction · 0.70

Tested by

no test coverage detected