Skip to content

Commit 6086d86

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 7d6f604 commit 6086d86

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
@@ -2362,6 +2362,35 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
23622362
allow_empty_commit, msg_batch);
23632363
}
23642364

2365+
static void handle_peer_start_batch(struct peer *peer, const u8 *msg)
2366+
{
2367+
u16 batch_size;
2368+
struct channel_id channel_id;
2369+
struct tlv_start_batch_tlvs *tlvs;
2370+
if (!fromwire_start_batch(tmpctx, msg, &channel_id, &batch_size, &tlvs))
2371+
peer_failed_warn(peer->pps, &peer->channel_id,
2372+
"Bad start_batch %s", tal_hex(msg, msg));
2373+
2374+
if (!tlvs || !tlvs->batch_info
2375+
|| *tlvs->batch_info != WIRE_COMMITMENT_SIGNED) {
2376+
status_unusual("Ignoring Unrecognized start_batch message type"
2377+
" %s, expected WIRE_COMMITMENT_SIGNED.",
2378+
tlvs && tlvs->batch_info
2379+
? peer_wire_name(*tlvs->batch_info)
2380+
: "N/A");
2381+
return;
2382+
}
2383+
2384+
handle_peer_commit_sig_batch(peer, peer_read(tmpctx, peer->pps), 0,
2385+
peer->channel->funding_pubkey[REMOTE],
2386+
NULL, 0, 0,
2387+
peer->next_index[LOCAL],
2388+
&peer->next_local_per_commit,
2389+
false,
2390+
batch_size);
2391+
}
2392+
2393+
23652394
/* Pops the penalty base for the given commitnum from our internal list. There
23662395
* may not be one, in which case we return NULL and leave the list
23672396
* unmodified. */
@@ -4828,6 +4857,7 @@ static void peer_in(struct peer *peer, const u8 *msg)
48284857
handle_peer_add_htlc(peer, msg);
48294858
return;
48304859
case WIRE_START_BATCH:
4860+
handle_peer_start_batch(peer, msg);
48314861
return;
48324862
case WIRE_COMMITMENT_SIGNED:
48334863
handle_peer_commit_sig_batch(peer, msg, 0,

0 commit comments

Comments
 (0)