diff --git a/src/gui/views/wallets/wallet/txs/content.rs b/src/gui/views/wallets/wallet/txs/content.rs index d9308fec..11cedd77 100644 --- a/src/gui/views/wallets/wallet/txs/content.rs +++ b/src/gui/views/wallets/wallet/txs/content.rs @@ -175,24 +175,26 @@ impl WalletTransactions { }); } - let rebroadcast = tx.broadcasting_timed_out(wallet); + if !tx.cancelled() && !tx.cancelling() && !tx.posting() { + let rebroadcast = tx.broadcasting_timed_out(wallet); - // Draw button to cancel transaction. - if tx.can_cancel() || rebroadcast { - let (icon, color) = (PROHIBIT, Some(Colors::red())); - View::item_button(ui, CornerRadius::default(), icon, color, || { - self.confirm_cancel_tx_id = Some(tx.data.id); - // Show transaction cancellation confirmation modal. - Modal::new(CANCEL_TX_CONFIRMATION_MODAL) - .position(ModalPosition::Center) - .title(t!("confirmation")) - .show(); - }); - } - - // Draw button to repeat transaction action. - if tx.can_repeat_action() || rebroadcast { - Self::tx_repeat_button_ui(ui, CornerRadius::default(), tx, wallet, rebroadcast); + // Draw button to cancel transaction. + if tx.can_cancel() || rebroadcast { + let (icon, color) = (PROHIBIT, Some(Colors::red())); + View::item_button(ui, CornerRadius::default(), icon, color, || { + self.confirm_cancel_tx_id = Some(tx.data.id); + // Show transaction cancellation confirmation modal. + Modal::new(CANCEL_TX_CONFIRMATION_MODAL) + .position(ModalPosition::Center) + .title(t!("confirmation")) + .show(); + }); + } + + // Draw button to repeat transaction action. + if tx.can_repeat_action() || rebroadcast { + Self::tx_repeat_button_ui(ui, CornerRadius::default(), tx, wallet, rebroadcast); + } } }); } diff --git a/src/gui/views/wallets/wallet/txs/tx.rs b/src/gui/views/wallets/wallet/txs/tx.rs index 0a27eda0..1a82c71b 100644 --- a/src/gui/views/wallets/wallet/txs/tx.rs +++ b/src/gui/views/wallets/wallet/txs/tx.rs @@ -258,29 +258,31 @@ impl WalletTransactionContent { }); } - let rebroadcast = tx.broadcasting_timed_out(&wallet); + if !tx.cancelled() && !tx.cancelling() && !tx.posting() { + let rebroadcast = tx.broadcasting_timed_out(&wallet); - // Draw button to cancel transaction. - if tx.can_cancel() || rebroadcast { - let r = if tx.can_finalize() { - CornerRadius::default() - } else { - View::item_rounding(0, 2, true) - }; - View::item_button(ui, r, PROHIBIT, Some(Colors::red()), || { - wallet.task(WalletTask::Cancel(tx.clone())); - Modal::close(); - }); - } + // Draw button to cancel transaction. + if tx.can_cancel() || rebroadcast { + let r = if tx.can_finalize() { + CornerRadius::default() + } else { + View::item_rounding(0, 2, true) + }; + View::item_button(ui, r, PROHIBIT, Some(Colors::red()), || { + wallet.task(WalletTask::Cancel(tx.clone())); + Modal::close(); + }); + } - // Draw button to repeat transaction action. - if tx.can_repeat_action() || rebroadcast { - let r = if tx.can_finalize() || tx.can_cancel() { - CornerRadius::default() - } else { - View::item_rounding(0, 2, true) - }; - WalletTransactions::tx_repeat_button_ui(ui, r, tx, wallet, rebroadcast); + // Draw button to repeat transaction action. + if tx.can_repeat_action() || rebroadcast { + let r = if tx.can_finalize() || tx.can_cancel() { + CornerRadius::default() + } else { + View::item_rounding(0, 2, true) + }; + WalletTransactions::tx_repeat_button_ui(ui, r, tx, wallet, rebroadcast); + } } }); diff --git a/src/wallet/types.rs b/src/wallet/types.rs index 617e885d..5cdfbc2a 100644 --- a/src/wallet/types.rs +++ b/src/wallet/types.rs @@ -347,6 +347,12 @@ impl WalletTransaction { self.data.tx_type != TxLogEntryType::TxSentCancelled } + /// Check if transaction was canceled. + pub fn cancelled(&self) -> bool { + self.data.tx_type == TxLogEntryType::TxReceivedCancelled || + self.data.tx_type == TxLogEntryType::TxSentCancelled + } + /// Check if transaction is finalizing. pub fn finalizing(&self) -> bool { if let Some(a) = self.action.as_ref() { diff --git a/src/wallet/wallet.rs b/src/wallet/wallet.rs index c861b299..e3e30e69 100644 --- a/src/wallet/wallet.rs +++ b/src/wallet/wallet.rs @@ -1373,6 +1373,8 @@ async fn handle_task(w: &Wallet, t: WalletTask) { } } WalletTask::Post(s, id) => { + w.on_tx_action(id.to_string(), Some(WalletTransactionAction::Posting)); + let slate = match s { None => &w.get_tx(*id).unwrap(), Some(s) => s @@ -1380,6 +1382,9 @@ async fn handle_task(w: &Wallet, t: WalletTask) { w.on_tx_error(slate.id.to_string(), None); // Cleanup broadcasting tx height. + let tx_height_store = TxHeightStore::new(w.get_config().get_extra_db_path()); + tx_height_store.delete_broadcasting_height(*id); + let has_data = { let r_data = w.data.read(); r_data.is_some()