@@ -251,7 +251,7 @@ pub struct OpenChannelV2 {
251
251
pub channel_flags : u8 ,
252
252
/// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
253
253
/// collaboratively close
254
- pub shutdown_scriptpubkey : OptionalField < Script > ,
254
+ pub shutdown_scriptpubkey : Option < Script > ,
255
255
/// The channel type that this channel will represent. If none is set, we derive the channel
256
256
/// type from the intersection of our feature bits with our counterparty's feature bits from
257
257
/// the Init message.
@@ -343,7 +343,7 @@ pub struct AcceptChannelV2 {
343
343
pub first_per_commitment_point : PublicKey ,
344
344
/// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
345
345
/// collaboratively close
346
- pub shutdown_scriptpubkey : OptionalField < Script > ,
346
+ pub shutdown_scriptpubkey : Option < Script > ,
347
347
/// The channel type that this channel will represent. If none is set, we derive the channel
348
348
/// type from the intersection of our feature bits with our counterparty's feature bits from
349
349
/// the Init message.
@@ -1563,8 +1563,8 @@ impl_writeable_msg!(AcceptChannelV2, {
1563
1563
delayed_payment_basepoint,
1564
1564
htlc_basepoint,
1565
1565
first_per_commitment_point,
1566
- shutdown_scriptpubkey
1567
1566
} , {
1567
+ ( 0 , shutdown_scriptpubkey, option) ,
1568
1568
( 1 , channel_type, option) ,
1569
1569
( 2 , require_confirmed_inputs, option) ,
1570
1570
} ) ;
@@ -1801,8 +1801,8 @@ impl_writeable_msg!(OpenChannelV2, {
1801
1801
first_per_commitment_point,
1802
1802
second_per_commitment_point,
1803
1803
channel_flags,
1804
- shutdown_scriptpubkey
1805
1804
} , {
1805
+ ( 0 , shutdown_scriptpubkey, option) ,
1806
1806
( 1 , channel_type, option) ,
1807
1807
( 2 , require_confirmed_inputs, option) ,
1808
1808
} ) ;
@@ -2812,7 +2812,7 @@ mod tests {
2812
2812
first_per_commitment_point : pubkey_6,
2813
2813
second_per_commitment_point : pubkey_7,
2814
2814
channel_flags : if random_bit { 1 << 5 } else { 0 } ,
2815
- shutdown_scriptpubkey : if shutdown { OptionalField :: Present ( Address :: p2pkh ( & :: bitcoin:: PublicKey { compressed : true , inner : pubkey_1} , Network :: Testnet ) . script_pubkey ( ) ) } else { OptionalField :: Absent } ,
2815
+ shutdown_scriptpubkey : if shutdown { Some ( Address :: p2pkh ( & :: bitcoin:: PublicKey { compressed : true , inner : pubkey_1} , Network :: Testnet ) . script_pubkey ( ) ) } else { None } ,
2816
2816
channel_type : if incl_chan_type { Some ( ChannelTypeFeatures :: empty ( ) ) } else { None } ,
2817
2817
require_confirmed_inputs : if require_confirmed_inputs { Some ( ( ) ) } else { None } ,
2818
2818
} ;
@@ -2843,6 +2843,7 @@ mod tests {
2843
2843
target_value. append ( & mut hex:: decode ( "00" ) . unwrap ( ) ) ;
2844
2844
}
2845
2845
if shutdown {
2846
+ target_value. append ( & mut hex:: decode ( "001b" ) . unwrap ( ) ) ; // Type 0 + Length 27
2846
2847
target_value. append ( & mut hex:: decode ( "001976a91479b000887626b294a914501a4cd226b58b23598388ac" ) . unwrap ( ) ) ;
2847
2848
}
2848
2849
if incl_chan_type {
@@ -2937,13 +2938,27 @@ mod tests {
2937
2938
delayed_payment_basepoint : pubkey_4,
2938
2939
htlc_basepoint : pubkey_5,
2939
2940
first_per_commitment_point : pubkey_6,
2940
- shutdown_scriptpubkey : if shutdown { OptionalField :: Present ( Address :: p2pkh ( & :: bitcoin:: PublicKey { compressed : true , inner : pubkey_1} , Network :: Testnet ) . script_pubkey ( ) ) } else { OptionalField :: Absent } ,
2941
+ shutdown_scriptpubkey : if shutdown { Some ( Address :: p2pkh ( & :: bitcoin:: PublicKey { compressed : true , inner : pubkey_1} , Network :: Testnet ) . script_pubkey ( ) ) } else { None } ,
2941
2942
channel_type : None ,
2942
2943
require_confirmed_inputs : None ,
2943
2944
} ;
2944
2945
let encoded_value = accept_channelv2. encode ( ) ;
2945
- let mut target_value = hex:: decode ( "020202020202020202020202020202020202020202020202020202020202020212345678901234561234567890123456233403289122369800083a840000034d000c89d4c0bcc0bc031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d076602531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe33703462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f703f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a" ) . unwrap ( ) ;
2946
+ let mut target_value = hex:: decode ( "0202020202020202020202020202020202020202020202020202020202020202" ) . unwrap ( ) ; // temporary_channel_id
2947
+ target_value. append ( & mut hex:: decode ( "1234567890123456" ) . unwrap ( ) ) ; // funding_satoshis
2948
+ target_value. append ( & mut hex:: decode ( "1234567890123456" ) . unwrap ( ) ) ; // dust_limit_satoshis
2949
+ target_value. append ( & mut hex:: decode ( "2334032891223698" ) . unwrap ( ) ) ; // max_htlc_value_in_flight_msat
2950
+ target_value. append ( & mut hex:: decode ( "00083a840000034d" ) . unwrap ( ) ) ; // htlc_minimum_msat
2951
+ target_value. append ( & mut hex:: decode ( "000c89d4" ) . unwrap ( ) ) ; // minimum_depth
2952
+ target_value. append ( & mut hex:: decode ( "c0bc" ) . unwrap ( ) ) ; // to_self_delay
2953
+ target_value. append ( & mut hex:: decode ( "c0bc" ) . unwrap ( ) ) ; // max_accepted_htlcs
2954
+ target_value. append ( & mut hex:: decode ( "031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f" ) . unwrap ( ) ) ; // funding_pubkey
2955
+ target_value. append ( & mut hex:: decode ( "024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d0766" ) . unwrap ( ) ) ; // revocation_basepoint
2956
+ target_value. append ( & mut hex:: decode ( "02531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe337" ) . unwrap ( ) ) ; // payment_basepoint
2957
+ target_value. append ( & mut hex:: decode ( "03462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b" ) . unwrap ( ) ) ; // delayed_payment_basepoint
2958
+ target_value. append ( & mut hex:: decode ( "0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f7" ) . unwrap ( ) ) ; // htlc_basepoint
2959
+ target_value. append ( & mut hex:: decode ( "03f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a" ) . unwrap ( ) ) ; // first_per_commitment_point
2946
2960
if shutdown {
2961
+ target_value. append ( & mut hex:: decode ( "001b" ) . unwrap ( ) ) ; // Type 0 + Length 27
2947
2962
target_value. append ( & mut hex:: decode ( "001976a91479b000887626b294a914501a4cd226b58b23598388ac" ) . unwrap ( ) ) ;
2948
2963
}
2949
2964
assert_eq ! ( encoded_value, target_value) ;
0 commit comments