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

Function update_out_htlc

lightningd/peer_htlcs.c:2081–2121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2079}
2080
2081static bool update_out_htlc(struct channel *channel,
2082 u64 id, enum htlc_state newstate)
2083{
2084 struct lightningd *ld = channel->peer->ld;
2085 struct htlc_out *hout;
2086
2087 hout = find_htlc_out(ld->htlcs_out, channel, id);
2088 if (!hout) {
2089 channel_internal_error(channel, "Can't find out HTLC %"PRIu64, id);
2090 return false;
2091 }
2092
2093 if (!hout->dbid) {
2094 wallet_htlc_save_out(ld->wallet, channel, hout);
2095 /* Update channel stats */
2096 channel_stats_incr_out_offered(channel, hout->msat);
2097
2098 if (hout->in) {
2099 struct short_channel_id scid;
2100 scid = channel_scid_or_local_alias(channel);
2101
2102 wallet_forwarded_payment_add(ld->wallet, hout->in,
2103 FORWARD_STYLE_TLV,
2104 &scid, hout,
2105 FORWARD_OFFERED, 0);
2106 }
2107 }
2108
2109 if (!htlc_out_update_state(channel, hout, newstate))
2110 return false;
2111
2112 /* First transition into commitment; now it outlives peer. */
2113 if (newstate == SENT_ADD_COMMIT) {
2114 tal_del_destructor(hout, destroy_hout_subd_died);
2115 hout->timeout = tal_free(hout->timeout);
2116 tal_steal(ld, hout);
2117 } else if (newstate == RCVD_REMOVE_ACK_REVOCATION) {
2118 remove_htlc_out(channel, hout);
2119 }
2120 return true;
2121}
2122
2123static bool changed_htlc(struct channel *channel,
2124 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