Преглед на файлове

refactor: check if token is pending during verification

thesimplekid преди 1 година
родител
ревизия
b0a8d6046d
променени са 1 файла, в които са добавени 12 реда и са изтрити 2 реда
  1. 12 2
      crates/cashu-sdk/src/mint/mod.rs

+ 12 - 2
crates/cashu-sdk/src/mint/mod.rs

@@ -36,6 +36,8 @@ pub enum Error {
     DuplicateProofs,
     #[error("Token Spent")]
     TokenSpent,
+    #[error("Token Pending")]
+    TokenPending,
     #[error("`{0}`")]
     Custom(String),
     #[error("`{0}`")]
@@ -271,13 +273,21 @@ impl<L: LocalStore> Mint<L> {
         if self
             .localstore
             .get_spent_proof(&proof.secret)
-            .await
-            .unwrap()
+            .await?
             .is_some()
         {
             return Err(Error::TokenSpent);
         }
 
+        if self
+            .localstore
+            .get_pending_proof(&proof.secret)
+            .await?
+            .is_some()
+        {
+            return Err(Error::TokenPending);
+        }
+
         let keyset = self
             .localstore
             .get_keyset(&proof.keyset_id)