fix: do not send over tor when service not launched

This commit is contained in:
ardocrat
2026-04-10 00:28:27 +03:00
parent 31bc74529c
commit 6835bb1909
5 changed files with 15 additions and 11 deletions
+1 -1
View File
@@ -242,7 +242,7 @@ impl WalletTransactionsContent {
});
}
// Draw button to repeat transaction action.
if tx.can_repeat_action() || repeat {
if tx.can_repeat_action(wallet) || repeat {
Self::tx_repeat_button_ui(ui, CornerRadius::default(), tx, wallet, repeat);
}
}
+1 -1
View File
@@ -305,7 +305,7 @@ impl WalletTransactionContent {
});
}
// Draw button to repeat transaction action.
if tx.can_repeat_action() || repeat {
if tx.can_repeat_action(wallet) || repeat {
let r = if tx.can_finalize() || tx.can_cancel() {
CornerRadius::default()
} else {
+2 -4
View File
@@ -302,10 +302,8 @@ impl Tor {
return None;
}
}
// Launch client if needed.
Self::launch();
if Self::client_config().is_none() {
error!("Tor: can not launch Tor client");
error!("Tor: client not launched");
return None;
}
// Create http tor-powered client to post data.
@@ -580,7 +578,7 @@ impl Tor {
const MAX_ERRORS: i32 = 16;
let mut errors_count = 0;
// Wait 5 seconds.
thread::sleep(Duration::from_millis(5000));
tokio::time::sleep(Duration::from_millis(5000)).await;
loop {
if !Self::check_running(&service_id) {
break;
+4 -2
View File
@@ -20,6 +20,7 @@ use grin_wallet_util::OnionV3Address;
use serde_derive::{Deserialize, Serialize};
use std::sync::Arc;
use crate::tor::Tor;
use crate::wallet::Wallet;
/// Mnemonic phrase word.
@@ -377,12 +378,13 @@ impl WalletTx {
}
/// Check if possible to repeat transaction action.
pub fn can_repeat_action(&self) -> bool {
pub fn can_repeat_action(&self, wallet: &Wallet) -> bool {
if let Some(a) = &self.action {
self.action_error.is_some() && a != &WalletTxAction::Cancelling
} else {
// Can resend over Tor.
!self.data.confirmed && !self.sending_tor() && !self.broadcasting() &&
!self.data.confirmed && !self.sending_tor() &&
Tor::is_service_running(&wallet.identifier()) && !self.broadcasting() &&
self.receiver.is_some()
}
}
+7 -3
View File
@@ -1735,9 +1735,13 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
let tx = w.retrieve_tx_by_id(None, Some(s.id));
if let Some(tx) = tx {
if let Some(addr) = r {
w.send_creating.store(false, Ordering::Relaxed);
send_tor(tx, &s, addr).await;
return;
if Tor::is_service_running(&w.identifier()) {
w.send_creating.store(false, Ordering::Relaxed);
send_tor(tx, &s, addr).await;
return;
} else {
w.on_task_result(Some(tx), &t);
}
} else {
w.on_task_result(Some(tx), &t);
}