From 86896c822317ab108541acbf0622d94a9119c479 Mon Sep 17 00:00:00 2001 From: edouard Date: Mon, 9 Jan 2023 11:41:43 +0100 Subject: [PATCH] Check output amount superior to dust value close #237 --- gui/src/app/state/spend/step.rs | 7 +++++++ gui/src/app/view/spend/step.rs | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gui/src/app/state/spend/step.rs b/gui/src/app/state/spend/step.rs index 49f3e7d8..933c929b 100644 --- a/gui/src/app/state/spend/step.rs +++ b/gui/src/app/state/spend/step.rs @@ -21,6 +21,9 @@ use crate::{ ui::component::form, }; +/// See: https://github.com/wizardsardine/liana/blob/master/src/commands/mod.rs#L32 +const DUST_OUTPUT_SATS: u64 = 5_000; + #[derive(Default, Clone)] pub struct TransactionDraft { inputs: Vec, @@ -162,6 +165,10 @@ impl Recipient { return Err(Error::Unexpected("Amount should be non-zero".to_string())); } + if amount.to_sat() < DUST_OUTPUT_SATS { + return Err(Error::Unexpected("Amount should be non-zero".to_string())); + } + if let Ok(address) = Address::from_str(&self.address.value) { if amount <= address.script_pubkey().dust_value() { return Err(Error::Unexpected( diff --git a/gui/src/app/view/spend/step.rs b/gui/src/app/view/spend/step.rs index 18e0179b..f1dfbd85 100644 --- a/gui/src/app/view/spend/step.rs +++ b/gui/src/app/view/spend/step.rs @@ -100,11 +100,11 @@ pub fn recipient_view<'a>( form::Form::new("Amount", amount, move |msg| { CreateSpendMessage::RecipientEdited(index, "amount", msg) }) - .warning("Please enter correct amount") + .warning("Please enter correct amount (> 5000 sats)") .size(20) .padding(10), ) - .width(Length::Units(250)), + .width(Length::Units(300)), ) .spacing(5) .push(