@@ -91,6 +91,7 @@ pub struct LdkServerHandle {
9191 pub grpc_port : u16 ,
9292 pub p2p_port : u16 ,
9393 pub storage_dir : PathBuf ,
94+ pub config_path : PathBuf ,
9495 pub api_key : String ,
9596 pub tls_cert_path : PathBuf ,
9697 pub node_id : String ,
@@ -214,6 +215,7 @@ poll_metrics_interval = 1
214215 grpc_port,
215216 p2p_port,
216217 storage_dir,
218+ config_path,
217219 api_key,
218220 tls_cert_path,
219221 node_id : String :: new ( ) ,
@@ -381,13 +383,42 @@ pub fn run_cli_raw(handle: &LdkServerHandle, args: &[&str]) -> String {
381383 String :: from_utf8 ( output. stdout ) . unwrap ( )
382384}
383385
386+ /// Run a CLI command using the server's config file for connection details.
387+ pub fn run_cli_with_config_raw ( handle : & LdkServerHandle , args : & [ & str ] ) -> String {
388+ let cli_path = cli_binary_path ( ) ;
389+ let output = Command :: new ( & cli_path)
390+ . arg ( "--config" )
391+ . arg ( handle. config_path . to_str ( ) . unwrap ( ) )
392+ . args ( args)
393+ . output ( )
394+ . unwrap_or_else ( |e| panic ! ( "Failed to run CLI at {:?}: {}" , cli_path, e) ) ;
395+
396+ if !output. status . success ( ) {
397+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
398+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
399+ panic ! (
400+ "CLI command {:?} failed with status {}\n stdout: {}\n stderr: {}" ,
401+ args, output. status, stdout, stderr
402+ ) ;
403+ }
404+
405+ String :: from_utf8 ( output. stdout ) . unwrap ( )
406+ }
407+
384408/// Run a CLI command against the given server handle and return parsed JSON output.
385409pub fn run_cli ( handle : & LdkServerHandle , args : & [ & str ] ) -> serde_json:: Value {
386410 let stdout = run_cli_raw ( handle, args) ;
387411 serde_json:: from_str ( & stdout)
388412 . unwrap_or_else ( |e| panic ! ( "Failed to parse CLI output as JSON: {e}\n Output: {stdout}" ) )
389413}
390414
415+ /// Run a CLI command using the server's config file and return parsed JSON output.
416+ pub fn run_cli_with_config ( handle : & LdkServerHandle , args : & [ & str ] ) -> serde_json:: Value {
417+ let stdout = run_cli_with_config_raw ( handle, args) ;
418+ serde_json:: from_str ( & stdout)
419+ . unwrap_or_else ( |e| panic ! ( "Failed to parse CLI output as JSON: {e}\n Output: {stdout}" ) )
420+ }
421+
391422/// Mine blocks and wait for all servers to sync to the new chain tip.
392423pub async fn mine_and_sync (
393424 bitcoind : & TestBitcoind , servers : & [ & LdkServerHandle ] , block_count : u64 ,
0 commit comments