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

Function handle_peer_commit_sig

channeld/channeld.c:2073–2409  ·  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

2071 * inflight msgs must be in the same order as the inflight array.
2072 */
2073static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
2074 const u8 *msg,
2075 u32 commit_index,
2076 struct pubkey remote_funding,
2077 const struct htlc **changed_htlcs,
2078 s64 splice_amnt,
2079 s64 remote_splice_amnt,
2080 u64 local_index,
2081 const struct pubkey *local_per_commit,
2082 bool allow_empty_commit,
2083 const u8 **msg_batch)
2084{
2085 struct commitsig_info *result;
2086 struct channel_id channel_id;
2087 struct bitcoin_signature commit_sig;
2088 secp256k1_ecdsa_signature *raw_sigs;
2089 struct bitcoin_signature *htlc_sigs;
2090 struct pubkey remote_htlckey;
2091 struct bitcoin_tx **txs;
2092 const struct htlc **htlc_map;
2093 const u8 *funding_wscript;
2094 size_t i;
2095 const struct hsm_htlc *htlcs;
2096 const u8 * msg2;
2097 struct bitcoin_outpoint outpoint;
2098 struct amount_sat funding_sats;
2099 const struct commitsig **commitsigs;
2100 int remote_anchor_outnum;
2101 struct pubkey funding_pubkeys[NUM_SIDES] =
2102 { peer->channel->funding_pubkey[LOCAL],
2103 remote_funding };
2104
2105 status_debug("handle_peer_commit_sig(splice: %d, remote_splice: %d,"
2106 " commit_index: %"PRIu32", local_index: %"PRIu64", msg: %p)",
2107 (int)splice_amnt, (int)remote_splice_amnt, commit_index,
2108 local_index, msg);
2109
2110 struct tlv_commitment_signed_tlvs *cs_tlv
2111 = tlv_commitment_signed_tlvs_new(tmpctx);
2112 if (!fromwire_commitment_signed(tmpctx, msg,
2113 &channel_id, &commit_sig.s, &raw_sigs,
2114 &cs_tlv))
2115 peer_failed_warn(peer->pps, &peer->channel_id,
2116 "Bad commit_sig %s", tal_hex(msg, msg));
2117
2118 /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2119 * - If the sending node sent `start_batch` and we are processing a batch of
2120 * `commitment_signed` messages:
2121 */
2122 if (msg_batch && tal_count(msg_batch) > 1) {
2123
2124 /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2125 * - If `funding_txid` is missing in one of the `commitment_signed` messages:
2126 * - MUST send an `error` and fail the channel.
2127 */
2128 if (!cs_tlv->splice_info)
2129 peer_failed_err(peer->pps, &peer->channel_id,
2130 "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