diff --git a/applications/minotari_console_wallet/src/ui/components/transactions_tab.rs b/applications/minotari_console_wallet/src/ui/components/transactions_tab.rs index 98aa436e3b..dfb2bb389d 100644 --- a/applications/minotari_console_wallet/src/ui/components/transactions_tab.rs +++ b/applications/minotari_console_wallet/src/ui/components/transactions_tab.rs @@ -595,6 +595,7 @@ impl Component for TransactionsTab { error!(target: LOG_TARGET, "Error rebroadcasting transactions: {}", e); } }, + 'a' => app_state.toggle_abandoned_coinbase_filter(), '\n' => match self.selected_tx_list { SelectedTransactionList::None => {}, SelectedTransactionList::PendingTxs => { diff --git a/applications/minotari_console_wallet/src/ui/state/app_state.rs b/applications/minotari_console_wallet/src/ui/state/app_state.rs index 2c1fd54b4a..9f2642fcd4 100644 --- a/applications/minotari_console_wallet/src/ui/state/app_state.rs +++ b/applications/minotari_console_wallet/src/ui/state/app_state.rs @@ -96,6 +96,7 @@ pub struct AppState { inner: Arc>, cached_data: AppStateData, cache_update_cooldown: Option, + completed_tx_filter: TransactionFilter, config: AppStateConfig, wallet_config: WalletConfig, wallet_connectivity: WalletConnectivityHandle, @@ -121,6 +122,7 @@ impl AppState { cached_data, cache_update_cooldown: None, config: AppStateConfig::default(), + completed_tx_filter: TransactionFilter::AbandonedCoinbases, wallet_connectivity, balance_enquiry_debouncer: BalanceEnquiryDebouncer::new( inner, @@ -185,6 +187,13 @@ impl AppState { Ok(()) } + pub fn toggle_abandoned_coinbase_filter(&mut self) { + self.completed_tx_filter = match self.completed_tx_filter { + TransactionFilter::AbandonedCoinbases => TransactionFilter::None, + TransactionFilter::None => TransactionFilter::AbandonedCoinbases, + }; + } + pub async fn update_cache(&mut self) { let update = match self.cache_update_cooldown { Some(last_update) => last_update.elapsed() > self.config.cache_update_cooldown, @@ -556,7 +565,15 @@ impl AppState { } pub fn get_completed_txs(&self) -> Vec<&CompletedTransactionInfo> { - self.cached_data.completed_txs.iter().collect() + if self.completed_tx_filter == TransactionFilter::AbandonedCoinbases { + self.cached_data + .completed_txs + .iter() + .filter(|tx| !matches!(tx.status, TransactionStatus::CoinbaseNotInBlockChain)) + .collect() + } else { + self.cached_data.completed_txs.iter().collect() + } } pub fn get_confirmations(&self, tx_id: TxId) -> Option<&u64> { @@ -1370,3 +1387,9 @@ impl Default for AppStateConfig { } } } + +#[derive(Clone, PartialEq)] +pub enum TransactionFilter { + None, + AbandonedCoinbases, +}