From a04c336c57bdfd91d9f3e23c0d8d5048e4223189 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Thu, 8 Jun 2023 00:16:25 -0400 Subject: [PATCH] mint token --- src/cashu_wallet.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cashu_wallet.rs b/src/cashu_wallet.rs index 64a52031..564360e6 100644 --- a/src/cashu_wallet.rs +++ b/src/cashu_wallet.rs @@ -34,8 +34,8 @@ impl CashuWallet { // TODO: getter method for keys that if it cant get them try again /// Check if a proof is spent - pub async fn check_proofs_spent(&self, proofs: Proofs) -> Result { - let spendable = self.client.check_spendable(&proofs).await?; + pub async fn check_proofs_spent(&self, proofs: &Proofs) -> Result { + let spendable = self.client.check_spendable(proofs).await?; // Separate proofs in spent and unspent based on mint response let (spendable, spent): (Vec<_>, Vec<_>) = proofs @@ -55,7 +55,15 @@ impl CashuWallet { } /// Mint Token - pub async fn mint_token(&self, amount: Amount, hash: &str) -> Result { + pub async fn mint_token(&self, amount: Amount, hash: &str) -> Result { + let proofs = self.mint(amount, hash).await?; + + let token = Token::new(self.client.mint_url.clone(), proofs, None); + Ok(token) + } + + /// Mint Proofs + pub async fn mint(&self, amount: Amount, hash: &str) -> Result { let blinded_messages = BlindedMessages::random(amount)?; let mint_res = self.client.mint(blinded_messages.clone(), hash).await?;