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

Function handle_peer_commit_sig

channeld/channeld.c:2102–2444  ·  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

2100 * inflight msgs must be in the same order as the inflight array.
2101 */
2102static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
2103 const u8 *msg,
2104 u32 commit_index,
2105 struct pubkey remote_funding,
2106 const struct htlc **changed_htlcs,
2107 s64 splice_amnt,
2108 s64 remote_splice_amnt,
2109 u64 local_index,
2110 const struct pubkey *local_per_commit,
2111 bool allow_empty_commit,
2112 const u8 **msg_batch)
2113{
2114 struct commitsig_info *result;
2115 struct channel_id channel_id;
2116 struct bitcoin_signature commit_sig;
2117 secp256k1_ecdsa_signature *raw_sigs;
2118 struct bitcoin_signature *htlc_sigs;
2119 struct pubkey remote_htlckey;
2120 struct bitcoin_tx **txs;
2121 const struct htlc **htlc_map;
2122 const u8 *funding_wscript;
2123 size_t i;
2124 const struct hsm_htlc *htlcs;
2125 const u8 * msg2;
2126 struct bitcoin_outpoint outpoint;
2127 struct amount_sat funding_sats;
2128 const struct commitsig **commitsigs;
2129 int remote_anchor_outnum;
2130 struct pubkey funding_pubkeys[NUM_SIDES] =
2131 { peer->channel->funding_pubkey[LOCAL],
2132 remote_funding };
2133
2134 status_debug("handle_peer_commit_sig(splice: %d, remote_splice: %d,"
2135 " commit_index: %"PRIu32", local_index: %"PRIu64", msg: %p)",
2136 (int)splice_amnt, (int)remote_splice_amnt, commit_index,
2137 local_index, msg);
2138
2139 struct tlv_commitment_signed_tlvs *cs_tlv
2140 = tlv_commitment_signed_tlvs_new(tmpctx);
2141 if (!fromwire_commitment_signed(tmpctx, msg,
2142 &channel_id, &commit_sig.s, &raw_sigs,
2143 &cs_tlv))
2144 peer_failed_warn(peer->pps, &peer->channel_id,
2145 "Bad commit_sig %s", tal_hex(msg, msg));
2146
2147 /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2148 * - If the sending node sent `start_batch` and we are processing a batch of
2149 * `commitment_signed` messages:
2150 */
2151 if (msg_batch && tal_count(msg_batch) > 1) {
2152
2153 /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2154 * - If `funding_txid` is missing in one of the `commitment_signed` messages:
2155 * - MUST send an `error` and fail the channel.
2156 */
2157 if (!cs_tlv->splice_info)
2158 peer_failed_err(peer->pps, &peer->channel_id,
2159 "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
fmt_bitcoin_outpointFunction · 0.85
psbt_input_set_signatureFunction · 0.85
derive_simple_keyFunction · 0.85

Tested by

no test coverage detected