From 120f87462f0402c8a056c4af2c318601174bdfb6 Mon Sep 17 00:00:00 2001 From: edouard Date: Thu, 16 Feb 2023 10:41:29 +0100 Subject: [PATCH 1/2] Change pending label for unconfirmed close #230 close #231 --- gui/src/app/view/coins.rs | 12 ++------ gui/src/app/view/home.rs | 4 +-- gui/src/app/view/spend/detail.rs | 12 ++------ gui/src/app/view/spend/mod.rs | 12 ++------ gui/src/app/view/spend/step.rs | 12 ++------ gui/src/ui/component/badge.rs | 47 ++++++++++++++++++++++++++++++-- 6 files changed, 54 insertions(+), 45 deletions(-) diff --git a/gui/src/app/view/coins.rs b/gui/src/app/view/coins.rs index a0031298..fb1ede02 100644 --- a/gui/src/app/view/coins.rs +++ b/gui/src/app/view/coins.rs @@ -70,11 +70,7 @@ fn coin_list_view( Row::new() .push(badge::coin()) .push_maybe(if coin.spend_info.is_some() { - Some( - Container::new(text(" Spent ").small()) - .padding(3) - .style(badge::PillStyle::Success), - ) + Some(badge::spent()) } else { let seq = remaining_sequence(coin, blockheight, timelock); if seq == 0 { @@ -116,11 +112,7 @@ fn coin_list_view( } }) .push_maybe(if coin.block_height.is_none() { - Some( - Container::new(text(" Unconfirmed ").small()) - .padding(3) - .style(badge::PillStyle::Simple), - ) + Some(badge::unconfirmed()) } else { None }) diff --git a/gui/src/app/view/home.rs b/gui/src/app/view/home.rs index 855ac40c..e55b1ddd 100644 --- a/gui/src/app/view/home.rs +++ b/gui/src/app/view/home.rs @@ -130,9 +130,7 @@ fn event_list_view<'a>(i: usize, event: &HistoryTransaction) -> Element<'a, Mess .small(), ) } else { - Container::new(text(" Pending ").small()) - .padding(3) - .style(badge::PillStyle::Success) + badge::unconfirmed() }) .spacing(10) .align_items(Alignment::Center) diff --git a/gui/src/app/view/spend/detail.rs b/gui/src/app/view/spend/detail.rs index e28316ee..abb339c5 100644 --- a/gui/src/app/view/spend/detail.rs +++ b/gui/src/app/view/spend/detail.rs @@ -210,16 +210,8 @@ fn spend_header<'a>(tx: &SpendTx) -> Element<'a, Message> { .align_items(Alignment::Center), ) .push_maybe(match tx.status { - SpendStatus::Deprecated => Some( - Container::new(text(" Deprecated ").small()) - .padding(3) - .style(badge::PillStyle::Simple), - ), - SpendStatus::Broadcast => Some( - Container::new(text(" Broadcast ").small()) - .padding(3) - .style(badge::PillStyle::Success), - ), + SpendStatus::Deprecated => Some(badge::deprecated()), + SpendStatus::Broadcast => Some(badge::unconfirmed()), _ => None, }) .push( diff --git a/gui/src/app/view/spend/mod.rs b/gui/src/app/view/spend/mod.rs index 6fd58bd2..ac2e59b3 100644 --- a/gui/src/app/view/spend/mod.rs +++ b/gui/src/app/view/spend/mod.rs @@ -156,16 +156,8 @@ fn spend_tx_list_view<'a>(i: usize, tx: &SpendTx) -> Element<'a, Message> { .width(Length::Fill), ) .push_maybe(match tx.status { - SpendStatus::Deprecated => Some( - Container::new(text(" Deprecated ").small()) - .padding(3) - .style(badge::PillStyle::Simple), - ), - SpendStatus::Broadcast => Some( - Container::new(text(" Broadcast ").small()) - .padding(3) - .style(badge::PillStyle::Success), - ), + SpendStatus::Deprecated => Some(badge::deprecated()), + SpendStatus::Broadcast => Some(badge::unconfirmed()), _ => None, }) .push( diff --git a/gui/src/app/view/spend/step.rs b/gui/src/app/view/spend/step.rs index 2e478d7f..5f69ad97 100644 --- a/gui/src/app/view/spend/step.rs +++ b/gui/src/app/view/spend/step.rs @@ -206,11 +206,7 @@ fn coin_list_view<'a>( }) .push(badge::coin()) .push_maybe(if coin.spend_info.is_some() { - Some( - Container::new(text(" Spent ").small()) - .padding(3) - .style(badge::PillStyle::Success), - ) + Some(badge::spent()) } else { let seq = remaining_sequence(coin, blockheight, timelock); if seq == 0 { @@ -244,11 +240,7 @@ fn coin_list_view<'a>( } }) .push_maybe(if coin.block_height.is_none() { - Some( - Container::new(text(" Unconfirmed ").small()) - .padding(3) - .style(badge::PillStyle::Simple), - ) + Some(badge::unconfirmed()) } else { None }) diff --git a/gui/src/ui/component/badge.rs b/gui/src/ui/component/badge.rs index 3bba0afd..26ef715b 100644 --- a/gui/src/ui/component/badge.rs +++ b/gui/src/ui/component/badge.rs @@ -1,9 +1,13 @@ use iced::{ - widget::{self, Container}, + widget::{self, tooltip, Container}, Element, Length, }; -use crate::ui::{color, icon}; +use crate::ui::{ + color, + component::{card, text::*}, + icon, +}; pub enum Style { Standard, @@ -164,3 +168,42 @@ impl From for iced::theme::Container { iced::theme::Container::Custom(i.into()) } } + +pub fn unconfirmed<'a, T: 'a>() -> widget::container::Container<'a, T> { + Container::new( + tooltip::Tooltip::new( + Container::new(text(" Unconfirmed ").small()) + .padding(3) + .style(PillStyle::Simple), + "Do not treat this as a payment until it is confirmed", + tooltip::Position::Top, + ) + .style(card::SimpleCardStyle), + ) +} + +pub fn deprecated<'a, T: 'a>() -> widget::container::Container<'a, T> { + Container::new( + tooltip::Tooltip::new( + Container::new(text(" Deprecated ").small()) + .padding(3) + .style(PillStyle::Simple), + "This spend cannot be included anymore in the blockchain", + tooltip::Position::Top, + ) + .style(card::SimpleCardStyle), + ) +} + +pub fn spent<'a, T: 'a>() -> widget::container::Container<'a, T> { + Container::new( + tooltip::Tooltip::new( + Container::new(text(" Spent ").small()) + .padding(3) + .style(PillStyle::Simple), + "The spend transaction was included in the blockchain", + tooltip::Position::Top, + ) + .style(card::SimpleCardStyle), + ) +} From 9535b802584a153fd0e6fcb808d8af7aa067ec95 Mon Sep 17 00:00:00 2001 From: edouard Date: Thu, 16 Feb 2023 10:49:22 +0100 Subject: [PATCH 2/2] Add spent tag to confirmed broadcast tx close #233 --- gui/src/app/view/spend/detail.rs | 1 + gui/src/app/view/spend/mod.rs | 1 + gui/src/daemon/model.rs | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gui/src/app/view/spend/detail.rs b/gui/src/app/view/spend/detail.rs index abb339c5..ff674133 100644 --- a/gui/src/app/view/spend/detail.rs +++ b/gui/src/app/view/spend/detail.rs @@ -212,6 +212,7 @@ fn spend_header<'a>(tx: &SpendTx) -> Element<'a, Message> { .push_maybe(match tx.status { SpendStatus::Deprecated => Some(badge::deprecated()), SpendStatus::Broadcast => Some(badge::unconfirmed()), + SpendStatus::Spent => Some(badge::spent()), _ => None, }) .push( diff --git a/gui/src/app/view/spend/mod.rs b/gui/src/app/view/spend/mod.rs index ac2e59b3..27e121de 100644 --- a/gui/src/app/view/spend/mod.rs +++ b/gui/src/app/view/spend/mod.rs @@ -158,6 +158,7 @@ fn spend_tx_list_view<'a>(i: usize, tx: &SpendTx) -> Element<'a, Message> { .push_maybe(match tx.status { SpendStatus::Deprecated => Some(badge::deprecated()), SpendStatus::Broadcast => Some(badge::unconfirmed()), + SpendStatus::Spent => Some(badge::spent()), _ => None, }) .push( diff --git a/gui/src/daemon/model.rs b/gui/src/daemon/model.rs index 69a42ae5..7443f60d 100644 --- a/gui/src/daemon/model.rs +++ b/gui/src/daemon/model.rs @@ -37,6 +37,7 @@ pub enum SpendStatus { Pending, Deprecated, Broadcast, + Spent, } impl SpendTx { @@ -60,7 +61,11 @@ impl SpendTx { inputs_amount += coin.amount; if let Some(info) = coin.spend_info { if info.txid == psbt.unsigned_tx.txid() { - status = SpendStatus::Broadcast + if info.height.is_some() { + status = SpendStatus::Spent + } else { + status = SpendStatus::Broadcast + } } else { status = SpendStatus::Deprecated }