| 2149 | } |
| 2150 | |
| 2151 | static 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 | |
| 2193 | static bool changed_htlc(struct channel *channel, |
| 2194 | const struct changed_htlc *changed) |
no test coverage detected