@@ -1019,7 +1019,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
1019
1019
cur_counterparty_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER ,
1020
1020
value_to_self_msat,
1021
1021
1022
- max_accepted_htlcs : 50 ,
1022
+ max_accepted_htlcs : config . channel_handshake_config . max_accepted_htlcs ,
1023
1023
pending_inbound_htlcs : Vec :: new ( ) ,
1024
1024
pending_outbound_htlcs : Vec :: new ( ) ,
1025
1025
holding_cell_htlc_updates : Vec :: new ( ) ,
@@ -1364,7 +1364,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
1364
1364
cur_counterparty_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER ,
1365
1365
value_to_self_msat : msg. push_msat ,
1366
1366
1367
- max_accepted_htlcs : msg . max_accepted_htlcs ,
1367
+ max_accepted_htlcs : config . channel_handshake_config . max_accepted_htlcs ,
1368
1368
pending_inbound_htlcs : Vec :: new ( ) ,
1369
1369
pending_outbound_htlcs : Vec :: new ( ) ,
1370
1370
holding_cell_htlc_updates : Vec :: new ( ) ,
@@ -6208,7 +6208,6 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
6208
6208
self . cur_counterparty_commitment_transaction_number . write ( writer) ?;
6209
6209
self . value_to_self_msat . write ( writer) ?;
6210
6210
6211
- self . max_accepted_htlcs . write ( writer) ?;
6212
6211
let mut dropped_inbound_htlcs = 0 ;
6213
6212
for htlc in self . pending_inbound_htlcs . iter ( ) {
6214
6213
if let InboundHTLCState :: RemoteAnnounced ( _) = htlc. state {
@@ -6429,6 +6428,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
6429
6428
// we write the high bytes as an option here.
6430
6429
let user_id_high_opt = Some ( ( self . user_id >> 64 ) as u64 ) ;
6431
6430
6431
+ let max_accepted_htlcs = if self . max_accepted_htlcs == 50 { None } else { Some ( self . max_accepted_htlcs ) } ;
6432
+
6432
6433
write_tlv_fields ! ( writer, {
6433
6434
( 0 , self . announcement_sigs, option) ,
6434
6435
// minimum_depth and counterparty_selected_channel_reserve_satoshis used to have a
@@ -6454,7 +6455,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
6454
6455
( 23 , channel_ready_event_emitted, option) ,
6455
6456
( 25 , user_id_high_opt, option) ,
6456
6457
( 27 , self . channel_keys_id, required) ,
6457
- ( 28 , Some ( self . max_accepted_htlcs) , option) ,
6458
+ ( 28 , max_accepted_htlcs, option) ,
6458
6459
} ) ;
6459
6460
6460
6461
Ok ( ( ) )
@@ -6520,10 +6521,11 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6520
6521
let cur_counterparty_commitment_transaction_number = Readable :: read ( reader) ?;
6521
6522
let value_to_self_msat = Readable :: read ( reader) ?;
6522
6523
6523
- let max_accepted_htlcs = Readable :: read ( reader) ?;
6524
6524
let pending_inbound_htlc_count: u64 = Readable :: read ( reader) ?;
6525
6525
6526
- let mut pending_inbound_htlcs = Vec :: with_capacity ( cmp:: min ( pending_inbound_htlc_count as usize , max_accepted_htlcs as usize ) ) ;
6526
+ let channel_handshake_config = ChannelHandshakeConfig :: default ( ) ;
6527
+
6528
+ let mut pending_inbound_htlcs = Vec :: with_capacity ( cmp:: min ( pending_inbound_htlc_count as usize , channel_handshake_config. max_accepted_htlcs as usize ) ) ;
6527
6529
for _ in 0 ..pending_inbound_htlc_count {
6528
6530
pending_inbound_htlcs. push ( InboundHTLCOutput {
6529
6531
htlc_id : Readable :: read ( reader) ?,
@@ -6541,7 +6543,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6541
6543
}
6542
6544
6543
6545
let pending_outbound_htlc_count: u64 = Readable :: read ( reader) ?;
6544
- let mut pending_outbound_htlcs = Vec :: with_capacity ( cmp:: min ( pending_outbound_htlc_count as usize , max_accepted_htlcs as usize ) ) ;
6546
+ let mut pending_outbound_htlcs = Vec :: with_capacity ( cmp:: min ( pending_outbound_htlc_count as usize , channel_handshake_config . max_accepted_htlcs as usize ) ) ;
6545
6547
for _ in 0 ..pending_outbound_htlc_count {
6546
6548
pending_outbound_htlcs. push ( OutboundHTLCOutput {
6547
6549
htlc_id : Readable :: read ( reader) ?,
@@ -6570,7 +6572,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6570
6572
}
6571
6573
6572
6574
let holding_cell_htlc_update_count: u64 = Readable :: read ( reader) ?;
6573
- let mut holding_cell_htlc_updates = Vec :: with_capacity ( cmp:: min ( holding_cell_htlc_update_count as usize , max_accepted_htlcs as usize * 2 ) ) ;
6575
+ let mut holding_cell_htlc_updates = Vec :: with_capacity ( cmp:: min ( holding_cell_htlc_update_count as usize , channel_handshake_config . max_accepted_htlcs as usize * 2 ) ) ;
6574
6576
for _ in 0 ..holding_cell_htlc_update_count {
6575
6577
holding_cell_htlc_updates. push ( match <u8 as Readable >:: read ( reader) ? {
6576
6578
0 => HTLCUpdateAwaitingACK :: AddHTLC {
@@ -6603,13 +6605,13 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6603
6605
let monitor_pending_commitment_signed = Readable :: read ( reader) ?;
6604
6606
6605
6607
let monitor_pending_forwards_count: u64 = Readable :: read ( reader) ?;
6606
- let mut monitor_pending_forwards = Vec :: with_capacity ( cmp:: min ( monitor_pending_forwards_count as usize , max_accepted_htlcs as usize ) ) ;
6608
+ let mut monitor_pending_forwards = Vec :: with_capacity ( cmp:: min ( monitor_pending_forwards_count as usize , channel_handshake_config . max_accepted_htlcs as usize ) ) ;
6607
6609
for _ in 0 ..monitor_pending_forwards_count {
6608
6610
monitor_pending_forwards. push ( ( Readable :: read ( reader) ?, Readable :: read ( reader) ?) ) ;
6609
6611
}
6610
6612
6611
6613
let monitor_pending_failures_count: u64 = Readable :: read ( reader) ?;
6612
- let mut monitor_pending_failures = Vec :: with_capacity ( cmp:: min ( monitor_pending_failures_count as usize , max_accepted_htlcs as usize ) ) ;
6614
+ let mut monitor_pending_failures = Vec :: with_capacity ( cmp:: min ( monitor_pending_failures_count as usize , channel_handshake_config . max_accepted_htlcs as usize ) ) ;
6613
6615
for _ in 0 ..monitor_pending_failures_count {
6614
6616
monitor_pending_failures. push ( ( Readable :: read ( reader) ?, Readable :: read ( reader) ?, Readable :: read ( reader) ?) ) ;
6615
6617
}
@@ -6728,6 +6730,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6728
6730
6729
6731
let mut user_id_high_opt: Option < u64 > = None ;
6730
6732
let mut channel_keys_id: Option < [ u8 ; 32 ] > = None ;
6733
+ let mut max_accepted_htlcs: Option < u16 > = None ;
6731
6734
6732
6735
read_tlv_fields ! ( reader, {
6733
6736
( 0 , announcement_sigs, option) ,
@@ -6748,6 +6751,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6748
6751
( 23 , channel_ready_event_emitted, option) ,
6749
6752
( 25 , user_id_high_opt, option) ,
6750
6753
( 27 , channel_keys_id, option) ,
6754
+ ( 28 , max_accepted_htlcs, option) ,
6751
6755
} ) ;
6752
6756
6753
6757
let ( channel_keys_id, holder_signer) = if let Some ( channel_keys_id) = channel_keys_id {
@@ -6800,6 +6804,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6800
6804
// separate u64 values.
6801
6805
let user_id = user_id_low as u128 + ( ( user_id_high_opt. unwrap_or ( 0 ) as u128 ) << 64 ) ;
6802
6806
6807
+ let max_accepted_htlcs = max_accepted_htlcs. unwrap_or ( channel_handshake_config. max_accepted_htlcs ) ;
6808
+
6803
6809
Ok ( Channel {
6804
6810
user_id,
6805
6811
0 commit comments