Skip to content

Commit

Permalink
Revert "cashu-sdk/mint improve: verify_melt called by `proccess_m…
Browse files Browse the repository at this point in the history
…elt_request`"

This reverts commit 4a91014.

Verify needs to be public as clients will need to verify the request before paying
and procesing the request
  • Loading branch information
thesimplekid committed Sep 29, 2023
1 parent 0d7966b commit b9f56c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions bindings/cashu-sdk-ffi/src/cashu_sdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
8 changes: 8 additions & 0 deletions bindings/cashu-sdk-ffi/src/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ impl Mint {
))
}

pub fn verify_melt_request(&self, melt_request: Arc<MeltRequest>) -> Result<()> {
Ok(self
.inner
.write()
.unwrap()
.verify_melt_request(melt_request.as_ref().deref())?)
}

pub fn process_melt_request(
&self,
melt_request: Arc<MeltRequest>,
Expand Down
4 changes: 1 addition & 3 deletions crates/cashu-sdk/src/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -274,8 +274,6 @@ impl Mint {
preimage: &str,
total_spent: Amount,
) -> Result<MeltResponse, Error> {
self.verify_melt_request(melt_request)?;

let secrets = Vec::with_capacity(melt_request.proofs.len());
for secret in secrets {
self.spent_secrets.insert(secret);
Expand Down

0 comments on commit b9f56c6

Please sign in to comment.