fix: action repeat tor tx, no resend for tor

This commit is contained in:
ardocrat
2025-06-25 12:51:29 +03:00
parent a89a9bcaed
commit 1b78118f51
4 changed files with 18 additions and 13 deletions
+4 -4
View File
@@ -189,9 +189,9 @@ impl WalletTransactions {
.show();
});
}
// Draw button to repeat transaction action or resend with tor.
if tx.action_error.is_some() || rebroadcast || tx.can_resend_tor() {
// Draw button to repeat transaction action.
if tx.can_repeat_action() || rebroadcast {
Self::tx_repeat_button_ui(ui, CornerRadius::default(), tx, wallet, rebroadcast);
}
});
@@ -459,7 +459,7 @@ impl WalletTransactions {
TxLogEntryType::TxSentCancelled => Colors::inactive_text(),
TxLogEntryType::TxReverted => Colors::inactive_text(),
};
ui.label(RichText::new(status_text).size(15.0).color(status_color));
View::ellipsize_text(ui, status_text, 15.0, status_color);
// Setup transaction time.
let tx_time = View::format_time(tx.data.creation_ts.timestamp());
+2 -2
View File
@@ -22,7 +22,7 @@ use crate::gui::platform::PlatformCallbacks;
use crate::gui::views::wallets::wallet::txs::WalletTransactions;
use crate::gui::views::{CameraContent, FilePickContent, FilePickContentType, Modal, QrCodeContent, View};
use crate::gui::Colors;
use crate::wallet::types::{WalletTask, WalletTransaction};
use crate::wallet::types::{WalletTask, WalletTransaction, WalletTransactionAction};
use crate::wallet::Wallet;
/// Transaction information [`Modal`] content.
@@ -274,7 +274,7 @@ impl WalletTransactionContent {
}
// Draw button to repeat transaction action.
if tx.action_error.is_some() || rebroadcast || tx.can_resend_tor() {
if tx.can_repeat_action() || rebroadcast {
let r = if tx.can_finalize() || tx.can_cancel() {
CornerRadius::default()
} else {
+9 -6
View File
@@ -347,12 +347,6 @@ impl WalletTransaction {
self.data.tx_type != TxLogEntryType::TxSentCancelled
}
/// Check if transaction can be sent over Tor again.
pub fn can_resend_tor(&self) -> bool {
!self.sending_tor() && (self.state == SlateState::Standard1 ||
self.state == SlateState::Invoice1) && self.receiver.is_some()
}
/// Check if transaction is finalizing.
pub fn finalizing(&self) -> bool {
if let Some(a) = self.action.as_ref() {
@@ -361,6 +355,15 @@ impl WalletTransaction {
false
}
/// Check if possible to repeat transaction action.
pub fn can_repeat_action(&self) -> bool {
if let Some(a) = &self.action {
return self.action_error.is_some() && a != &WalletTransactionAction::SendingTor &&
a != &WalletTransactionAction::Cancelling
}
false
}
/// Check if transaction is broadcasting after finalization.
pub fn broadcasting(&self) -> bool {
!self.data.confirmed && self.finalized()
+3 -1
View File
@@ -1329,13 +1329,13 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
w.send_creating.store(true, Ordering::Relaxed);
if let Ok(s) = w.send(*a, r.clone()) {
sync_wallet_data(&w, false);
w.send_creating.store(false, Ordering::Relaxed);
if let Some(r) = r {
send_tor(&s, r).await;
} else {
w.on_tx_result(&s);
}
}
w.send_creating.store(false, Ordering::Relaxed);
}
WalletTask::SendTor(id, r) => {
if let Some(s) = w.get_tx(*id) {
@@ -1355,6 +1355,7 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
None => &w.get_tx(*id).unwrap(),
Some(s) => s
};
w.on_tx_error(slate.id.to_string(), None);
match w.finalize(slate) {
Ok(s) => {
match w.post(&s) {
@@ -1376,6 +1377,7 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
None => &w.get_tx(*id).unwrap(),
Some(s) => s
};
w.on_tx_error(slate.id.to_string(), None);
// Cleanup broadcasting tx height.
let has_data = {