@@ -624,8 +624,8 @@ pub struct UnsignedChannelUpdate {
624
624
pub cltv_expiry_delta : u16 ,
625
625
/// The minimum HTLC size incoming to sender, in milli-satoshi
626
626
pub htlc_minimum_msat : u64 ,
627
- /// Optionally, the maximum HTLC value incoming to sender, in milli-satoshi
628
- pub htlc_maximum_msat : OptionalField < u64 > ,
627
+ /// The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
628
+ pub htlc_maximum_msat : u64 ,
629
629
/// The base HTLC fee charged by sender, in milli-satoshi
630
630
pub fee_base_msat : u32 ,
631
631
/// The amount to fee multiplier, in micro-satoshi
@@ -1491,14 +1491,12 @@ impl_writeable!(ChannelAnnouncement, {
1491
1491
1492
1492
impl Writeable for UnsignedChannelUpdate {
1493
1493
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
1494
- let mut message_flags: u8 = 0 ;
1495
- if let OptionalField :: Present ( _) = self . htlc_maximum_msat {
1496
- message_flags = 1 ;
1497
- }
1494
+ // `must_be_one` used to be `message_flags` but was deprecated in the spec.
1495
+ const MUST_BE_ONE : u8 = 1 ;
1498
1496
self . chain_hash . write ( w) ?;
1499
1497
self . short_channel_id . write ( w) ?;
1500
1498
self . timestamp . write ( w) ?;
1501
- let all_flags = self . flags as u16 | ( ( message_flags as u16 ) << 8 ) ;
1499
+ let all_flags = self . flags as u16 | ( ( MUST_BE_ONE as u16 ) << 8 ) ;
1502
1500
all_flags. write ( w) ?;
1503
1501
self . cltv_expiry_delta . write ( w) ?;
1504
1502
self . htlc_minimum_msat . write ( w) ?;
@@ -1512,22 +1510,20 @@ impl Writeable for UnsignedChannelUpdate {
1512
1510
1513
1511
impl Readable for UnsignedChannelUpdate {
1514
1512
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1515
- let has_htlc_maximum_msat;
1516
1513
Ok ( Self {
1517
1514
chain_hash : Readable :: read ( r) ?,
1518
1515
short_channel_id : Readable :: read ( r) ?,
1519
1516
timestamp : Readable :: read ( r) ?,
1520
1517
flags : {
1521
1518
let flags: u16 = Readable :: read ( r) ?;
1522
- let message_flags = flags >> 8 ;
1523
- has_htlc_maximum_msat = ( message_flags as i32 & 1 ) == 1 ;
1519
+ // Note: we ignore `must_be_one`, formely `message_flags`, since it was deprecated by the spec.
1524
1520
flags as u8
1525
1521
} ,
1526
1522
cltv_expiry_delta : Readable :: read ( r) ?,
1527
1523
htlc_minimum_msat : Readable :: read ( r) ?,
1528
1524
fee_base_msat : Readable :: read ( r) ?,
1529
1525
fee_proportional_millionths : Readable :: read ( r) ?,
1530
- htlc_maximum_msat : if has_htlc_maximum_msat { Readable :: read ( r) ? } else { OptionalField :: Absent } ,
1526
+ htlc_maximum_msat : Readable :: read ( r) ?,
1531
1527
excess_data : read_to_end ( r) ?,
1532
1528
} )
1533
1529
}
@@ -2069,7 +2065,7 @@ mod tests {
2069
2065
do_encoding_node_announcement ( false , false , true , false , true , false , false ) ;
2070
2066
}
2071
2067
2072
- fn do_encoding_channel_update ( direction : bool , disable : bool , htlc_maximum_msat : bool , excess_data : bool ) {
2068
+ fn do_encoding_channel_update ( direction : bool , disable : bool , excess_data : bool ) {
2073
2069
let secp_ctx = Secp256k1 :: new ( ) ;
2074
2070
let ( privkey_1, _) = get_keys_from ! ( "0101010101010101010101010101010101010101010101010101010101010101" , secp_ctx) ;
2075
2071
let sig_1 = get_sig_on ! ( privkey_1, secp_ctx, String :: from( "01010101010101010101010101010101" ) ) ;
@@ -2080,7 +2076,7 @@ mod tests {
2080
2076
flags : if direction { 1 } else { 0 } | if disable { 1 << 1 } else { 0 } ,
2081
2077
cltv_expiry_delta : 144 ,
2082
2078
htlc_minimum_msat : 1000000 ,
2083
- htlc_maximum_msat : if htlc_maximum_msat { OptionalField :: Present ( 131355275467161 ) } else { OptionalField :: Absent } ,
2079
+ htlc_maximum_msat : 131355275467161 ,
2084
2080
fee_base_msat : 10000 ,
2085
2081
fee_proportional_millionths : 20 ,
2086
2082
excess_data : if excess_data { vec ! [ 0 , 0 , 0 , 0 , 59 , 154 , 202 , 0 ] } else { Vec :: new ( ) }
@@ -2093,11 +2089,7 @@ mod tests {
2093
2089
let mut target_value = hex:: decode ( "d977cb9b53d93a6ff64bb5f1e158b4094b66e798fb12911168a3ccdf80a83096340a6a95da0ae8d9f776528eecdbb747eb6b545495a4319ed5378e35b21e073a" ) . unwrap ( ) ;
2094
2090
target_value. append ( & mut hex:: decode ( "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" ) . unwrap ( ) ) ;
2095
2091
target_value. append ( & mut hex:: decode ( "00083a840000034d013413a7" ) . unwrap ( ) ) ;
2096
- if htlc_maximum_msat {
2097
- target_value. append ( & mut hex:: decode ( "01" ) . unwrap ( ) ) ;
2098
- } else {
2099
- target_value. append ( & mut hex:: decode ( "00" ) . unwrap ( ) ) ;
2100
- }
2092
+ target_value. append ( & mut hex:: decode ( "01" ) . unwrap ( ) ) ;
2101
2093
target_value. append ( & mut hex:: decode ( "00" ) . unwrap ( ) ) ;
2102
2094
if direction {
2103
2095
let flag = target_value. last_mut ( ) . unwrap ( ) ;
@@ -2108,9 +2100,7 @@ mod tests {
2108
2100
* flag = * flag | 1 << 1 ;
2109
2101
}
2110
2102
target_value. append ( & mut hex:: decode ( "009000000000000f42400000271000000014" ) . unwrap ( ) ) ;
2111
- if htlc_maximum_msat {
2112
- target_value. append ( & mut hex:: decode ( "0000777788889999" ) . unwrap ( ) ) ;
2113
- }
2103
+ target_value. append ( & mut hex:: decode ( "0000777788889999" ) . unwrap ( ) ) ;
2114
2104
if excess_data {
2115
2105
target_value. append ( & mut hex:: decode ( "000000003b9aca00" ) . unwrap ( ) ) ;
2116
2106
}
@@ -2119,16 +2109,16 @@ mod tests {
2119
2109
2120
2110
#[ test]
2121
2111
fn encoding_channel_update ( ) {
2122
- do_encoding_channel_update ( false , false , false , false ) ;
2123
- do_encoding_channel_update ( false , false , false , true ) ;
2124
- do_encoding_channel_update ( true , false , false , false ) ;
2125
- do_encoding_channel_update ( true , false , false , true ) ;
2126
- do_encoding_channel_update ( false , true , false , false ) ;
2127
- do_encoding_channel_update ( false , true , false , true ) ;
2128
- do_encoding_channel_update ( false , false , true , false ) ;
2129
- do_encoding_channel_update ( false , false , true , true ) ;
2130
- do_encoding_channel_update ( true , true , true , false ) ;
2131
- do_encoding_channel_update ( true , true , true , true ) ;
2112
+ do_encoding_channel_update ( false , false , false ) ;
2113
+ do_encoding_channel_update ( false , false , true ) ;
2114
+ do_encoding_channel_update ( true , false , false ) ;
2115
+ do_encoding_channel_update ( true , false , true ) ;
2116
+ do_encoding_channel_update ( false , true , false ) ;
2117
+ do_encoding_channel_update ( false , true , true ) ;
2118
+ do_encoding_channel_update ( false , false , false ) ;
2119
+ do_encoding_channel_update ( false , false , true ) ;
2120
+ do_encoding_channel_update ( true , true , false ) ;
2121
+ do_encoding_channel_update ( true , true , true ) ;
2132
2122
}
2133
2123
2134
2124
fn do_encoding_open_channel ( random_bit : bool , shutdown : bool , incl_chan_type : bool ) {
0 commit comments