From aa32444318ebe44d4cf38c15f08ccec061b9cb0c Mon Sep 17 00:00:00 2001 From: edouard Date: Fri, 16 Dec 2022 17:25:41 +0100 Subject: [PATCH] fix inconsistencies between spend and coins panel Add remaining timelock and unconfirmed label. close #232 --- gui/src/app/view/coins.rs | 9 +++++++++ gui/src/app/view/spend/step.rs | 33 +++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/gui/src/app/view/coins.rs b/gui/src/app/view/coins.rs index e036c595..5d65ca87 100644 --- a/gui/src/app/view/coins.rs +++ b/gui/src/app/view/coins.rs @@ -113,6 +113,15 @@ fn coin_list_view( )) } }) + .push_maybe(if coin.block_height.is_none() { + Some( + Container::new(text(" Unconfirmed ").small()) + .padding(3) + .style(badge::PillStyle::Simple), + ) + } else { + None + }) .spacing(10) .align_items(Alignment::Center) .width(Length::Fill), diff --git a/gui/src/app/view/spend/step.rs b/gui/src/app/view/spend/step.rs index 64a470a5..0e467e9c 100644 --- a/gui/src/app/view/spend/step.rs +++ b/gui/src/app/view/spend/step.rs @@ -11,7 +11,7 @@ use crate::{ error::Error, view::{message::*, modal}, }, - daemon::model::Coin, + daemon::model::{remaining_sequence, Coin}, ui::{ color, component::{ @@ -198,8 +198,15 @@ fn coin_list_view<'a>( icon::square_icon() }) .push(badge::coin()) - .push_maybe(if let Some(b) = coin.block_height { - if blockheight > b as u32 + timelock { + .push_maybe(if coin.spend_info.is_some() { + Some( + Container::new(text(" Spent ").small()) + .padding(3) + .style(badge::PillStyle::Success), + ) + } else { + let seq = remaining_sequence(coin, blockheight, timelock); + if seq == 0 { Some(Container::new( Row::new() .spacing(5) @@ -209,18 +216,32 @@ fn coin_list_view<'a>( ) .align_items(Alignment::Center), )) - } else { + } else if seq < timelock * 10 / 100 { Some(Container::new( Row::new() .spacing(5) .push( - text(format!(" {}", b as u32 + timelock - blockheight)) - .small(), + text(format!(" {}", seq)).small().style(color::WARNING), ) + .push(icon::hourglass_icon().small().style(color::WARNING)) + .align_items(Alignment::Center), + )) + } else { + Some(Container::new( + Row::new() + .spacing(5) + .push(text(format!(" {}", seq)).small()) .push(icon::hourglass_icon().small()) .align_items(Alignment::Center), )) } + }) + .push_maybe(if coin.block_height.is_none() { + Some( + Container::new(text(" Unconfirmed ").small()) + .padding(3) + .style(badge::PillStyle::Simple), + ) } else { None })