@@ -980,20 +980,6 @@ impl Node {
980
980
return Err ( Error :: InsufficientFunds ) ;
981
981
}
982
982
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
-
997
983
let channel_config = ( * ( channel_config. unwrap_or_default ( ) ) ) . clone ( ) . into ( ) ;
998
984
let user_config = UserConfig {
999
985
channel_handshake_limits : Default :: default ( ) ,
@@ -1007,14 +993,41 @@ impl Node {
1007
993
1008
994
let push_msat = push_to_counterparty_msat. unwrap_or ( 0 ) ;
1009
995
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
+ } ) ?;
1010
1023
1011
1024
match self . channel_manager . create_channel (
1012
1025
peer_info. node_id ,
1013
1026
channel_amount_sats,
1014
1027
push_msat,
1015
1028
user_channel_id,
1016
1029
None ,
1017
- Some ( user_config) ,
1030
+ user_config,
1018
1031
) {
1019
1032
Ok ( _) => {
1020
1033
log_info ! (
0 commit comments