Skip to content

Commit 5389d00

Browse files
committed
Merge branch 'main' into mock-deps
2 parents 1e992b7 + f1b1742 commit 5389d00

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

examples/node/cli.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ pub(crate) fn poll_for_user_input(node: &LightningNode, log_file_path: &str) {
271271
"background" => {
272272
node.background();
273273
}
274+
"closechannels" => {
275+
if let Err(message) = node.close_all_channels_with_current_lsp() {
276+
println!("{}", format!("{message:#}").red());
277+
}
278+
}
274279
"stop" => {
275280
break;
276281
}
@@ -412,6 +417,7 @@ fn setup_editor(history_path: &Path) -> Editor<CommandHinter, DefaultHistory> {
412417
hints.insert(CommandHint::new("health", "health"));
413418
hints.insert(CommandHint::new("foreground", "foreground"));
414419
hints.insert(CommandHint::new("background", "background"));
420+
hints.insert(CommandHint::new("closechannels", "closechannels"));
415421
hints.insert(CommandHint::new("stop", "stop"));
416422
hints.insert(CommandHint::new("help", "help"));
417423
hints.insert(CommandHint::new("h", "h"));
@@ -475,6 +481,8 @@ fn help() {
475481
println!(" foreground");
476482
println!(" background");
477483
println!();
484+
println!(" closechannels");
485+
println!();
478486
println!(" stop");
479487
}
480488

src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,6 +2436,19 @@ impl LightningNode {
24362436

24372437
Ok(node_state.utxos)
24382438
}
2439+
2440+
// Only meant for example CLI use
2441+
#[doc(hidden)]
2442+
pub fn close_all_channels_with_current_lsp(&self) -> Result<()> {
2443+
self.rt
2444+
.handle()
2445+
.block_on(self.sdk.close_lsp_channels())
2446+
.map_to_runtime_error(
2447+
RuntimeErrorCode::NodeUnavailable,
2448+
"Failed to close channels",
2449+
)?;
2450+
Ok(())
2451+
}
24392452
}
24402453

24412454
pub(crate) async fn start_sdk(

0 commit comments

Comments
 (0)