Restart spend process according to current state
Spend process keeps its state if it is the first step. User can click on Clear to reset if he wants.
This commit is contained in:
parent
a91fdd791a
commit
710883b6a2
@ -2,6 +2,7 @@ use std::{cmp::Ordering, collections::HashMap, str::FromStr, sync::Arc};
|
||||
|
||||
use iced::{Command, Subscription};
|
||||
use liana::{
|
||||
commands::ListCoinsEntry,
|
||||
descriptors::LianaDescriptor,
|
||||
miniscript::bitcoin::{
|
||||
address, psbt::Psbt, secp256k1, Address, Amount, Denomination, Network, OutPoint,
|
||||
@ -399,6 +400,19 @@ impl Step for DefineSpend {
|
||||
self.batch_label.valid = label.len() <= 100;
|
||||
self.batch_label.value = label;
|
||||
}
|
||||
view::CreateSpendMessage::Clear => {
|
||||
*self = Self::new(
|
||||
self.network,
|
||||
self.descriptor.clone(),
|
||||
self.coins
|
||||
.iter()
|
||||
.map(|(c, _)| c.clone())
|
||||
.collect::<Vec<ListCoinsEntry>>()
|
||||
.as_slice(),
|
||||
self.timelock,
|
||||
);
|
||||
return Command::none();
|
||||
}
|
||||
view::CreateSpendMessage::AddRecipient => {
|
||||
self.recipients.push(Recipient::default());
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ pub enum CreateSpendMessage {
|
||||
SelectPath(usize),
|
||||
Generate,
|
||||
SendMaxToRecipient(usize),
|
||||
Clear,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@ -98,7 +98,7 @@ pub fn sidebar<'a>(menu: &Menu, cache: &'a Cache) -> Container<'a, Message> {
|
||||
let spend_button = if *menu == Menu::CreateSpendTx {
|
||||
row!(
|
||||
button::menu_active(Some(send_icon()), "Send")
|
||||
.on_press(Message::Menu(Menu::CreateSpendTx))
|
||||
.on_press(Message::Reload)
|
||||
.width(iced::Length::Fill),
|
||||
menu_green_bar()
|
||||
)
|
||||
|
||||
@ -294,7 +294,7 @@ pub fn create_spend_tx<'a>(
|
||||
.push(Space::with_width(Length::Fill))
|
||||
.push(
|
||||
button::primary(None, "Clear")
|
||||
.on_press(Message::Menu(Menu::CreateSpendTx))
|
||||
.on_press(Message::CreateSpend(CreateSpendMessage::Clear))
|
||||
.width(Length::Fixed(100.0)),
|
||||
)
|
||||
.push(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user