Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rust/chains/tw_ripple/src/types/amount/native_amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ pub struct NativeAmount(i64);

impl NativeAmount {
pub fn new(amount: i64) -> SigningResult<Self> {
if amount < 0 {
return SigningError::err(SigningErrorType::Error_invalid_params).context(format!(
"Invalid XRP amount must not be negative (found: {amount})"
));
}
if amount > MAX_DROPS {
return SigningError::err(SigningErrorType::Error_invalid_params).context(format!(
"Invalid XRP amount is too large (max: {MAX_DROPS} found: {amount})"
Expand Down Expand Up @@ -75,5 +80,6 @@ mod tests {
NativeAmount::from_str("1e20").expect_err("More than max supply");
NativeAmount::from_str("1e-7").expect_err("Contains decimals");
NativeAmount::from_str("1.234").expect_err("Contains decimals");
NativeAmount::from_str("-1").expect_err("Negative");
}
}
Loading