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

Function handle_peer_commit_sig

channeld/channeld.c:2001–2337  ·  view source on GitHub ↗

Calling `handle_peer_commit_sig` with a `commit_index` of 0 and * `changed_htlcs` of NULL will process the message, then read & process coming * consecutive commitment messages equal to the number of inflight splices. * * Returns the last commitsig received. When splicing this is the * newest splice commit sig. * * `commit_index` 0 refers to the funding commit. `commit_index` 1 and above *

Source from the content-addressed store, hash-verified

1999 * inflight msgs must be in the same order as the inflight array.
2000 */
2001static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
2002 const u8 *msg,
2003 u32 commit_index,
2004 struct pubkey remote_funding,
2005 const struct htlc **changed_htlcs,
2006 s64 splice_amnt,
2007 s64 remote_splice_amnt,
2008 u64 local_index,
2009 const struct pubkey *local_per_commit,
2010 bool allow_empty_commit,
2011 const u8 **msg_batch)
2012{
2013 struct commitsig_info *result;
2014 struct channel_id channel_id;
2015 struct bitcoin_signature commit_sig;
2016 secp256k1_ecdsa_signature *raw_sigs;
2017 struct bitcoin_signature *htlc_sigs;
2018 struct pubkey remote_htlckey;
2019 struct bitcoin_tx **txs;
2020 const struct htlc **htlc_map;
2021 const u8 *funding_wscript;
2022 size_t i;
2023 const struct hsm_htlc *htlcs;
2024 const u8 * msg2;
2025 struct bitcoin_outpoint outpoint;
2026 struct amount_sat funding_sats;
2027 const struct commitsig **commitsigs;
2028 int remote_anchor_outnum;
2029 struct pubkey funding_pubkeys[NUM_SIDES] =
2030 { peer->channel->funding_pubkey[LOCAL],
2031 remote_funding };
2032
2033 status_debug("handle_peer_commit_sig(splice: %d, remote_splice: %d,"
2034 " commit_index: %"PRIu32", local_index: %"PRIu64", msg: %p)",
2035 (int)splice_amnt, (int)remote_splice_amnt, commit_index,
2036 local_index, msg);
2037
2038 struct tlv_commitment_signed_tlvs *cs_tlv
2039 = tlv_commitment_signed_tlvs_new(tmpctx);
2040 if (!fromwire_commitment_signed(tmpctx, msg,
2041 &channel_id, &commit_sig.s, &raw_sigs,
2042 &cs_tlv))
2043 peer_failed_warn(peer->pps, &peer->channel_id,
2044 "Bad commit_sig %s", tal_hex(msg, msg));
2045
2046 /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2047 * - If the sending node sent `start_batch` and we are processing a batch of
2048 * `commitment_signed` messages:
2049 */
2050 if (msg_batch && tal_count(msg_batch) > 1) {
2051
2052 /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2053 * - If `funding_txid` is missing in one of the `commitment_signed` messages:
2054 * - MUST send an `error` and fail the channel.
2055 */
2056 if (!cs_tlv->splice_info)
2057 peer_failed_err(peer->pps, &peer->channel_id,
2058 "Must send funding_txid when sending"

Callers 2

Calls 15

peer_failed_warnFunction · 0.85
tal_hexFunction · 0.85
fmt_bitcoin_txidFunction · 0.85
channel_rcvd_commitFunction · 0.85
channel_feerateFunction · 0.85
unraw_sigsFunction · 0.85
channel_has_anchorsFunction · 0.85
channel_txsFunction · 0.85
psbt_input_set_signatureFunction · 0.85
derive_simple_keyFunction · 0.85
fmt_pubkeyFunction · 0.85

Tested by

no test coverage detected