From 8c0c23e688b02a73393a7172b3f41bfaa2a9c143 Mon Sep 17 00:00:00 2001 From: edouardparis Date: Tue, 6 May 2025 11:13:05 +0200 Subject: [PATCH] Use gui panic hook --- lianad/src/bin/daemon.rs | 4 +++- lianad/src/lib.rs | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lianad/src/bin/daemon.rs b/lianad/src/bin/daemon.rs index 7b1ffbaa..dcc756bd 100644 --- a/lianad/src/bin/daemon.rs +++ b/lianad/src/bin/daemon.rs @@ -5,7 +5,7 @@ use std::{ process, thread, time, }; -use lianad::{config::Config, DaemonHandle, VERSION}; +use lianad::{config::Config, setup_panic_hook, DaemonHandle, VERSION}; fn print_help_exit(code: i32) { eprintln!("lianad version {}", VERSION); @@ -80,6 +80,8 @@ fn main() { process::exit(1); }); + setup_panic_hook(); + let handle = DaemonHandle::start_default(config, cfg!(unix)).unwrap_or_else(|e| { log::error!("Error starting Liana daemon: {}", e); process::exit(1); diff --git a/lianad/src/lib.rs b/lianad/src/lib.rs index 7189bfe1..8ff2306b 100644 --- a/lianad/src/lib.rs +++ b/lianad/src/lib.rs @@ -40,7 +40,7 @@ use miniscript::bitcoin::{constants::ChainHash, hashes::Hash, secp256k1, BlockHa use std::panic; // A panic in any thread should stop the main thread, and print the panic. #[cfg(not(test))] -fn setup_panic_hook() { +pub fn setup_panic_hook() { panic::set_hook(Box::new(move |panic_info| { let file = panic_info .location() @@ -396,9 +396,6 @@ impl DaemonHandle { db: Option, with_rpc_server: bool, ) -> Result { - #[cfg(not(test))] - setup_panic_hook(); - let secp = secp256k1::Secp256k1::verification_only(); // First, check the data directory