From a1125509c48f76f4133606bfae61f319f2969358 Mon Sep 17 00:00:00 2001 From: Philip Date: Thu, 27 Jan 2022 09:57:31 +0200 Subject: [PATCH] feat: update the available balance in console wallet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the available balance in the console wallet to not include the time locked balance. This way the user doesn’t have to do a mental subtraction. --- .../tari_console_wallet/src/ui/components/balance.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/applications/tari_console_wallet/src/ui/components/balance.rs b/applications/tari_console_wallet/src/ui/components/balance.rs index 213556db58..462c316d0e 100644 --- a/applications/tari_console_wallet/src/ui/components/balance.rs +++ b/applications/tari_console_wallet/src/ui/components/balance.rs @@ -46,15 +46,12 @@ impl Component for Balance { f.render_widget(block, area); let balance = app_state.get_balance(); - + let time_locked = balance.time_locked_balance.unwrap_or_else(|| MicroTari::from(0u64)); let available_balance = Spans::from(vec![ Span::styled("Available:", Style::default().fg(Color::Magenta)), Span::raw(" "), - Span::raw(format!("{}", balance.available_balance)), - Span::raw(format!( - " (Time Locked: {})", - balance.time_locked_balance.unwrap_or_else(|| MicroTari::from(0u64)) - )), + Span::raw(format!("{}", balance.available_balance.saturating_sub(time_locked))), + Span::raw(format!(" (Time Locked: {})", time_locked)), ]); let incoming_balance = Spans::from(vec![ Span::styled("Pending Incoming:", Style::default().fg(Color::Magenta)),