diff --git a/crates/cashu-sdk/src/client/minreq_client.rs b/crates/cashu-sdk/src/client/minreq_client.rs index b2ce0421..7e58fc3e 100644 --- a/crates/cashu-sdk/src/client/minreq_client.rs +++ b/crates/cashu-sdk/src/client/minreq_client.rs @@ -1,7 +1,5 @@ //! Minreq http Client -use std::println; - use async_trait::async_trait; use cashu::nuts::{ BlindedMessage, CurrencyUnit, KeySet, KeysResponse, KeysetResponse, MeltBolt11Request, @@ -11,6 +9,7 @@ use cashu::nuts::{ }; #[cfg(feature = "nut07")] use cashu::nuts::{CheckStateRequest, CheckStateResponse}; +#[cfg(feature = "nut07")] use cashu::secret::Secret; use cashu::{Amount, Bolt11Invoice}; use serde_json::Value; diff --git a/crates/cashu-sdk/src/client/mod.rs b/crates/cashu-sdk/src/client/mod.rs index a255857e..9f59c294 100644 --- a/crates/cashu-sdk/src/client/mod.rs +++ b/crates/cashu-sdk/src/client/mod.rs @@ -8,6 +8,7 @@ use cashu::nuts::{ MeltQuoteBolt11Response, MintBolt11Response, MintInfo, MintQuoteBolt11Response, PreMintSecrets, Proof, SwapRequest, SwapResponse, }; +#[cfg(feature = "nut07")] use cashu::secret::Secret; use cashu::{utils, Amount}; use serde::{Deserialize, Serialize}; diff --git a/crates/cashu-sdk/src/mint/mod.rs b/crates/cashu-sdk/src/mint/mod.rs index 8ec077db..414295d6 100644 --- a/crates/cashu-sdk/src/mint/mod.rs +++ b/crates/cashu-sdk/src/mint/mod.rs @@ -2,7 +2,7 @@ use std::collections::HashSet; use cashu::dhke::{sign_message, verify_message}; #[cfg(feature = "nut07")] -use cashu::nuts::nut07::State; +use cashu::nuts::nut07::{ProofState, State}; use cashu::nuts::{ BlindedMessage, BlindedSignature, MeltBolt11Request, MeltBolt11Response, Proof, SwapRequest, SwapResponse, *, @@ -373,26 +373,12 @@ impl Mint { &self, check_spendable: &CheckStateRequest, ) -> Result { - use cashu::nuts::nut07::ProofState; - let mut states = Vec::with_capacity(check_spendable.secrets.len()); for secret in &check_spendable.secrets { - let state = if self - .localstore - .get_spent_proof(secret) - .await - .unwrap() - .is_some() - { + let state = if self.localstore.get_spent_proof(secret).await?.is_some() { State::Spent - } else if self - .localstore - .get_pending_proof(secret) - .await - .unwrap() - .is_some() - { + } else if self.localstore.get_pending_proof(secret).await?.is_some() { State::Pending } else { State::Unspent diff --git a/crates/cashu/src/nuts/nut00.rs b/crates/cashu/src/nuts/nut00.rs index 081e1d6b..74d26597 100644 --- a/crates/cashu/src/nuts/nut00.rs +++ b/crates/cashu/src/nuts/nut00.rs @@ -428,64 +428,6 @@ impl PartialOrd for Proof { } } -impl From for mint::Proof { - fn from(proof: Proof) -> Self { - Self { - amount: Some(proof.amount), - secret: proof.secret, - c: Some(proof.c), - keyset_id: Some(proof.keyset_id), - } - } -} - -impl TryFrom for Proof { - type Error = Error; - - fn try_from(mint_proof: mint::Proof) -> Result { - Ok(Self { - keyset_id: mint_proof.keyset_id.ok_or(Error::MissingProofField)?, - amount: mint_proof.amount.ok_or(Error::MissingProofField)?, - secret: mint_proof.secret, - c: mint_proof.c.ok_or(Error::MissingProofField)?, - }) - } -} - -pub mod mint { - use serde::{Deserialize, Serialize}; - - use super::PublicKey; - use crate::nuts::nut02::Id; - use crate::secret::Secret; - use crate::Amount; - - /// Proofs [NUT-00] - #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] - pub struct Proof { - /// Amount in satoshi - #[serde(skip_serializing)] - pub amount: Option, - /// Secret message - #[serde(skip_serializing)] - pub secret: Secret, - /// Unblinded signature - #[serde(rename = "C")] - pub c: Option, - /// `Keyset id` - #[serde(skip_serializing)] - #[serde(rename = "id")] - pub keyset_id: Option, - } - - /// List of proofs - pub type Proofs = Vec; - - pub fn mint_proofs_from_proofs(proofs: crate::nuts::Proofs) -> Proofs { - proofs.iter().map(|p| p.to_owned().into()).collect() - } -} - #[cfg(test)] mod tests { use std::str::FromStr;