gui: create self send transaction
This commit is contained in:
parent
89162262e9
commit
032cf801d5
@ -112,8 +112,11 @@ impl DefineSpend {
|
||||
}
|
||||
}
|
||||
fn check_valid(&mut self) {
|
||||
self.is_valid = !self.recipients.is_empty();
|
||||
self.is_valid = self.feerate.valid && !self.feerate.value.is_empty();
|
||||
self.is_duplicate = false;
|
||||
if !self.coins.iter().any(|(_, selected)| *selected) {
|
||||
self.is_valid = false;
|
||||
}
|
||||
for (i, recipient) in self.recipients.iter().enumerate() {
|
||||
if !recipient.valid() {
|
||||
self.is_valid = false;
|
||||
@ -212,9 +215,9 @@ impl Step for DefineSpend {
|
||||
}
|
||||
|
||||
view::CreateSpendMessage::FeerateEdited(s) => {
|
||||
if s.parse::<u64>().is_ok() {
|
||||
if let Ok(value) = s.parse::<u64>() {
|
||||
self.feerate.value = s;
|
||||
self.feerate.valid = true;
|
||||
self.feerate.valid = value != 0;
|
||||
self.amount_left_to_select();
|
||||
} else if s.is_empty() {
|
||||
self.feerate.value = "".to_string();
|
||||
|
||||
@ -93,12 +93,13 @@ pub fn create_spend_tx<'a>(
|
||||
feerate: &form::Value<String>,
|
||||
error: Option<&Error>,
|
||||
) -> Element<'a, Message> {
|
||||
let is_self_send = recipients.is_empty();
|
||||
dashboard(
|
||||
&Menu::CreateSpendTx,
|
||||
cache,
|
||||
error,
|
||||
Column::new()
|
||||
.push(h3("Send"))
|
||||
.push(h3(if is_self_send { "Self send" } else { "Send" }))
|
||||
.push(
|
||||
Column::new()
|
||||
.push(Column::with_children(recipients).spacing(10))
|
||||
@ -151,7 +152,26 @@ pub fn create_spend_tx<'a>(
|
||||
Row::new()
|
||||
.align_items(Alignment::Center)
|
||||
.push(p1_bold("Coins selection").width(Length::Fill))
|
||||
.push(Container::new(if let Some(amount_left) = amount_left {
|
||||
.push(if is_self_send {
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(amount_with_size(
|
||||
&Amount::from_sat(
|
||||
coins
|
||||
.iter()
|
||||
.filter_map(|(coin, selected)| {
|
||||
if *selected {
|
||||
Some(coin.amount.to_sat())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.sum(),
|
||||
),
|
||||
P2_SIZE,
|
||||
))
|
||||
.push(p2_regular("selected").style(color::GREY_3))
|
||||
} else if let Some(amount_left) = amount_left {
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(amount_with_size(amount_left, P2_SIZE))
|
||||
@ -159,7 +179,7 @@ pub fn create_spend_tx<'a>(
|
||||
} else {
|
||||
Row::new()
|
||||
.push(text("Feerate needs to be set.").style(color::GREY_3))
|
||||
}))
|
||||
})
|
||||
.width(Length::Fill),
|
||||
)
|
||||
.push(
|
||||
@ -193,8 +213,9 @@ pub fn create_spend_tx<'a>(
|
||||
)
|
||||
.push(
|
||||
if is_valid
|
||||
&& total_amount < *balance_available
|
||||
&& Some(&Amount::from_sat(0)) == amount_left
|
||||
&& (is_self_send
|
||||
|| (total_amount < *balance_available
|
||||
&& Some(&Amount::from_sat(0)) == amount_left))
|
||||
{
|
||||
button::primary(None, "Next")
|
||||
.on_press(Message::CreateSpend(CreateSpendMessage::Generate))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user