@@ -647,8 +647,8 @@ pub struct UnsignedChannelUpdate {
647
647
pub cltv_expiry_delta : u16 ,
648
648
/// The minimum HTLC size incoming to sender, in milli-satoshi
649
649
pub htlc_minimum_msat : u64 ,
650
- /// Optionally, the maximum HTLC value incoming to sender, in milli-satoshi
651
- pub htlc_maximum_msat : OptionalField < u64 > ,
650
+ /// The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
651
+ pub htlc_maximum_msat : u64 ,
652
652
/// The base HTLC fee charged by sender, in milli-satoshi
653
653
pub fee_base_msat : u32 ,
654
654
/// The amount to fee multiplier, in micro-satoshi
@@ -1514,14 +1514,12 @@ impl_writeable!(ChannelAnnouncement, {
1514
1514
1515
1515
impl Writeable for UnsignedChannelUpdate {
1516
1516
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
1517
- let mut message_flags: u8 = 0 ;
1518
- if let OptionalField :: Present ( _) = self . htlc_maximum_msat {
1519
- message_flags = 1 ;
1520
- }
1517
+ // `message_flags` used to indicate presence of `htlc_maximum_msat`, but was deprecated in the spec.
1518
+ const MESSAGE_FLAGS : u8 = 1 ;
1521
1519
self . chain_hash . write ( w) ?;
1522
1520
self . short_channel_id . write ( w) ?;
1523
1521
self . timestamp . write ( w) ?;
1524
- let all_flags = self . flags as u16 | ( ( message_flags as u16 ) << 8 ) ;
1522
+ let all_flags = self . flags as u16 | ( ( MESSAGE_FLAGS as u16 ) << 8 ) ;
1525
1523
all_flags. write ( w) ?;
1526
1524
self . cltv_expiry_delta . write ( w) ?;
1527
1525
self . htlc_minimum_msat . write ( w) ?;
@@ -1535,22 +1533,20 @@ impl Writeable for UnsignedChannelUpdate {
1535
1533
1536
1534
impl Readable for UnsignedChannelUpdate {
1537
1535
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1538
- let has_htlc_maximum_msat;
1539
1536
Ok ( Self {
1540
1537
chain_hash : Readable :: read ( r) ?,
1541
1538
short_channel_id : Readable :: read ( r) ?,
1542
1539
timestamp : Readable :: read ( r) ?,
1543
1540
flags : {
1544
1541
let flags: u16 = Readable :: read ( r) ?;
1545
- let message_flags = flags >> 8 ;
1546
- has_htlc_maximum_msat = ( message_flags as i32 & 1 ) == 1 ;
1542
+ // Note: we ignore the `message_flags` for now, since it was deprecated by the spec.
1547
1543
flags as u8
1548
1544
} ,
1549
1545
cltv_expiry_delta : Readable :: read ( r) ?,
1550
1546
htlc_minimum_msat : Readable :: read ( r) ?,
1551
1547
fee_base_msat : Readable :: read ( r) ?,
1552
1548
fee_proportional_millionths : Readable :: read ( r) ?,
1553
- htlc_maximum_msat : if has_htlc_maximum_msat { Readable :: read ( r) ? } else { OptionalField :: Absent } ,
1549
+ htlc_maximum_msat : Readable :: read ( r) ?,
1554
1550
excess_data : read_to_end ( r) ?,
1555
1551
} )
1556
1552
}
@@ -2103,7 +2099,7 @@ mod tests {
2103
2099
do_encoding_node_announcement ( false , false , true , false , true , false , false , false ) ;
2104
2100
}
2105
2101
2106
- fn do_encoding_channel_update ( direction : bool , disable : bool , htlc_maximum_msat : bool , excess_data : bool ) {
2102
+ fn do_encoding_channel_update ( direction : bool , disable : bool , excess_data : bool ) {
2107
2103
let secp_ctx = Secp256k1 :: new ( ) ;
2108
2104
let ( privkey_1, _) = get_keys_from ! ( "0101010101010101010101010101010101010101010101010101010101010101" , secp_ctx) ;
2109
2105
let sig_1 = get_sig_on ! ( privkey_1, secp_ctx, String :: from( "01010101010101010101010101010101" ) ) ;
@@ -2114,7 +2110,7 @@ mod tests {
2114
2110
flags : if direction { 1 } else { 0 } | if disable { 1 << 1 } else { 0 } ,
2115
2111
cltv_expiry_delta : 144 ,
2116
2112
htlc_minimum_msat : 1000000 ,
2117
- htlc_maximum_msat : if htlc_maximum_msat { OptionalField :: Present ( 131355275467161 ) } else { OptionalField :: Absent } ,
2113
+ htlc_maximum_msat : 131355275467161 ,
2118
2114
fee_base_msat : 10000 ,
2119
2115
fee_proportional_millionths : 20 ,
2120
2116
excess_data : if excess_data { vec ! [ 0 , 0 , 0 , 0 , 59 , 154 , 202 , 0 ] } else { Vec :: new ( ) }
@@ -2127,11 +2123,7 @@ mod tests {
2127
2123
let mut target_value = hex:: decode ( "d977cb9b53d93a6ff64bb5f1e158b4094b66e798fb12911168a3ccdf80a83096340a6a95da0ae8d9f776528eecdbb747eb6b545495a4319ed5378e35b21e073a" ) . unwrap ( ) ;
2128
2124
target_value. append ( & mut hex:: decode ( "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" ) . unwrap ( ) ) ;
2129
2125
target_value. append ( & mut hex:: decode ( "00083a840000034d013413a7" ) . unwrap ( ) ) ;
2130
- if htlc_maximum_msat {
2131
- target_value. append ( & mut hex:: decode ( "01" ) . unwrap ( ) ) ;
2132
- } else {
2133
- target_value. append ( & mut hex:: decode ( "00" ) . unwrap ( ) ) ;
2134
- }
2126
+ target_value. append ( & mut hex:: decode ( "01" ) . unwrap ( ) ) ;
2135
2127
target_value. append ( & mut hex:: decode ( "00" ) . unwrap ( ) ) ;
2136
2128
if direction {
2137
2129
let flag = target_value. last_mut ( ) . unwrap ( ) ;
@@ -2142,9 +2134,7 @@ mod tests {
2142
2134
* flag = * flag | 1 << 1 ;
2143
2135
}
2144
2136
target_value. append ( & mut hex:: decode ( "009000000000000f42400000271000000014" ) . unwrap ( ) ) ;
2145
- if htlc_maximum_msat {
2146
- target_value. append ( & mut hex:: decode ( "0000777788889999" ) . unwrap ( ) ) ;
2147
- }
2137
+ target_value. append ( & mut hex:: decode ( "0000777788889999" ) . unwrap ( ) ) ;
2148
2138
if excess_data {
2149
2139
target_value. append ( & mut hex:: decode ( "000000003b9aca00" ) . unwrap ( ) ) ;
2150
2140
}
@@ -2153,16 +2143,14 @@ mod tests {
2153
2143
2154
2144
#[ test]
2155
2145
fn encoding_channel_update ( ) {
2156
- do_encoding_channel_update ( false , false , false , false ) ;
2157
- do_encoding_channel_update ( false , false , false , true ) ;
2158
- do_encoding_channel_update ( true , false , false , false ) ;
2159
- do_encoding_channel_update ( true , false , false , true ) ;
2160
- do_encoding_channel_update ( false , true , false , false ) ;
2161
- do_encoding_channel_update ( false , true , false , true ) ;
2162
- do_encoding_channel_update ( false , false , true , false ) ;
2163
- do_encoding_channel_update ( false , false , true , true ) ;
2164
- do_encoding_channel_update ( true , true , true , false ) ;
2165
- do_encoding_channel_update ( true , true , true , true ) ;
2146
+ do_encoding_channel_update ( false , false , false ) ;
2147
+ do_encoding_channel_update ( false , false , true ) ;
2148
+ do_encoding_channel_update ( true , false , false ) ;
2149
+ do_encoding_channel_update ( true , false , true ) ;
2150
+ do_encoding_channel_update ( false , true , false ) ;
2151
+ do_encoding_channel_update ( false , true , true ) ;
2152
+ do_encoding_channel_update ( true , true , false ) ;
2153
+ do_encoding_channel_update ( true , true , true ) ;
2166
2154
}
2167
2155
2168
2156
fn do_encoding_open_channel ( random_bit : bool , shutdown : bool , incl_chan_type : bool ) {
0 commit comments