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

Function handle_peer_commit_sig_batch

channeld/channeld.c:2387–2478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2385}
2386
2387static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
2388 const u8 *msg,
2389 struct pubkey remote_funding,
2390 const struct htlc **changed_htlcs,
2391 s64 splice_amnt,
2392 s64 remote_splice_amnt,
2393 u64 local_index,
2394 const struct pubkey *local_per_commit,
2395 bool allow_empty_commit,
2396 u16 batch_size)
2397{
2398 struct channel_id channel_id;
2399 struct bitcoin_signature commit_sig;
2400 secp256k1_ecdsa_signature *raw_sigs;
2401 const u8 **msg_batch;
2402 enum peer_wire type;
2403 struct tlv_commitment_signed_tlvs *cs_tlv
2404 = tlv_commitment_signed_tlvs_new(tmpctx);
2405 status_debug("fromwire_commitment_signed(%p) primary", msg);
2406 check_tx_abort(peer, msg, NULL);
2407 type = fromwire_peektype(msg);
2408 if (type != WIRE_COMMITMENT_SIGNED)
2409 peer_failed_err(peer->pps, &peer->channel_id,
2410 "Expected WIRE_COMMITMENT_SIGNED but got %s.",
2411 peer_wire_name(type));
2412 if (!fromwire_commitment_signed(tmpctx, msg,
2413 &channel_id, &commit_sig.s, &raw_sigs,
2414 &cs_tlv))
2415 peer_failed_warn(peer->pps, &peer->channel_id,
2416 "Bad commit_sig %s", tal_hex(msg, msg));
2417
2418 /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2419 * - If there are pending splice transactions and the sending node did not
2420 * send `start_batch` followed by a batch of `commitment_signed` messages:
2421 * - MUST send an `error` and fail the channel.
2422 */
2423 if (batch_size < 2 && last_inflight(peer))
2424 peer_failed_err(peer->pps, &peer->channel_id, "Must send a"
2425 " commitment batch (ie. start_batch) when I"
2426 " have pending splices inflight.");
2427
2428 msg_batch = tal_arr(tmpctx, const u8*, batch_size);
2429 msg_batch[0] = msg;
2430
2431 /* Already received commitment signed once, so start at i = 1 */
2432 for (u16 i = 1; i < batch_size; i++) {
2433 struct tlv_commitment_signed_tlvs *sub_cs_tlv
2434 = tlv_commitment_signed_tlvs_new(tmpctx);
2435 u8 *sub_msg = peer_read(tmpctx, peer->pps);
2436 check_tx_abort(peer, sub_msg, NULL);
2437
2438 /* Check type for cleaner failure message */
2439 type = fromwire_peektype(sub_msg);
2440 if (type != WIRE_COMMITMENT_SIGNED)
2441 peer_failed_err(peer->pps, &peer->channel_id,
2442 "Expected splice related "
2443 "WIRE_COMMITMENT_SIGNED but got %s",
2444 peer_wire_name(type));

Callers 2

handle_peer_start_batchFunction · 0.85
peer_inFunction · 0.85

Calls 8

check_tx_abortFunction · 0.85
fromwire_peektypeFunction · 0.85
peer_failed_warnFunction · 0.85
tal_hexFunction · 0.85
last_inflightFunction · 0.85
peer_readFunction · 0.85
handle_peer_commit_sigFunction · 0.85
peer_failed_errFunction · 0.50

Tested by

no test coverage detected