@@ -751,6 +751,38 @@ pub fn update_nodes_with_chan_announce<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, '
751751 }
752752}
753753
754+ 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 ) {
755+ if nodes[ a] . node . get_current_default_configuration ( ) . channel_options . announced_channel {
756+ panic ! ( "`Nodes[a]` must have channel_options.announced_channel set to false" )
757+ }
758+ nodes[ a] . node . create_channel ( nodes[ b] . node . get_our_node_id ( ) , channel_value, push_msat, 42 , None ) . unwrap ( ) ;
759+ let open_channel = get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendOpenChannel , nodes[ b] . node. get_our_node_id( ) ) ;
760+ nodes[ b] . node . handle_open_channel ( & nodes[ a] . node . get_our_node_id ( ) , a_flags, & open_channel) ;
761+ let accept_channel = get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendAcceptChannel , nodes[ a] . node. get_our_node_id( ) ) ;
762+ nodes[ a] . node . handle_accept_channel ( & nodes[ b] . node . get_our_node_id ( ) , b_flags, & accept_channel) ;
763+
764+ let ( temporary_channel_id, tx, _) = create_funding_transaction ( & nodes[ a] , channel_value, 42 ) ;
765+ nodes[ a] . node . funding_transaction_generated ( & temporary_channel_id, tx. clone ( ) ) . unwrap ( ) ;
766+ 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( ) ) ) ;
767+ check_added_monitors ! ( nodes[ b] , 1 ) ;
768+
769+ let cs_funding_signed = get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendFundingSigned , nodes[ a] . node. get_our_node_id( ) ) ;
770+ nodes[ a] . node . handle_funding_signed ( & nodes[ b] . node . get_our_node_id ( ) , & cs_funding_signed) ;
771+ check_added_monitors ! ( nodes[ a] , 1 ) ;
772+
773+ let conf_height = core:: cmp:: max ( nodes[ a] . best_block_info ( ) . 1 + 1 , nodes[ b] . best_block_info ( ) . 1 + 1 ) ;
774+ confirm_transaction_at ( & nodes[ a] , & tx, conf_height) ;
775+ connect_blocks ( & nodes[ a] , CHAN_CONFIRM_DEPTH - 1 ) ;
776+ confirm_transaction_at ( & nodes[ b] , & tx, conf_height) ;
777+ connect_blocks ( & nodes[ b] , CHAN_CONFIRM_DEPTH - 1 ) ;
778+ let as_funding_locked = get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendFundingLocked , nodes[ b] . node. get_our_node_id( ) ) ;
779+ 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( ) ) ) ;
780+ let a_update = get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendChannelUpdate , nodes[ b] . node. get_our_node_id( ) ) ;
781+ nodes[ b] . node . handle_funding_locked ( & nodes[ a] . node . get_our_node_id ( ) , & as_funding_locked) ;
782+ let b_update = get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendChannelUpdate , nodes[ a] . node. get_our_node_id( ) ) ;
783+ ( a_update, b_update, as_funding_locked. channel_id . clone ( ) , tx)
784+ }
785+
754786#[ macro_export]
755787macro_rules! check_spends {
756788 ( $tx: expr, $( $spends_txn: expr) ,* ) => {
0 commit comments