From 3e43a806cfa129e4c8449c4a43353290579fcd22 Mon Sep 17 00:00:00 2001 From: edouard Date: Thu, 17 Nov 2022 20:47:31 +0100 Subject: [PATCH 1/2] bump minisafe --- gui/Cargo.lock | 4 ++-- gui/src/daemon/embedded.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/Cargo.lock b/gui/Cargo.lock index 4e98bd16..3b090b18 100644 --- a/gui/Cargo.lock +++ b/gui/Cargo.lock @@ -1620,7 +1620,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "minisafe" version = "0.0.1" -source = "git+https://github.com/revault/minisafe?branch=master#ac80aa77215169d93bf5a44afb2b854f52e74348" +source = "git+https://github.com/revault/minisafe?branch=master#25bbce8612f7aaef45d24ec16fc1fd55c6b73594" dependencies = [ "backtrace", "base64", @@ -2804,7 +2804,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "rand 0.8.5", "static_assertions", ] diff --git a/gui/src/daemon/embedded.rs b/gui/src/daemon/embedded.rs index 022dd9f8..033aa7af 100644 --- a/gui/src/daemon/embedded.rs +++ b/gui/src/daemon/embedded.rs @@ -120,7 +120,7 @@ impl Daemon for EmbeddedDaemon { .read() .unwrap() .control - .create_spend(coins_outpoints, destinations, feerate_vb) + .create_spend(destinations, coins_outpoints, feerate_vb) .map_err(|e| DaemonError::Unexpected(e.to_string())) } From d541ca90e59f7890aa26373c8675278a3a559d5b Mon Sep 17 00:00:00 2001 From: edouard Date: Thu, 17 Nov 2022 21:22:57 +0100 Subject: [PATCH 2/2] Fix spend creation --- gui/src/app/state/spend/step.rs | 2 +- gui/src/app/view/spend/detail.rs | 132 +++++++++++++++++-------------- gui/src/ui/component/form.rs | 33 ++++---- 3 files changed, 92 insertions(+), 75 deletions(-) diff --git a/gui/src/app/state/spend/step.rs b/gui/src/app/state/spend/step.rs index 0467cbef..0d26c677 100644 --- a/gui/src/app/state/spend/step.rs +++ b/gui/src/app/state/spend/step.rs @@ -346,7 +346,7 @@ impl Step for SaveSpend { psbt.unsigned_tx .output .iter() - .position(|output| outputs_script_pubkeys.contains(&output.script_pubkey)) + .position(|output| !outputs_script_pubkeys.contains(&output.script_pubkey)) } else { None }; diff --git a/gui/src/app/view/spend/detail.rs b/gui/src/app/view/spend/detail.rs index dd72aed3..4b1c0c23 100644 --- a/gui/src/app/view/spend/detail.rs +++ b/gui/src/app/view/spend/detail.rs @@ -37,9 +37,11 @@ pub fn spend_view<'a, T: Into>>( show_delete, warning, column() + .align_items(Alignment::Center) .spacing(20) - .push(spend_overview_view(tx)) + .push(spend_header(tx)) .push(action) + .push(spend_overview_view(tx)) .push(inputs_and_outputs_view( &tx.coins, &tx.psbt, @@ -139,7 +141,11 @@ pub fn spend_modal<'a, T: Into>>( ) .width(Length::Fill) } else { - column().width(Length::Fill) + column() + .push( + button::transparent(None, "< Previous").on_press(Message::Previous), + ) + .width(Length::Fill) }) .align_items(iced::Alignment::Center) .push( @@ -155,7 +161,7 @@ pub fn spend_modal<'a, T: Into>>( .into() } -fn spend_overview_view<'a>(tx: &SpendTx) -> Element<'a, Message> { +fn spend_header<'a>(tx: &SpendTx) -> Element<'a, Message> { column() .spacing(20) .align_items(Alignment::Center) @@ -192,49 +198,53 @@ fn spend_overview_view<'a>(tx: &SpendTx) -> Element<'a, Message> { tx.fee_amount.to_btc() )))), ) - .push(card::simple( - column() - .push(container( - row() - .push( - container( - row() - .push(container(icon::key_icon().size(30).width(Length::Fill))) - .push(column().push(text("Number of signatures:").bold()).push( - text(&format!("{}", tx.psbt.inputs[0].partial_sigs.len(),)), - )) - .align_items(Alignment::Center) - .spacing(20), - ) - .width(Length::FillPortion(1)), - ) - .align_items(Alignment::Center) - .spacing(20), - )) - .push(separation().width(Length::Fill)) - .push( - column() - .push( - row() - .push(text("Tx ID:").bold().width(Length::Fill)) - .push(text(&format!("{}", tx.psbt.unsigned_tx.txid())).small()) - .align_items(Alignment::Center), - ) - .push( - row() - .push(text("Psbt:").bold().width(Length::Fill)) - .push( - button::transparent(Some(icon::clipboard_icon()), "Copy") - .on_press(Message::Clipboard(tx.psbt.to_string())), - ) - .align_items(Alignment::Center), - ), - ) - .spacing(20), - )) .into() } +fn spend_overview_view<'a>(tx: &SpendTx) -> Element<'a, Message> { + card::simple( + column() + .push(container( + row() + .push( + container( + row() + .push(container(icon::key_icon().size(30).width(Length::Fill))) + .push(column().push(text("Number of signatures:").bold()).push( + text(&format!("{}", tx.psbt.inputs[0].partial_sigs.len(),)), + )) + .align_items(Alignment::Center) + .spacing(20), + ) + .width(Length::FillPortion(1)), + ) + .align_items(Alignment::Center) + .spacing(20), + )) + .push(separation().width(Length::Fill)) + .push( + column() + .push( + row() + .push(text("Tx ID:").bold().width(Length::Fill)) + .push(text(&format!("{}", tx.psbt.unsigned_tx.txid())).small()) + .align_items(Alignment::Center), + ) + .push( + row() + .push(text("Psbt:").bold().width(Length::Fill)) + .push( + button::transparent(Some(icon::clipboard_icon()), "Copy") + .on_press(Message::Clipboard(tx.psbt.to_string())), + ) + .align_items(Alignment::Center), + ), + ) + .spacing(20), + ) + .into() +} + fn inputs_and_outputs_view<'a>( coins: &[Coin], psbt: &Psbt, @@ -272,24 +282,28 @@ fn inputs_and_outputs_view<'a>( col.push( card::simple( column() - .width(Length::Fill) + .spacing(10) .push( - text(&format!( - "{} BTC", - Amount::from_sat(output.value).to_btc() - )) - .bold(), - ) - .push( - text(&format!( - "{}", - Address::from_script( - &output.script_pubkey, - network + column() + .width(Length::Fill) + .push( + text(&format!( + "{} BTC", + Amount::from_sat(output.value).to_btc() + )) + .bold(), ) - .unwrap() - )) - .small(), + .push( + text(&format!( + "{}", + Address::from_script( + &output.script_pubkey, + network + ) + .unwrap() + )) + .small(), + ), ) .push_maybe(if Some(i) == change_index { Some( diff --git a/gui/src/ui/component/form.rs b/gui/src/ui/component/form.rs index 861993d8..b1b84360 100644 --- a/gui/src/ui/component/form.rs +++ b/gui/src/ui/component/form.rs @@ -5,7 +5,7 @@ use iced::pure::{ }; use iced::Length; -use crate::ui::{color, component::text::*}; +use crate::ui::{color, component::text::*, util::Collection}; #[derive(Debug, Clone)] pub struct Value { @@ -70,21 +70,24 @@ where impl<'a, Message: 'a + Clone> From> for Element<'a, Message> { fn from(form: Form<'a, Message>) -> Element<'a, Message> { - if !form.valid { - if let Some(message) = form.warning { - return container( - column() - .push(form.input.style(InvalidFormStyle)) - .push(text(message).color(color::ALERT).small()) - .width(Length::Fill) - .spacing(5), - ) + container( + column() + .push(if !form.valid { + form.input.style(InvalidFormStyle) + } else { + form.input + }) + .push_maybe(if !form.valid { + form.warning + .map(|message| text(message).color(color::ALERT).small()) + } else { + None + }) .width(Length::Fill) - .into(); - } - } - - container(form.input).width(Length::Fill).into() + .spacing(5), + ) + .width(Length::Fill) + .into() } }