@@ -251,7 +251,7 @@ pub struct OpenChannelV2 {
251251 pub channel_flags : u8 ,
252252 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
253253 /// collaboratively close
254- pub shutdown_scriptpubkey : OptionalField < Script > ,
254+ pub shutdown_scriptpubkey : Option < Script > ,
255255 /// The channel type that this channel will represent. If none is set, we derive the channel
256256 /// type from the intersection of our feature bits with our counterparty's feature bits from
257257 /// the Init message.
@@ -343,7 +343,7 @@ pub struct AcceptChannelV2 {
343343 pub first_per_commitment_point : PublicKey ,
344344 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
345345 /// collaboratively close
346- pub shutdown_scriptpubkey : OptionalField < Script > ,
346+ pub shutdown_scriptpubkey : Option < Script > ,
347347 /// The channel type that this channel will represent. If none is set, we derive the channel
348348 /// type from the intersection of our feature bits with our counterparty's feature bits from
349349 /// the Init message.
@@ -1563,8 +1563,8 @@ impl_writeable_msg!(AcceptChannelV2, {
15631563 delayed_payment_basepoint,
15641564 htlc_basepoint,
15651565 first_per_commitment_point,
1566- shutdown_scriptpubkey
15671566} , {
1567+ ( 0 , shutdown_scriptpubkey, option) ,
15681568 ( 1 , channel_type, option) ,
15691569 ( 2 , require_confirmed_inputs, option) ,
15701570} ) ;
@@ -1801,8 +1801,8 @@ impl_writeable_msg!(OpenChannelV2, {
18011801 first_per_commitment_point,
18021802 second_per_commitment_point,
18031803 channel_flags,
1804- shutdown_scriptpubkey
18051804} , {
1805+ ( 0 , shutdown_scriptpubkey, option) ,
18061806 ( 1 , channel_type, option) ,
18071807 ( 2 , require_confirmed_inputs, option) ,
18081808} ) ;
@@ -2812,7 +2812,7 @@ mod tests {
28122812 first_per_commitment_point : pubkey_6,
28132813 second_per_commitment_point : pubkey_7,
28142814 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 } ,
28162816 channel_type : if incl_chan_type { Some ( ChannelTypeFeatures :: empty ( ) ) } else { None } ,
28172817 require_confirmed_inputs : if require_confirmed_inputs { Some ( ( ) ) } else { None } ,
28182818 } ;
@@ -2843,6 +2843,7 @@ mod tests {
28432843 target_value. append ( & mut hex:: decode ( "00" ) . unwrap ( ) ) ;
28442844 }
28452845 if shutdown {
2846+ target_value. append ( & mut hex:: decode ( "001b" ) . unwrap ( ) ) ; // Type 0 + Length 27
28462847 target_value. append ( & mut hex:: decode ( "001976a91479b000887626b294a914501a4cd226b58b23598388ac" ) . unwrap ( ) ) ;
28472848 }
28482849 if incl_chan_type {
@@ -2937,13 +2938,27 @@ mod tests {
29372938 delayed_payment_basepoint : pubkey_4,
29382939 htlc_basepoint : pubkey_5,
29392940 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 } ,
29412942 channel_type : None ,
29422943 require_confirmed_inputs : None ,
29432944 } ;
29442945 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
29462960 if shutdown {
2961+ target_value. append ( & mut hex:: decode ( "001b" ) . unwrap ( ) ) ; // Type 0 + Length 27
29472962 target_value. append ( & mut hex:: decode ( "001976a91479b000887626b294a914501a4cd226b58b23598388ac" ) . unwrap ( ) ) ;
29482963 }
29492964 assert_eq ! ( encoded_value, target_value) ;
0 commit comments