Check output amount superior to dust value

close #237
This commit is contained in:
edouard 2023-01-09 11:41:43 +01:00
parent ecd35d2bd1
commit 86896c8223
2 changed files with 9 additions and 2 deletions

View File

@ -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<Coin>,
@ -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(

View File

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