@@ -222,6 +222,8 @@ pub struct OpenChannelV2 {
222222 pub htlc_basepoint : PublicKey ,
223223 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
224224 pub first_per_commitment_point : PublicKey ,
225+ /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
226+ pub second_per_commitment_point : PublicKey ,
225227 /// Channel flags
226228 pub channel_flags : u8 ,
227229 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
@@ -231,6 +233,8 @@ pub struct OpenChannelV2 {
231233 /// type from the intersection of our feature bits with our counterparty's feature bits from
232234 /// the Init message.
233235 pub channel_type : Option < ChannelTypeFeatures > ,
236+ /// Optionally, a requirement that only confirmed inputs can be added
237+ pub require_confirmed_inputs : Option < ( ) > ,
234238}
235239
236240/// An accept_channel message to be sent or received from a peer.
@@ -1707,10 +1711,12 @@ impl_writeable_msg!(OpenChannelV2, {
17071711 delayed_payment_basepoint,
17081712 htlc_basepoint,
17091713 first_per_commitment_point,
1714+ second_per_commitment_point,
17101715 channel_flags,
17111716 shutdown_scriptpubkey
17121717} , {
17131718 ( 1 , channel_type, option) ,
1719+ ( 2 , require_confirmed_inputs, option) ,
17141720} ) ;
17151721
17161722impl_writeable_msg ! ( RevokeAndACK , {
@@ -2690,14 +2696,15 @@ mod tests {
26902696 do_encoding_open_channel ( true , true , true ) ;
26912697 }
26922698
2693- fn do_encoding_open_channelv2 ( random_bit : bool , shutdown : bool , incl_chan_type : bool ) {
2699+ fn do_encoding_open_channelv2 ( random_bit : bool , shutdown : bool , incl_chan_type : bool , require_confirmed_inputs : bool ) {
26942700 let secp_ctx = Secp256k1 :: new ( ) ;
26952701 let ( _, pubkey_1) = get_keys_from ! ( "0101010101010101010101010101010101010101010101010101010101010101" , secp_ctx) ;
26962702 let ( _, pubkey_2) = get_keys_from ! ( "0202020202020202020202020202020202020202020202020202020202020202" , secp_ctx) ;
26972703 let ( _, pubkey_3) = get_keys_from ! ( "0303030303030303030303030303030303030303030303030303030303030303" , secp_ctx) ;
26982704 let ( _, pubkey_4) = get_keys_from ! ( "0404040404040404040404040404040404040404040404040404040404040404" , secp_ctx) ;
26992705 let ( _, pubkey_5) = get_keys_from ! ( "0505050505050505050505050505050505050505050505050505050505050505" , secp_ctx) ;
27002706 let ( _, pubkey_6) = get_keys_from ! ( "0606060606060606060606060606060606060606060606060606060606060606" , secp_ctx) ;
2707+ let ( _, pubkey_7) = get_keys_from ! ( "0707070707070707070707070707070707070707070707070707070707070707" , secp_ctx) ;
27012708 let open_channelv2 = msgs:: OpenChannelV2 {
27022709 chain_hash : BlockHash :: from_hex ( "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000" ) . unwrap ( ) ,
27032710 temporary_channel_id : [ 2 ; 32 ] ,
@@ -2716,14 +2723,33 @@ mod tests {
27162723 delayed_payment_basepoint : pubkey_4,
27172724 htlc_basepoint : pubkey_5,
27182725 first_per_commitment_point : pubkey_6,
2726+ second_per_commitment_point : pubkey_7,
27192727 channel_flags : if random_bit { 1 << 5 } else { 0 } ,
27202728 shutdown_scriptpubkey : if shutdown { OptionalField :: Present ( Address :: p2pkh ( & :: bitcoin:: PublicKey { compressed : true , inner : pubkey_1} , Network :: Testnet ) . script_pubkey ( ) ) } else { OptionalField :: Absent } ,
27212729 channel_type : if incl_chan_type { Some ( ChannelTypeFeatures :: empty ( ) ) } else { None } ,
2730+ require_confirmed_inputs : if require_confirmed_inputs { Some ( ( ) ) } else { None } ,
27222731 } ;
27232732 let encoded_value = open_channelv2. encode ( ) ;
27242733 let mut target_value = Vec :: new ( ) ;
27252734 target_value. append ( & mut hex:: decode ( "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" ) . unwrap ( ) ) ;
2726- target_value. append ( & mut hex:: decode ( "0202020202020202020202020202020202020202020202020202020202020202000c89d4000c89d412345678901234563214466870114476763303089620319800083a840000034dc0bcc0bc12345678031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d076602531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe33703462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f703f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a" ) . unwrap ( ) ) ;
2735+ target_value. append ( & mut hex:: decode ( "0202020202020202020202020202020202020202020202020202020202020202" ) . unwrap ( ) ) ;
2736+ target_value. append ( & mut hex:: decode ( "000c89d4" ) . unwrap ( ) ) ;
2737+ target_value. append ( & mut hex:: decode ( "000c89d4" ) . unwrap ( ) ) ;
2738+ target_value. append ( & mut hex:: decode ( "1234567890123456" ) . unwrap ( ) ) ;
2739+ target_value. append ( & mut hex:: decode ( "3214466870114476" ) . unwrap ( ) ) ;
2740+ target_value. append ( & mut hex:: decode ( "7633030896203198" ) . unwrap ( ) ) ;
2741+ target_value. append ( & mut hex:: decode ( "00083a840000034d" ) . unwrap ( ) ) ;
2742+ target_value. append ( & mut hex:: decode ( "c0bc" ) . unwrap ( ) ) ;
2743+ target_value. append ( & mut hex:: decode ( "c0bc" ) . unwrap ( ) ) ;
2744+ target_value. append ( & mut hex:: decode ( "12345678" ) . unwrap ( ) ) ;
2745+ target_value. append ( & mut hex:: decode ( "031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f" ) . unwrap ( ) ) ;
2746+ target_value. append ( & mut hex:: decode ( "024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d0766" ) . unwrap ( ) ) ;
2747+ target_value. append ( & mut hex:: decode ( "02531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe337" ) . unwrap ( ) ) ;
2748+ target_value. append ( & mut hex:: decode ( "03462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b" ) . unwrap ( ) ) ;
2749+ target_value. append ( & mut hex:: decode ( "0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f7" ) . unwrap ( ) ) ;
2750+ target_value. append ( & mut hex:: decode ( "03f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a" ) . unwrap ( ) ) ;
2751+ target_value. append ( & mut hex:: decode ( "02989c0b76cb563971fdc9bef31ec06c3560f3249d6ee9e5d83c57625596e05f6f" ) . unwrap ( ) ) ;
2752+
27272753 if random_bit {
27282754 target_value. append ( & mut hex:: decode ( "20" ) . unwrap ( ) ) ;
27292755 } else {
@@ -2735,19 +2761,30 @@ mod tests {
27352761 if incl_chan_type {
27362762 target_value. append ( & mut hex:: decode ( "0100" ) . unwrap ( ) ) ;
27372763 }
2764+ if require_confirmed_inputs {
2765+ target_value. append ( & mut hex:: decode ( "0200" ) . unwrap ( ) ) ;
2766+ }
27382767 assert_eq ! ( encoded_value, target_value) ;
27392768 }
27402769
27412770 #[ test]
27422771 fn encoding_open_channelv2 ( ) {
2743- do_encoding_open_channelv2 ( false , false , false ) ;
2744- do_encoding_open_channelv2 ( false , false , true ) ;
2745- do_encoding_open_channelv2 ( false , true , false ) ;
2746- do_encoding_open_channelv2 ( false , true , true ) ;
2747- do_encoding_open_channelv2 ( true , false , false ) ;
2748- do_encoding_open_channelv2 ( true , false , true ) ;
2749- do_encoding_open_channelv2 ( true , true , false ) ;
2750- do_encoding_open_channelv2 ( true , true , true ) ;
2772+ do_encoding_open_channelv2 ( false , false , false , false ) ;
2773+ do_encoding_open_channelv2 ( false , false , false , true ) ;
2774+ do_encoding_open_channelv2 ( false , false , true , false ) ;
2775+ do_encoding_open_channelv2 ( false , false , true , true ) ;
2776+ do_encoding_open_channelv2 ( false , true , false , false ) ;
2777+ do_encoding_open_channelv2 ( false , true , false , true ) ;
2778+ do_encoding_open_channelv2 ( false , true , true , false ) ;
2779+ do_encoding_open_channelv2 ( false , true , true , true ) ;
2780+ do_encoding_open_channelv2 ( true , false , false , false ) ;
2781+ do_encoding_open_channelv2 ( true , false , false , true ) ;
2782+ do_encoding_open_channelv2 ( true , false , true , false ) ;
2783+ do_encoding_open_channelv2 ( true , false , true , true ) ;
2784+ do_encoding_open_channelv2 ( true , true , false , false ) ;
2785+ do_encoding_open_channelv2 ( true , true , false , true ) ;
2786+ do_encoding_open_channelv2 ( true , true , true , false ) ;
2787+ do_encoding_open_channelv2 ( true , true , true , true ) ;
27512788 }
27522789
27532790 fn do_encoding_accept_channel ( shutdown : bool ) {
0 commit comments