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

Function peer_got_commitsig

lightningd/peer_htlcs.c:2152–2264  ·  view source on GitHub ↗

This also implies we're sending revocation */

Source from the content-addressed store, hash-verified

2150
2151/* This also implies we're sending revocation */
2152void peer_got_commitsig(struct channel *channel, const u8 *msg)
2153{
2154 u64 commitnum;
2155 struct fee_states *fee_states;
2156 struct height_states *blockheight_states;
2157 struct bitcoin_signature commit_sig, *htlc_sigs;
2158 struct added_htlc *added;
2159 struct fulfilled_htlc *fulfilled;
2160 struct failed_htlc **failed;
2161 struct changed_htlc *changed;
2162 struct bitcoin_tx *tx;
2163 size_t i;
2164 struct lightningd *ld = channel->peer->ld;
2165
2166 if (!fromwire_channeld_got_commitsig(msg, msg,
2167 &commitnum,
2168 &fee_states,
2169 &blockheight_states,
2170 &commit_sig,
2171 &htlc_sigs,
2172 &added,
2173 &fulfilled,
2174 &failed,
2175 &changed,
2176 &tx)
2177 || !fee_states_valid(fee_states, channel->opener)
2178 || !height_states_valid(blockheight_states, channel->opener)) {
2179 channel_internal_error(channel,
2180 "bad fromwire_channeld_got_commitsig %s",
2181 tal_hex(channel, msg));
2182 return;
2183 }
2184
2185 /* If we're not synced with bitcoin network, we can't accept
2186 * any new HTLCs. We stall at this point, in the hope that it
2187 * won't take long! */
2188 if (added && !topology_synced(ld->topology)) {
2189 struct deferred_commitsig *d;
2190
2191 log_unusual(channel->log,
2192 "Deferring incoming commit until we sync");
2193
2194 /* If subdaemon dies, we want to forget this. */
2195 d = tal(channel->owner, struct deferred_commitsig);
2196 d->channel = channel;
2197 d->msg = tal_dup_talarr(d, u8, msg);
2198 topology_add_sync_waiter(d, ld->topology,
2199 retry_deferred_commitsig, d);
2200 return;
2201 }
2202
2203 tx->chainparams = chainparams;
2204
2205 log_debug(channel->log,
2206 "got commitsig %"PRIu64
2207 ": feerate %u, blockheight: %u, %zu added, %zu fulfilled, %zu failed, %zu changed",
2208 commitnum, get_feerate(fee_states, channel->opener, LOCAL),
2209 get_blockheight(blockheight_states, channel->opener, LOCAL),

Callers 2

retry_deferred_commitsigFunction · 0.85
channel_msgFunction · 0.85

Calls 15

fee_states_validFunction · 0.85
height_states_validFunction · 0.85
tal_hexFunction · 0.85
topology_syncedFunction · 0.85
get_blockheightFunction · 0.85
channel_added_their_htlcFunction · 0.85
peer_fulfilled_our_htlcFunction · 0.85
peer_failed_our_htlcFunction · 0.85
tal_freeFunction · 0.85
peer_sending_revocationFunction · 0.85

Tested by

no test coverage detected