@@ -738,6 +738,38 @@ pub fn update_nodes_with_chan_announce<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, '
738738 }
739739}
740740
741+ pub fn create_private_chan_between_nodes_with_value < ' a , ' b , ' c , ' d > ( nodes : & ' a Vec < Node < ' b , ' c , ' d > > , a : usize , b : usize , channel_value : u64 , push_msat : u64 , a_flags : InitFeatures , b_flags : InitFeatures ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
742+ if nodes[ a] . node . get_current_default_configuration ( ) . channel_options . announced_channel {
743+ panic ! ( "`Nodes[a]` must have channel_options.announced_channel set to false" )
744+ }
745+ nodes[ a] . node . create_channel ( nodes[ b] . node . get_our_node_id ( ) , channel_value, push_msat, 42 , None ) . unwrap ( ) ;
746+ let open_channel = get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendOpenChannel , nodes[ b] . node. get_our_node_id( ) ) ;
747+ nodes[ b] . node . handle_open_channel ( & nodes[ a] . node . get_our_node_id ( ) , a_flags, & open_channel) ;
748+ let accept_channel = get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendAcceptChannel , nodes[ a] . node. get_our_node_id( ) ) ;
749+ nodes[ a] . node . handle_accept_channel ( & nodes[ b] . node . get_our_node_id ( ) , b_flags, & accept_channel) ;
750+
751+ let ( temporary_channel_id, tx, _) = create_funding_transaction ( & nodes[ a] , channel_value, 42 ) ;
752+ nodes[ a] . node . funding_transaction_generated ( & temporary_channel_id, tx. clone ( ) ) . unwrap ( ) ;
753+ nodes[ b] . node . handle_funding_created ( & nodes[ a] . node . get_our_node_id ( ) , & get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendFundingCreated , nodes[ b] . node. get_our_node_id( ) ) ) ;
754+ check_added_monitors ! ( nodes[ b] , 1 ) ;
755+
756+ let cs_funding_signed = get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendFundingSigned , nodes[ a] . node. get_our_node_id( ) ) ;
757+ nodes[ a] . node . handle_funding_signed ( & nodes[ b] . node . get_our_node_id ( ) , & cs_funding_signed) ;
758+ check_added_monitors ! ( nodes[ a] , 1 ) ;
759+
760+ let conf_height = core:: cmp:: max ( nodes[ a] . best_block_info ( ) . 1 + 1 , nodes[ b] . best_block_info ( ) . 1 + 1 ) ;
761+ confirm_transaction_at ( & nodes[ a] , & tx, conf_height) ;
762+ connect_blocks ( & nodes[ a] , CHAN_CONFIRM_DEPTH - 1 ) ;
763+ confirm_transaction_at ( & nodes[ b] , & tx, conf_height) ;
764+ connect_blocks ( & nodes[ b] , CHAN_CONFIRM_DEPTH - 1 ) ;
765+ let as_funding_locked = get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendFundingLocked , nodes[ b] . node. get_our_node_id( ) ) ;
766+ nodes[ a] . node . handle_funding_locked ( & nodes[ b] . node . get_our_node_id ( ) , & get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendFundingLocked , nodes[ a] . node. get_our_node_id( ) ) ) ;
767+ let a_update = get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendChannelUpdate , nodes[ b] . node. get_our_node_id( ) ) ;
768+ nodes[ b] . node . handle_funding_locked ( & nodes[ a] . node . get_our_node_id ( ) , & as_funding_locked) ;
769+ let b_update = get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendChannelUpdate , nodes[ a] . node. get_our_node_id( ) ) ;
770+ ( a_update, b_update, as_funding_locked. channel_id . clone ( ) , tx)
771+ }
772+
741773#[ macro_export]
742774macro_rules! check_spends {
743775 ( $tx: expr, $( $spends_txn: expr) ,* ) => {
0 commit comments