Skip to content

Commit 464b50b

Browse files
committed
channeld: Implement receiving of start_batch
Since `batch_size` has moved into this new message, we can’t ignore it anymore and have to process it
1 parent ec7654c commit 464b50b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

channeld/channeld.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,35 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
23252325
allow_empty_commit, msg_batch);
23262326
}
23272327

2328+
static void handle_peer_start_batch(struct peer *peer, const u8 *msg)
2329+
{
2330+
u16 batch_size;
2331+
struct channel_id channel_id;
2332+
struct tlv_start_batch_tlvs *tlvs;
2333+
if (!fromwire_start_batch(tmpctx, msg, &channel_id, &batch_size, &tlvs))
2334+
peer_failed_warn(peer->pps, &peer->channel_id,
2335+
"Bad start_batch %s", tal_hex(msg, msg));
2336+
2337+
if (!tlvs || !tlvs->batch_info
2338+
|| *tlvs->batch_info != WIRE_COMMITMENT_SIGNED) {
2339+
status_unusual("Ignoring Unrecognized start_batch message type"
2340+
" %s, expected WIRE_COMMITMENT_SIGNED.",
2341+
tlvs && tlvs->batch_info
2342+
? peer_wire_name(*tlvs->batch_info)
2343+
: "N/A");
2344+
return;
2345+
}
2346+
2347+
handle_peer_commit_sig_batch(peer, peer_read(tmpctx, peer->pps), 0,
2348+
peer->channel->funding_pubkey[REMOTE],
2349+
NULL, 0, 0,
2350+
peer->next_index[LOCAL],
2351+
&peer->next_local_per_commit,
2352+
false,
2353+
batch_size);
2354+
}
2355+
2356+
23282357
/* Pops the penalty base for the given commitnum from our internal list. There
23292358
* may not be one, in which case we return NULL and leave the list
23302359
* unmodified. */
@@ -4884,6 +4913,7 @@ static void peer_in(struct peer *peer, const u8 *msg)
48844913
handle_peer_add_htlc(peer, msg);
48854914
return;
48864915
case WIRE_START_BATCH:
4916+
handle_peer_start_batch(peer, msg);
48874917
return;
48884918
case WIRE_COMMITMENT_SIGNED:
48894919
handle_peer_commit_sig_batch(peer, msg, 0,

0 commit comments

Comments
 (0)