feat(gui): Tor toggle (#300)

* re-add tor info box, show switch for toggling tor

* add use_tor to TauriSettings, only initialize tor client when it's true

* add warning log message when not using tor client

* change the label text of the switch, fail to align switch with SettingsBox icons

* move Tor settings to SettingsBox
This commit is contained in:
Raphael 2025-04-22 16:36:09 +02:00 committed by GitHub
parent ffe103cb49
commit 3fa31ba139
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 44 additions and 77 deletions

View file

@ -394,6 +394,12 @@ impl ContextBuilder {
};
let initialize_tor_client = async {
// Don't init a tor client unless we should use it.
if !self.tor {
tracing::warn!("Internal Tor client not enabled, skipping initialization");
return Ok(None);
}
self.tauri_handle.emit_context_init_progress_event(
TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::EstablishingTorCircuits(

View file

@ -133,7 +133,7 @@ impl TauriHandle {
let request_id = Uuid::new_v4();
let now_secs = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.expect("it is later than the begin of the unix epoch")
.as_secs();
let expiration_ts = now_secs + timeout_secs;
@ -501,4 +501,6 @@ pub struct TauriSettings {
/// The URL of the Electrum RPC server e.g `ssl://bitcoin.com:50001`
#[typeshare(serialized_as = "string")]
pub electrum_rpc_url: Option<Url>,
/// Whether to initialize and use a tor client.
pub use_tor: bool,
}

View file

@ -164,7 +164,7 @@ async fn next_state(
let btc_lock_amount = bitcoin::Amount::from_sat(
signed_tx
.output
.get(0)
.first()
.context("Failed to get lock amount")?
.value,
);