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

Function handle_peer_commit_sig_batch

channeld/channeld.c:2459–2550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2457}
2458
2459static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
2460 const u8 *msg,
2461 struct pubkey remote_funding,
2462 const struct htlc **changed_htlcs,
2463 s64 splice_amnt,
2464 s64 remote_splice_amnt,
2465 u64 local_index,
2466 const struct pubkey *local_per_commit,
2467 bool allow_empty_commit,
2468 u16 batch_size)
2469{
2470 struct channel_id channel_id;
2471 struct bitcoin_signature commit_sig;
2472 secp256k1_ecdsa_signature *raw_sigs;
2473 const u8 **msg_batch;
2474 enum peer_wire type;
2475 struct tlv_commitment_signed_tlvs *cs_tlv
2476 = tlv_commitment_signed_tlvs_new(tmpctx);
2477 status_debug("fromwire_commitment_signed(%p) primary", msg);
2478 check_tx_abort(peer, msg, NULL);
2479 type = fromwire_peektype(msg);
2480 if (type != WIRE_COMMITMENT_SIGNED)
2481 peer_failed_err(peer->pps, &peer->channel_id,
2482 "Expected WIRE_COMMITMENT_SIGNED but got %s.",
2483 peer_wire_name(type));
2484 if (!fromwire_commitment_signed(tmpctx, msg,
2485 &channel_id, &commit_sig.s, &raw_sigs,
2486 &cs_tlv))
2487 peer_failed_warn(peer->pps, &peer->channel_id,
2488 "Bad commit_sig %s", tal_hex(msg, msg));
2489
2490 /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2491 * - If there are pending splice transactions and the sending node did not
2492 * send `start_batch` followed by a batch of `commitment_signed` messages:
2493 * - MUST send an `error` and fail the channel.
2494 */
2495 if (batch_size < 2 && last_inflight(peer))
2496 peer_failed_err(peer->pps, &peer->channel_id, "Must send a"
2497 " commitment batch (ie. start_batch) when I"
2498 " have pending splices inflight.");
2499
2500 msg_batch = tal_arr(tmpctx, const u8*, batch_size);
2501 msg_batch[0] = msg;
2502
2503 /* Already received commitment signed once, so start at i = 1 */
2504 for (u16 i = 1; i < batch_size; i++) {
2505 struct tlv_commitment_signed_tlvs *sub_cs_tlv
2506 = tlv_commitment_signed_tlvs_new(tmpctx);
2507 u8 *sub_msg = peer_read(tmpctx, peer->pps);
2508 check_tx_abort(peer, sub_msg, NULL);
2509
2510 /* Check type for cleaner failure message */
2511 type = fromwire_peektype(sub_msg);
2512 if (type != WIRE_COMMITMENT_SIGNED)
2513 peer_failed_err(peer->pps, &peer->channel_id,
2514 "Expected splice related "
2515 "WIRE_COMMITMENT_SIGNED but got %s",
2516 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