From b9f56c61c1110c34fc01d74ab1633264f0211eae Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Fri, 29 Sep 2023 06:22:41 +0100 Subject: [PATCH] Revert "`cashu-sdk/mint` improve: `verify_melt` called by `proccess_melt_request`" This reverts commit 4a9101443f691f53e4a2781b7111ab428899203c. Verify needs to be public as clients will need to verify the request before paying and procesing the request --- bindings/cashu-sdk-ffi/src/cashu_sdk.udl | 2 ++ bindings/cashu-sdk-ffi/src/mint.rs | 8 ++++++++ crates/cashu-sdk/src/mint.rs | 4 +--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bindings/cashu-sdk-ffi/src/cashu_sdk.udl b/bindings/cashu-sdk-ffi/src/cashu_sdk.udl index 9da8b1f8c..a705d4878 100644 --- a/bindings/cashu-sdk-ffi/src/cashu_sdk.udl +++ b/bindings/cashu-sdk-ffi/src/cashu_sdk.udl @@ -339,6 +339,8 @@ interface Mint { PostMintResponse process_mint_request(MintRequest mint_request); [Throws=CashuSdkError] SplitResponse process_split_request(SplitRequest split_request); + [Throws=CashuSdkError] + void verify_melt_request(MeltRequest melt_request); [Throws=CashuSdkError] MeltResponse process_melt_request(MeltRequest melt_request, string preimage, Amount totoal_spent); }; \ No newline at end of file diff --git a/bindings/cashu-sdk-ffi/src/mint.rs b/bindings/cashu-sdk-ffi/src/mint.rs index a2f2c84bd..e79ebae17 100644 --- a/bindings/cashu-sdk-ffi/src/mint.rs +++ b/bindings/cashu-sdk-ffi/src/mint.rs @@ -114,6 +114,14 @@ impl Mint { )) } + pub fn verify_melt_request(&self, melt_request: Arc) -> Result<()> { + Ok(self + .inner + .write() + .unwrap() + .verify_melt_request(melt_request.as_ref().deref())?) + } + pub fn process_melt_request( &self, melt_request: Arc, diff --git a/crates/cashu-sdk/src/mint.rs b/crates/cashu-sdk/src/mint.rs index 2c8ea178c..b316d7193 100644 --- a/crates/cashu-sdk/src/mint.rs +++ b/crates/cashu-sdk/src/mint.rs @@ -232,7 +232,7 @@ impl Mint { Ok(CheckSpendableResponse { spendable, pending }) } - fn verify_melt_request(&mut self, melt_request: &MeltRequest) -> Result<(), Error> { + pub fn verify_melt_request(&mut self, melt_request: &MeltRequest) -> Result<(), Error> { let proofs_total = melt_request.proofs_amount(); let percent_fee_reserve = Amount::from_sat( @@ -274,8 +274,6 @@ impl Mint { preimage: &str, total_spent: Amount, ) -> Result { - self.verify_melt_request(melt_request)?; - let secrets = Vec::with_capacity(melt_request.proofs.len()); for secret in secrets { self.spent_secrets.insert(secret);