Merge #351: Gui unconfirmed badge

9535b802584a153fd0e6fcb808d8af7aa067ec95 Add spent tag to confirmed broadcast tx (edouard)
120f87462f0402c8a056c4af2c318601174bdfb6 Change pending label for unconfirmed (edouard)

Pull request description:

  ![2023-02-16T10:39:22,026408712+01:00](https://user-images.githubusercontent.com/6933020/219334057-c3b0a3f3-500e-4f4e-9389-219a62e7a48a.png)

ACKs for top commit:
  edouardparis:
    Self-ACK 9535b802584a153fd0e6fcb808d8af7aa067ec95

Tree-SHA512: 537f65e96ea99821ea2d342e80c55d9e1c8508664cb9fadb00ef08531e0f4c337b33a53d93e397ab07dfc8f1e051e18445d87baf4fe34acb1793561c48e3eded
This commit is contained in:
edouard 2023-02-16 13:39:53 +01:00
commit 4f4327fd1f
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
7 changed files with 62 additions and 46 deletions

View File

@ -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
})

View File

@ -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)

View File

@ -210,16 +210,9 @@ 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()),
SpendStatus::Spent => Some(badge::spent()),
_ => None,
})
.push(

View File

@ -156,16 +156,9 @@ 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()),
SpendStatus::Spent => Some(badge::spent()),
_ => None,
})
.push(

View File

@ -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
})

View File

@ -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
}

View File

@ -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<PillStyle> 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),
)
}