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

Function handle_peer_commit_sig_batch

channeld/channeld.c:2494–2585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2492}
2493
2494static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
2495 const u8 *msg,
2496 struct pubkey remote_funding,
2497 const struct htlc **changed_htlcs,
2498 s64 splice_amnt,
2499 s64 remote_splice_amnt,
2500 u64 local_index,
2501 const struct pubkey *local_per_commit,
2502 bool allow_empty_commit,
2503 u16 batch_size)
2504{
2505 struct channel_id channel_id;
2506 struct bitcoin_signature commit_sig;
2507 secp256k1_ecdsa_signature *raw_sigs;
2508 const u8 **msg_batch;
2509 enum peer_wire type;
2510 struct tlv_commitment_signed_tlvs *cs_tlv
2511 = tlv_commitment_signed_tlvs_new(tmpctx);
2512 status_debug("fromwire_commitment_signed(%p) primary", msg);
2513 check_tx_abort(peer, msg, NULL);
2514 type = fromwire_peektype(msg);
2515 if (type != WIRE_COMMITMENT_SIGNED)
2516 peer_failed_err(peer->pps, &peer->channel_id,
2517 "Expected WIRE_COMMITMENT_SIGNED but got %s.",
2518 peer_wire_name(type));
2519 if (!fromwire_commitment_signed(tmpctx, msg,
2520 &channel_id, &commit_sig.s, &raw_sigs,
2521 &cs_tlv))
2522 peer_failed_warn(peer->pps, &peer->channel_id,
2523 "Bad commit_sig %s", tal_hex(msg, msg));
2524
2525 /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2526 * - If there are pending splice transactions and the sending node did not
2527 * send `start_batch` followed by a batch of `commitment_signed` messages:
2528 * - MUST send an `error` and fail the channel.
2529 */
2530 if (batch_size < 2 && last_inflight(peer))
2531 peer_failed_err(peer->pps, &peer->channel_id, "Must send a"
2532 " commitment batch (ie. start_batch) when I"
2533 " have pending splices inflight.");
2534
2535 msg_batch = tal_arr(tmpctx, const u8*, batch_size);
2536 msg_batch[0] = msg;
2537
2538 /* Already received commitment signed once, so start at i = 1 */
2539 for (u16 i = 1; i < batch_size; i++) {
2540 struct tlv_commitment_signed_tlvs *sub_cs_tlv
2541 = tlv_commitment_signed_tlvs_new(tmpctx);
2542 u8 *sub_msg = peer_read(tmpctx, peer->pps);
2543 check_tx_abort(peer, sub_msg, NULL);
2544
2545 /* Check type for cleaner failure message */
2546 type = fromwire_peektype(sub_msg);
2547 if (type != WIRE_COMMITMENT_SIGNED)
2548 peer_failed_err(peer->pps, &peer->channel_id,
2549 "Expected splice related "
2550 "WIRE_COMMITMENT_SIGNED but got %s",
2551 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