@@ -5384,16 +5384,16 @@ impl<Signer: Sign> Channel<Signer> {
5384
5384
if msg. contents . htlc_minimum_msat >= self . channel_value_satoshis * 1000 {
5385
5385
return Err ( ChannelError :: Close ( "Minimum htlc value is greater than channel value" . to_string ( ) ) ) ;
5386
5386
}
5387
- let htlc_maximum_msat = match msg. contents . htlc_maximum_msat {
5387
+ let outbound_htlc_maximum_msat = match msg. contents . htlc_maximum_msat {
5388
5388
OptionalField :: Present ( htcl_max) => Some ( htcl_max) ,
5389
5389
OptionalField :: Absent => None
5390
5390
} ;
5391
5391
self . counterparty_forwarding_info = Some ( CounterpartyForwardingInfo {
5392
5392
fee_base_msat : msg. contents . fee_base_msat ,
5393
5393
fee_proportional_millionths : msg. contents . fee_proportional_millionths ,
5394
5394
cltv_expiry_delta : msg. contents . cltv_expiry_delta ,
5395
- htlc_minimum_msat : msg. contents . htlc_minimum_msat ,
5396
- htlc_maximum_msat ,
5395
+ outbound_htlc_minimum_msat : msg. contents . htlc_minimum_msat ,
5396
+ outbound_htlc_maximum_msat ,
5397
5397
} ) ;
5398
5398
5399
5399
Ok ( ( ) )
@@ -5780,16 +5780,12 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
5780
5780
// Note that this field is ignored by 0.0.99+ as the TLV Optional variant is used instead.
5781
5781
self . minimum_depth . unwrap_or ( 0 ) . write ( writer) ?;
5782
5782
5783
- let mut htlc_maximum_msat = None ;
5784
5783
match & self . counterparty_forwarding_info {
5785
5784
Some ( info) => {
5786
5785
1u8 . write ( writer) ?;
5787
5786
info. fee_base_msat . write ( writer) ?;
5788
5787
info. fee_proportional_millionths . write ( writer) ?;
5789
5788
info. cltv_expiry_delta . write ( writer) ?;
5790
- // Note that this field is ignored by 0.0.99+ as the TLV Optional variant is used instead.
5791
- info. htlc_maximum_msat . unwrap_or ( 0 ) . write ( writer) ?;
5792
- htlc_maximum_msat = info. htlc_maximum_msat ;
5793
5789
} ,
5794
5790
None => 0u8 . write ( writer) ?
5795
5791
}
@@ -5852,7 +5848,7 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
5852
5848
( 17 , self . announcement_sigs_state, required) ,
5853
5849
( 19 , self . latest_inbound_scid_alias, option) ,
5854
5850
( 21 , self . outbound_scid_alias, required) ,
5855
- ( 23 , htlc_maximum_msat , option) ,
5851
+ ( 23 , self . counterparty_forwarding_info . as_ref ( ) . map ( |info| info . outbound_htlc_maximum_msat ) . unwrap_or ( None ) , option) ,
5856
5852
} ) ;
5857
5853
5858
5854
Ok ( ( ) )
@@ -6051,28 +6047,16 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
6051
6047
let _dummy: u32 = Readable :: read ( reader) ?;
6052
6048
}
6053
6049
6054
- // Read fields for `CounterpartyForwardingInfo`. As the `htlc_maximum_msat` may be
6055
- // updated after the TLV Optional variant has been read depending on if they're used,
6056
- // we construct the `CounterpartyForwardingInfo` struct after TLV Optional variants
6057
- // have been read.
6058
- let mut fee_base_msat: u32 = 0 ;
6059
- let mut fee_proportional_millionths: u32 = 0 ;
6060
- let mut cltv_expiry_delta: u16 = 0 ;
6061
- let mut htlc_maximum_msat = None ;
6062
- let has_forwarding_info = match <u8 as Readable >:: read ( reader) ? {
6063
- 0 => false ,
6050
+ // Read fields for `CounterpartyForwardingInfo`. As the `outbound_htlc_maximum_msat` is a
6051
+ // TLV Optional variant, we construct the `CounterpartyForwardingInfo` struct after it ha
6052
+ // been read.
6053
+ let ( has_forwarding_info, fee_base_msat, fee_proportional_millionths, cltv_expiry_delta) = match <u8 as Readable >:: read ( reader) ? {
6054
+ 0 => ( false , 0 , 0 , 0 ) ,
6064
6055
1 => {
6065
- fee_base_msat = Readable :: read ( reader) ?;
6066
- fee_proportional_millionths = Readable :: read ( reader) ?;
6067
- cltv_expiry_delta = Readable :: read ( reader) ?;
6068
- if ver == 1 {
6069
- // Read the old serialization from version 0.0.98.
6070
- htlc_maximum_msat = Some ( Readable :: read ( reader) ?) ;
6071
- } else {
6072
- // Read the 8 bytes of backwards-compatibility data.
6073
- let _dummy: u64 = Readable :: read ( reader) ?;
6074
- }
6075
- true
6056
+ let fee_base_msat: u32 = Readable :: read ( reader) ?;
6057
+ let fee_proportional_millionths: u32 = Readable :: read ( reader) ?;
6058
+ let cltv_expiry_delta: u16 = Readable :: read ( reader) ?;
6059
+ ( true , fee_base_msat, fee_proportional_millionths, cltv_expiry_delta)
6076
6060
} ,
6077
6061
_ => return Err ( DecodeError :: InvalidValue ) ,
6078
6062
} ;
@@ -6126,6 +6110,7 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
6126
6110
let mut announcement_sigs_state = Some ( AnnouncementSigsState :: NotSent ) ;
6127
6111
let mut latest_inbound_scid_alias = None ;
6128
6112
let mut outbound_scid_alias = None ;
6113
+ let mut outbound_htlc_maximum_msat = None ;
6129
6114
6130
6115
read_tlv_fields ! ( reader, {
6131
6116
( 0 , announcement_sigs, option) ,
@@ -6143,19 +6128,19 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
6143
6128
( 17 , announcement_sigs_state, option) ,
6144
6129
( 19 , latest_inbound_scid_alias, option) ,
6145
6130
( 21 , outbound_scid_alias, option) ,
6146
- ( 23 , htlc_maximum_msat , option) ,
6131
+ ( 23 , outbound_htlc_maximum_msat , option) ,
6147
6132
} ) ;
6148
6133
6149
6134
// Construct the `CounterpartyForwardingInfo` after the TLV Optional variant for
6150
- // `htlc_maximum_msat ` has been read.
6135
+ // `outbound_htlc_maximum_msat ` has been read.
6151
6136
let counterparty_forwarding_info = match has_forwarding_info {
6152
6137
false => None ,
6153
6138
true => Some ( CounterpartyForwardingInfo {
6154
6139
fee_base_msat,
6155
6140
fee_proportional_millionths,
6156
6141
cltv_expiry_delta,
6157
- htlc_minimum_msat : counterparty_htlc_minimum_msat,
6158
- htlc_maximum_msat
6142
+ outbound_htlc_minimum_msat : counterparty_htlc_minimum_msat,
6143
+ outbound_htlc_maximum_msat
6159
6144
} )
6160
6145
} ;
6161
6146
0 commit comments