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

Function peer_got_commitsig

lightningd/peer_htlcs.c:2393–2545  ·  view source on GitHub ↗

This also implies we're sending revocation */

Source from the content-addressed store, hash-verified

2391
2392/* This also implies we're sending revocation */
2393void peer_got_commitsig(struct channel *channel, const u8 *msg)
2394{
2395 u64 commitnum;
2396 struct fee_states *fee_states;
2397 struct height_states *blockheight_states;
2398 struct bitcoin_signature commit_sig, *htlc_sigs;
2399 struct added_htlc **added;
2400 struct fulfilled_htlc *fulfilled;
2401 struct failed_htlc **failed;
2402 struct changed_htlc *changed;
2403 struct bitcoin_tx *tx;
2404 struct commitsig **inflight_commit_sigs;
2405 struct channel_inflight *inflight;
2406 size_t i;
2407 struct lightningd *ld = channel->peer->ld;
2408
2409 if (!fromwire_channeld_got_commitsig(msg, msg,
2410 &commitnum,
2411 &fee_states,
2412 &blockheight_states,
2413 &commit_sig,
2414 &htlc_sigs,
2415 &added,
2416 &fulfilled,
2417 &failed,
2418 &changed,
2419 &tx,
2420 &inflight_commit_sigs)
2421 || !fee_states_valid(fee_states, channel->opener)
2422 || !height_states_valid(blockheight_states, channel->opener)) {
2423 channel_internal_error(channel,
2424 "bad fromwire_channeld_got_commitsig %s",
2425 tal_hex(channel, msg));
2426 return;
2427 }
2428
2429 /* If we're not synced with bitcoin network, we can't accept
2430 * any new HTLCs. We stall at this point, in the hope that it
2431 * won't take long! */
2432 if (added && !topology_synced(ld->topology)) {
2433 struct deferred_commitsig *d;
2434
2435 log_unusual(channel->log,
2436 "Deferring incoming commit until we sync");
2437
2438 /* If subdaemon dies, we want to forget this. */
2439 d = tal(channel->owner, struct deferred_commitsig);
2440 d->channel = channel;
2441 d->msg = tal_dup_talarr(d, u8, msg);
2442 topology_add_sync_waiter(d, ld->topology,
2443 retry_deferred_commitsig, d);
2444 return;
2445 }
2446
2447 tx->chainparams = chainparams;
2448
2449 log_debug(channel->log,
2450 "got commitsig %"PRIu64

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