@@ -1026,7 +1026,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
1026
1026
cur_counterparty_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER ,
1027
1027
value_to_self_msat,
1028
1028
1029
- max_accepted_htlcs : 50 ,
1029
+ max_accepted_htlcs : config . channel_handshake_config . max_accepted_htlcs ,
1030
1030
pending_inbound_htlcs : Vec :: new ( ) ,
1031
1031
pending_outbound_htlcs : Vec :: new ( ) ,
1032
1032
holding_cell_htlc_updates : Vec :: new ( ) ,
@@ -1373,7 +1373,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
1373
1373
cur_counterparty_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER ,
1374
1374
value_to_self_msat : msg. push_msat ,
1375
1375
1376
- max_accepted_htlcs : msg . max_accepted_htlcs ,
1376
+ max_accepted_htlcs : config . channel_handshake_config . max_accepted_htlcs ,
1377
1377
pending_inbound_htlcs : Vec :: new ( ) ,
1378
1378
pending_outbound_htlcs : Vec :: new ( ) ,
1379
1379
holding_cell_htlc_updates : Vec :: new ( ) ,
@@ -6276,7 +6276,6 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
6276
6276
self . cur_counterparty_commitment_transaction_number . write ( writer) ?;
6277
6277
self . value_to_self_msat . write ( writer) ?;
6278
6278
6279
- self . max_accepted_htlcs . write ( writer) ?;
6280
6279
let mut dropped_inbound_htlcs = 0 ;
6281
6280
for htlc in self . pending_inbound_htlcs . iter ( ) {
6282
6281
if let InboundHTLCState :: RemoteAnnounced ( _) = htlc. state {
@@ -6498,6 +6497,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
6498
6497
// we write the high bytes as an option here.
6499
6498
let user_id_high_opt = Some ( ( self . user_id >> 64 ) as u64 ) ;
6500
6499
6500
+ let max_accepted_htlcs = if self . max_accepted_htlcs == 50 { None } else { Some ( self . max_accepted_htlcs ) } ;
6501
+
6501
6502
write_tlv_fields ! ( writer, {
6502
6503
( 0 , self . announcement_sigs, option) ,
6503
6504
// minimum_depth and counterparty_selected_channel_reserve_satoshis used to have a
@@ -6523,7 +6524,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
6523
6524
( 23 , channel_ready_event_emitted, option) ,
6524
6525
( 25 , user_id_high_opt, option) ,
6525
6526
( 27 , self . channel_keys_id, required) ,
6526
- ( 28 , Some ( self . max_accepted_htlcs) , option) ,
6527
+ ( 28 , max_accepted_htlcs, option) ,
6527
6528
( 29 , self . temporary_channel_id, option) ,
6528
6529
( 31 , channel_pending_event_emitted, option) ,
6529
6530
} ) ;
@@ -6591,10 +6592,11 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6591
6592
let cur_counterparty_commitment_transaction_number = Readable :: read ( reader) ?;
6592
6593
let value_to_self_msat = Readable :: read ( reader) ?;
6593
6594
6594
- let max_accepted_htlcs = Readable :: read ( reader) ?;
6595
6595
let pending_inbound_htlc_count: u64 = Readable :: read ( reader) ?;
6596
6596
6597
- let mut pending_inbound_htlcs = Vec :: with_capacity ( cmp:: min ( pending_inbound_htlc_count as usize , max_accepted_htlcs as usize ) ) ;
6597
+ let channel_handshake_config = ChannelHandshakeConfig :: default ( ) ;
6598
+
6599
+ let mut pending_inbound_htlcs = Vec :: with_capacity ( cmp:: min ( pending_inbound_htlc_count as usize , channel_handshake_config. max_accepted_htlcs as usize ) ) ;
6598
6600
for _ in 0 ..pending_inbound_htlc_count {
6599
6601
pending_inbound_htlcs. push ( InboundHTLCOutput {
6600
6602
htlc_id : Readable :: read ( reader) ?,
@@ -6612,7 +6614,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6612
6614
}
6613
6615
6614
6616
let pending_outbound_htlc_count: u64 = Readable :: read ( reader) ?;
6615
- let mut pending_outbound_htlcs = Vec :: with_capacity ( cmp:: min ( pending_outbound_htlc_count as usize , max_accepted_htlcs as usize ) ) ;
6617
+ let mut pending_outbound_htlcs = Vec :: with_capacity ( cmp:: min ( pending_outbound_htlc_count as usize , channel_handshake_config . max_accepted_htlcs as usize ) ) ;
6616
6618
for _ in 0 ..pending_outbound_htlc_count {
6617
6619
pending_outbound_htlcs. push ( OutboundHTLCOutput {
6618
6620
htlc_id : Readable :: read ( reader) ?,
@@ -6641,7 +6643,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6641
6643
}
6642
6644
6643
6645
let holding_cell_htlc_update_count: u64 = Readable :: read ( reader) ?;
6644
- let mut holding_cell_htlc_updates = Vec :: with_capacity ( cmp:: min ( holding_cell_htlc_update_count as usize , max_accepted_htlcs as usize * 2 ) ) ;
6646
+ 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 ) ) ;
6645
6647
for _ in 0 ..holding_cell_htlc_update_count {
6646
6648
holding_cell_htlc_updates. push ( match <u8 as Readable >:: read ( reader) ? {
6647
6649
0 => HTLCUpdateAwaitingACK :: AddHTLC {
@@ -6674,13 +6676,13 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6674
6676
let monitor_pending_commitment_signed = Readable :: read ( reader) ?;
6675
6677
6676
6678
let monitor_pending_forwards_count: u64 = Readable :: read ( reader) ?;
6677
- let mut monitor_pending_forwards = Vec :: with_capacity ( cmp:: min ( monitor_pending_forwards_count as usize , max_accepted_htlcs as usize ) ) ;
6679
+ let mut monitor_pending_forwards = Vec :: with_capacity ( cmp:: min ( monitor_pending_forwards_count as usize , channel_handshake_config . max_accepted_htlcs as usize ) ) ;
6678
6680
for _ in 0 ..monitor_pending_forwards_count {
6679
6681
monitor_pending_forwards. push ( ( Readable :: read ( reader) ?, Readable :: read ( reader) ?) ) ;
6680
6682
}
6681
6683
6682
6684
let monitor_pending_failures_count: u64 = Readable :: read ( reader) ?;
6683
- let mut monitor_pending_failures = Vec :: with_capacity ( cmp:: min ( monitor_pending_failures_count as usize , max_accepted_htlcs as usize ) ) ;
6685
+ let mut monitor_pending_failures = Vec :: with_capacity ( cmp:: min ( monitor_pending_failures_count as usize , channel_handshake_config . max_accepted_htlcs as usize ) ) ;
6684
6686
for _ in 0 ..monitor_pending_failures_count {
6685
6687
monitor_pending_failures. push ( ( Readable :: read ( reader) ?, Readable :: read ( reader) ?, Readable :: read ( reader) ?) ) ;
6686
6688
}
@@ -6801,6 +6803,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6801
6803
let mut user_id_high_opt: Option < u64 > = None ;
6802
6804
let mut channel_keys_id: Option < [ u8 ; 32 ] > = None ;
6803
6805
let mut temporary_channel_id: Option < [ u8 ; 32 ] > = None ;
6806
+ let mut max_accepted_htlcs: Option < u16 > = None ;
6804
6807
6805
6808
read_tlv_fields ! ( reader, {
6806
6809
( 0 , announcement_sigs, option) ,
@@ -6821,6 +6824,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6821
6824
( 23 , channel_ready_event_emitted, option) ,
6822
6825
( 25 , user_id_high_opt, option) ,
6823
6826
( 27 , channel_keys_id, option) ,
6827
+ ( 28 , max_accepted_htlcs, option) ,
6824
6828
( 29 , temporary_channel_id, option) ,
6825
6829
( 31 , channel_pending_event_emitted, option) ,
6826
6830
} ) ;
@@ -6875,6 +6879,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6875
6879
// separate u64 values.
6876
6880
let user_id = user_id_low as u128 + ( ( user_id_high_opt. unwrap_or ( 0 ) as u128 ) << 64 ) ;
6877
6881
6882
+ let max_accepted_htlcs = max_accepted_htlcs. unwrap_or ( channel_handshake_config. max_accepted_htlcs ) ;
6883
+
6878
6884
Ok ( Channel {
6879
6885
user_id,
6880
6886
0 commit comments