diff --git a/Cargo.toml b/Cargo.toml index f395d9e7..e52ed1d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cashu-crab" -version = "0.3.0" +version = "0.4.0-ALPHA" edition = "2021" authors = ["thesimplekid"] license = "BSD-3-Clause" diff --git a/src/error.rs b/src/error.rs index 7262785b..e301c9f3 100644 --- a/src/error.rs +++ b/src/error.rs @@ -158,6 +158,7 @@ pub mod mint { EllipticError(k256::elliptic_curve::Error), TokenNotVerifed, InvoiceAmountUndefined, + CustomError(String), } impl StdError for Error {} @@ -169,6 +170,7 @@ pub mod mint { Error::Amount => write!(f, "Amount miss match"), Error::TokenSpent => write!(f, "Token Spent"), Error::EllipticError(err) => write!(f, "{}", err), + Error::CustomError(err) => write!(f, "{}", err), Error::TokenNotVerifed => write!(f, "Token Not Verified"), Error::InvoiceAmountUndefined => write!(f, "Invoice without amount"), } diff --git a/src/mint.rs b/src/mint.rs index ed770ec9..2c53475a 100644 --- a/src/mint.rs +++ b/src/mint.rs @@ -103,6 +103,7 @@ impl Mint { let proofs_total = split_request.proofs_amount(); let output_total = split_request.output_amount(); + if proofs_total != output_total { return Err(Error::Amount); } @@ -124,10 +125,6 @@ impl Mint { Ok(SplitResponse::new(promises)) } Some(amount) => { - if proofs_total.le(amount) { - return Err(Error::Amount); - } - let outs_fst = (proofs_total.to_owned() - amount.to_owned()).split(); // Blinded change messages @@ -141,7 +138,7 @@ impl Mint { let split_response = SplitResponse::new_from_amount(fst, snd); if split_response.target_amount() != split_request.amount { - return Err(Error::OutputOrdering); + return Err(Error::CustomError("Output order".to_string())); } Ok(split_response) diff --git a/src/wallet.rs b/src/wallet.rs index 943f6bde..1b770518 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -13,7 +13,11 @@ use crate::nuts::nut06::{SplitPayload, SplitRequest}; use crate::types::{Melted, ProofsStatus, SendProofs}; use crate::Amount; pub use crate::Invoice; -use crate::{client::Client, dhke::construct_proofs, error}; +use crate::{ + client::Client, + dhke::construct_proofs, + error::{self, wallet::Error}, +}; #[derive(Clone, Debug)] pub struct Wallet {