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

Function peer_got_commitsig

lightningd/peer_htlcs.c:2473–2641  ·  view source on GitHub ↗

This also implies we're sending revocation */

Source from the content-addressed store, hash-verified

2471
2472/* This also implies we're sending revocation */
2473void peer_got_commitsig(struct channel *channel, const u8 *msg)
2474{
2475 u64 commitnum;
2476 struct fee_states *fee_states;
2477 struct height_states *blockheight_states;
2478 struct bitcoin_signature commit_sig, *htlc_sigs;
2479 struct added_htlc **added;
2480 struct fulfilled_htlc *fulfilled;
2481 struct failed_htlc **failed;
2482 struct changed_htlc *changed;
2483 struct bitcoin_tx *tx;
2484 struct commitsig **inflight_commit_sigs;
2485 struct channel_inflight *inflight;
2486 size_t i;
2487 u64 next_their_htlc_id;
2488 struct lightningd *ld = channel->peer->ld;
2489
2490 if (!fromwire_channeld_got_commitsig(msg, msg,
2491 &commitnum,
2492 &fee_states,
2493 &blockheight_states,
2494 &commit_sig,
2495 &htlc_sigs,
2496 &added,
2497 &fulfilled,
2498 &failed,
2499 &changed,
2500 &tx,
2501 &inflight_commit_sigs)
2502 || !fee_states_valid(fee_states, channel->opener)
2503 || !height_states_valid(blockheight_states, channel->opener)) {
2504 channel_internal_error(channel,
2505 "bad fromwire_channeld_got_commitsig %s",
2506 tal_hex(channel, msg));
2507 return;
2508 }
2509
2510 /* If we're not synced with bitcoin network, we can't accept
2511 * any new HTLCs. We stall at this point, in the hope that it
2512 * won't take long! */
2513 if (added && !topology_synced(ld->topology)) {
2514 struct deferred_commitsig *d;
2515
2516 log_unusual(channel->log,
2517 "Deferring incoming commit until we sync");
2518
2519 /* If subdaemon dies, we want to forget this. */
2520 d = tal(channel->owner, struct deferred_commitsig);
2521 d->channel = channel;
2522 d->msg = tal_dup_talarr(d, u8, msg);
2523 topology_add_sync_waiter(d, ld->topology,
2524 retry_deferred_commitsig, d);
2525 return;
2526 }
2527
2528 tx->chainparams = chainparams;
2529
2530 log_debug(channel->log,

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