Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide unmined coinbase #6159

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ impl<B: Backend> Component<B> 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 => {
Expand Down
25 changes: 24 additions & 1 deletion applications/minotari_console_wallet/src/ui/state/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub struct AppState {
inner: Arc<RwLock<AppStateInner>>,
cached_data: AppStateData,
cache_update_cooldown: Option<Instant>,
completed_tx_filter: TransactionFilter,
config: AppStateConfig,
wallet_config: WalletConfig,
wallet_connectivity: WalletConnectivityHandle,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -1370,3 +1387,9 @@ impl Default for AppStateConfig {
}
}
}

#[derive(Clone, PartialEq)]
pub enum TransactionFilter {
None,
AbandonedCoinbases,
}
Loading