mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-08 06:35:52 +01:00
fix: fix amount ordering error
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user