| 2105 | } |
| 2106 | |
| 2107 | static bool update_out_htlc(struct channel *channel, |
| 2108 | u64 id, enum htlc_state newstate) |
| 2109 | { |
| 2110 | struct lightningd *ld = channel->peer->ld; |
| 2111 | struct htlc_out *hout; |
| 2112 | |
| 2113 | hout = find_htlc_out(ld->htlcs_out, channel, id); |
| 2114 | if (!hout) { |
| 2115 | channel_internal_error(channel, "Can't find out HTLC %"PRIu64, id); |
| 2116 | return false; |
| 2117 | } |
| 2118 | |
| 2119 | if (!hout->dbid) { |
| 2120 | wallet_htlc_save_out(ld->wallet, channel, hout); |
| 2121 | /* Update channel stats */ |
| 2122 | channel_stats_incr_out_offered(channel, hout->msat); |
| 2123 | |
| 2124 | if (hout->in) { |
| 2125 | struct short_channel_id scid; |
| 2126 | scid = channel_scid_or_local_alias(channel); |
| 2127 | |
| 2128 | wallet_forwarded_payment_add(ld->wallet, hout->in, |
| 2129 | FORWARD_STYLE_TLV, |
| 2130 | &scid, hout, |
| 2131 | FORWARD_OFFERED, 0); |
| 2132 | } |
| 2133 | } |
| 2134 | |
| 2135 | if (!htlc_out_update_state(channel, hout, newstate)) |
| 2136 | return false; |
| 2137 | |
| 2138 | /* First transition into commitment; now it outlives peer. */ |
| 2139 | if (newstate == SENT_ADD_COMMIT) { |
| 2140 | tal_del_destructor(hout, destroy_hout_subd_died); |
| 2141 | hout->timeout = tal_free(hout->timeout); |
| 2142 | tal_steal(ld, hout); |
| 2143 | } else if (newstate == RCVD_REMOVE_ACK_REVOCATION) { |
| 2144 | remove_htlc_out(channel, hout); |
| 2145 | } |
| 2146 | return true; |
| 2147 | } |
| 2148 | |
| 2149 | static bool changed_htlc(struct channel *channel, |
| 2150 | const struct changed_htlc *changed) |
no test coverage detected