Skip to content

Commit f5d999e

Browse files
author
pythcoiner
committed
limit amount to 8 decimal digits
1 parent 3fcbb0b commit f5d999e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

gui/src/app/state/spend/step.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,9 @@ impl Recipient {
521521
}
522522
}
523523
view::CreateSpendMessage::RecipientEdited(_, "amount", amount) => {
524-
self.amount.value = amount;
524+
if let Some(a) = amount_checked(amount) {
525+
self.amount.value = a;
526+
}
525527
if !self.amount.value.is_empty() {
526528
self.amount.valid = self.amount().is_ok();
527529
} else {
@@ -627,3 +629,16 @@ impl Step for SaveSpend {
627629
}
628630
}
629631
}
632+
633+
fn amount_checked(input: String) -> Option<String> {
634+
match input.split_once('.') {
635+
Some((_, decimals)) => {
636+
if decimals.len() > 8 {
637+
None
638+
} else {
639+
Some(input.to_string())
640+
}
641+
}
642+
None => Some(input.to_string()),
643+
}
644+
}

0 commit comments

Comments
 (0)