@@ -980,20 +980,6 @@ impl Node {
980980 return Err ( Error :: InsufficientFunds ) ;
981981 }
982982
983- let peer_info = PeerInfo { node_id, address } ;
984-
985- let con_node_id = peer_info. node_id ;
986- let con_addr = peer_info. address . clone ( ) ;
987- let con_cm = Arc :: clone ( & self . connection_manager ) ;
988-
989- // We need to use our main runtime here as a local runtime might not be around to poll
990- // connection futures going forward.
991- tokio:: task:: block_in_place ( move || {
992- runtime. block_on ( async move {
993- con_cm. connect_peer_if_necessary ( con_node_id, con_addr) . await
994- } )
995- } ) ?;
996-
997983 let channel_config = ( * ( channel_config. unwrap_or_default ( ) ) ) . clone ( ) . into ( ) ;
998984 let user_config = UserConfig {
999985 channel_handshake_limits : Default :: default ( ) ,
@@ -1007,14 +993,41 @@ impl Node {
1007993
1008994 let push_msat = push_to_counterparty_msat. unwrap_or ( 0 ) ;
1009995 let user_channel_id: u128 = rand:: thread_rng ( ) . gen :: < u128 > ( ) ;
996+ self . internal_connect_open_channel (
997+ node_id,
998+ channel_amount_sats,
999+ push_msat,
1000+ user_channel_id,
1001+ address,
1002+ Some ( user_config) ,
1003+ runtime,
1004+ )
1005+ }
1006+
1007+ fn internal_connect_open_channel (
1008+ & self , node_id : PublicKey , channel_amount_sats : u64 , push_msat : u64 , user_channel_id : u128 ,
1009+ address : SocketAddress , user_config : Option < UserConfig > , runtime : & tokio:: runtime:: Runtime ,
1010+ ) -> Result < UserChannelId , Error > {
1011+ let peer_info = PeerInfo { node_id, address } ;
1012+ let con_node_id = peer_info. node_id ;
1013+ let con_addr = peer_info. address . clone ( ) ;
1014+ let con_cm = Arc :: clone ( & self . connection_manager ) ;
1015+
1016+ // We need to use our main runtime here as a local runtime might not be around to poll
1017+ // connection futures going forward.
1018+ tokio:: task:: block_in_place ( move || {
1019+ runtime. block_on ( async move {
1020+ con_cm. connect_peer_if_necessary ( con_node_id, con_addr) . await
1021+ } )
1022+ } ) ?;
10101023
10111024 match self . channel_manager . create_channel (
10121025 peer_info. node_id ,
10131026 channel_amount_sats,
10141027 push_msat,
10151028 user_channel_id,
10161029 None ,
1017- Some ( user_config) ,
1030+ user_config,
10181031 ) {
10191032 Ok ( _) => {
10201033 log_info ! (
0 commit comments