Эх сурвалжийг харах

Fixed parameters order and fmt

Cesar Rodas 1 сар өмнө
parent
commit
870ed941e9

+ 1 - 1
crates/cdk-cli/src/sub_commands/check_pending.rs

@@ -28,7 +28,7 @@ pub async fn check_pending(multi_mint_wallet: &MultiMintWallet) -> Result<()> {
         );
 
         // Try to reclaim any proofs that are no longer pending
-        match wallet.reclaim_unspent(pending_proofs, &mut tx).await {
+        match wallet.reclaim_unspent(&mut tx, pending_proofs).await {
             Ok(()) => println!("Successfully reclaimed pending proofs"),
             Err(e) => println!("Error reclaimed pending proofs: {e}"),
         }

+ 136 - 45
crates/cdk-ffi/src/postgres.rs

@@ -47,20 +47,32 @@ impl WalletDatabase for WalletPostgresDatabase {
     ) -> Result<(), FfiError> {
         let cdk_mint_url = mint_url.try_into()?;
         let cdk_mint_info = mint_info.map(Into::into);
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_mint(cdk_mint_url, cdk_mint_info).await
+        tx.add_mint(cdk_mint_url, cdk_mint_info)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
     async fn remove_mint(&self, mint_url: MintUrl) -> Result<(), FfiError> {
         let cdk_mint_url = mint_url.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.remove_mint(cdk_mint_url).await
+        tx.remove_mint(cdk_mint_url)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
     async fn get_mint(&self, mint_url: MintUrl) -> Result<Option<MintInfo>, FfiError> {
@@ -90,11 +102,17 @@ impl WalletDatabase for WalletPostgresDatabase {
     ) -> Result<(), FfiError> {
         let cdk_old_mint_url = old_mint_url.try_into()?;
         let cdk_new_mint_url = new_mint_url.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.update_mint_url(cdk_old_mint_url, cdk_new_mint_url).await
+        tx.update_mint_url(cdk_old_mint_url, cdk_new_mint_url)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
     async fn add_mint_keysets(
@@ -104,11 +122,17 @@ impl WalletDatabase for WalletPostgresDatabase {
     ) -> Result<(), FfiError> {
         let cdk_mint_url = mint_url.try_into()?;
         let cdk_keysets: Vec<cdk::nuts::KeySetInfo> = keysets.into_iter().map(Into::into).collect();
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_mint_keysets(cdk_mint_url, cdk_keysets).await
+        tx.add_mint_keysets(cdk_mint_url, cdk_keysets)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
     async fn get_mint_keysets(
@@ -137,11 +161,17 @@ impl WalletDatabase for WalletPostgresDatabase {
     // Mint Quote Management
     async fn add_mint_quote(&self, quote: MintQuote) -> Result<(), FfiError> {
         let cdk_quote = quote.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_mint_quote(cdk_quote).await
+        tx.add_mint_quote(cdk_quote)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -164,22 +194,34 @@ impl WalletDatabase for WalletPostgresDatabase {
     }
 
     async fn remove_mint_quote(&self, quote_id: String) -> Result<(), FfiError> {
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.remove_mint_quote(&quote_id).await
+        tx.remove_mint_quote(&quote_id)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
     // Melt Quote Management
     async fn add_melt_quote(&self, quote: MeltQuote) -> Result<(), FfiError> {
         let cdk_quote = quote.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_melt_quote(cdk_quote).await
+        tx.add_melt_quote(cdk_quote)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -202,11 +244,17 @@ impl WalletDatabase for WalletPostgresDatabase {
     }
 
     async fn remove_melt_quote(&self, quote_id: String) -> Result<(), FfiError> {
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.remove_melt_quote(&quote_id).await
+        tx.remove_melt_quote(&quote_id)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -214,11 +262,17 @@ impl WalletDatabase for WalletPostgresDatabase {
     async fn add_keys(&self, keyset: KeySet) -> Result<(), FfiError> {
         // Convert FFI KeySet to cdk::nuts::KeySet
         let cdk_keyset: cdk::nuts::KeySet = keyset.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_keys(cdk_keyset).await
+        tx.add_keys(cdk_keyset)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -234,11 +288,17 @@ impl WalletDatabase for WalletPostgresDatabase {
 
     async fn remove_keys(&self, id: Id) -> Result<(), FfiError> {
         let cdk_id = id.into();
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.remove_keys(&cdk_id).await
+        tx.remove_keys(&cdk_id)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -271,11 +331,17 @@ impl WalletDatabase for WalletPostgresDatabase {
             removed_ys.into_iter().map(|pk| pk.try_into()).collect();
         let cdk_removed_ys = cdk_removed_ys?;
 
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.update_proofs(cdk_added, cdk_removed_ys).await
+        tx.update_proofs(cdk_added, cdk_removed_ys)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -333,22 +399,35 @@ impl WalletDatabase for WalletPostgresDatabase {
         let cdk_ys = cdk_ys?;
         let cdk_state = state.into();
 
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.update_proofs_state(cdk_ys, cdk_state).await
+        tx.update_proofs_state(cdk_ys, cdk_state)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
     // Keyset Counter Management
     async fn increment_keyset_counter(&self, keyset_id: Id, count: u32) -> Result<u32, FfiError> {
         let cdk_id = keyset_id.into();
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        let result = tx.increment_keyset_counter(&cdk_id, count).await
+        let result = tx
+            .increment_keyset_counter(&cdk_id, count)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
         Ok(result)
     }
@@ -358,11 +437,17 @@ impl WalletDatabase for WalletPostgresDatabase {
         // Convert FFI Transaction to CDK Transaction using TryFrom
         let cdk_transaction: cdk::wallet::types::Transaction = transaction.try_into()?;
 
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_transaction(cdk_transaction).await
+        tx.add_transaction(cdk_transaction)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -400,11 +485,17 @@ impl WalletDatabase for WalletPostgresDatabase {
 
     async fn remove_transaction(&self, transaction_id: TransactionId) -> Result<(), FfiError> {
         let cdk_id = transaction_id.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.remove_transaction(cdk_id).await
+        tx.remove_transaction(cdk_id)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 }

+ 136 - 45
crates/cdk-ffi/src/sqlite.rs

@@ -79,21 +79,33 @@ impl WalletDatabase for WalletSqliteDatabase {
     ) -> Result<(), FfiError> {
         let cdk_mint_url = mint_url.try_into()?;
         let cdk_mint_info = mint_info.map(Into::into);
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_mint(cdk_mint_url, cdk_mint_info).await
+        tx.add_mint(cdk_mint_url, cdk_mint_info)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
     async fn remove_mint(&self, mint_url: MintUrl) -> Result<(), FfiError> {
         let cdk_mint_url = mint_url.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.remove_mint(cdk_mint_url).await
+        tx.remove_mint(cdk_mint_url)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -126,11 +138,17 @@ impl WalletDatabase for WalletSqliteDatabase {
     ) -> Result<(), FfiError> {
         let cdk_old_mint_url = old_mint_url.try_into()?;
         let cdk_new_mint_url = new_mint_url.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.update_mint_url(cdk_old_mint_url, cdk_new_mint_url).await
+        tx.update_mint_url(cdk_old_mint_url, cdk_new_mint_url)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -142,11 +160,17 @@ impl WalletDatabase for WalletSqliteDatabase {
     ) -> Result<(), FfiError> {
         let cdk_mint_url = mint_url.try_into()?;
         let cdk_keysets: Vec<cdk::nuts::KeySetInfo> = keysets.into_iter().map(Into::into).collect();
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_mint_keysets(cdk_mint_url, cdk_keysets).await
+        tx.add_mint_keysets(cdk_mint_url, cdk_keysets)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -176,11 +200,17 @@ impl WalletDatabase for WalletSqliteDatabase {
     // Mint Quote Management
     async fn add_mint_quote(&self, quote: MintQuote) -> Result<(), FfiError> {
         let cdk_quote = quote.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_mint_quote(cdk_quote).await
+        tx.add_mint_quote(cdk_quote)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -203,22 +233,34 @@ impl WalletDatabase for WalletSqliteDatabase {
     }
 
     async fn remove_mint_quote(&self, quote_id: String) -> Result<(), FfiError> {
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.remove_mint_quote(&quote_id).await
+        tx.remove_mint_quote(&quote_id)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
     // Melt Quote Management
     async fn add_melt_quote(&self, quote: MeltQuote) -> Result<(), FfiError> {
         let cdk_quote = quote.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_melt_quote(cdk_quote).await
+        tx.add_melt_quote(cdk_quote)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -241,11 +283,17 @@ impl WalletDatabase for WalletSqliteDatabase {
     }
 
     async fn remove_melt_quote(&self, quote_id: String) -> Result<(), FfiError> {
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.remove_melt_quote(&quote_id).await
+        tx.remove_melt_quote(&quote_id)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -253,11 +301,17 @@ impl WalletDatabase for WalletSqliteDatabase {
     async fn add_keys(&self, keyset: KeySet) -> Result<(), FfiError> {
         // Convert FFI KeySet to cdk::nuts::KeySet
         let cdk_keyset: cdk::nuts::KeySet = keyset.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_keys(cdk_keyset).await
+        tx.add_keys(cdk_keyset)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -273,11 +327,17 @@ impl WalletDatabase for WalletSqliteDatabase {
 
     async fn remove_keys(&self, id: Id) -> Result<(), FfiError> {
         let cdk_id = id.into();
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.remove_keys(&cdk_id).await
+        tx.remove_keys(&cdk_id)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -310,11 +370,17 @@ impl WalletDatabase for WalletSqliteDatabase {
             removed_ys.into_iter().map(|pk| pk.try_into()).collect();
         let cdk_removed_ys = cdk_removed_ys?;
 
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.update_proofs(cdk_added, cdk_removed_ys).await
+        tx.update_proofs(cdk_added, cdk_removed_ys)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -372,22 +438,35 @@ impl WalletDatabase for WalletSqliteDatabase {
         let cdk_ys = cdk_ys?;
         let cdk_state = state.into();
 
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.update_proofs_state(cdk_ys, cdk_state).await
+        tx.update_proofs_state(cdk_ys, cdk_state)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
     // Keyset Counter Management
     async fn increment_keyset_counter(&self, keyset_id: Id, count: u32) -> Result<u32, FfiError> {
         let cdk_id = keyset_id.into();
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        let result = tx.increment_keyset_counter(&cdk_id, count).await
+        let result = tx
+            .increment_keyset_counter(&cdk_id, count)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
         Ok(result)
     }
@@ -397,11 +476,17 @@ impl WalletDatabase for WalletSqliteDatabase {
         // Convert FFI Transaction to CDK Transaction using TryFrom
         let cdk_transaction: cdk::wallet::types::Transaction = transaction.try_into()?;
 
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.add_transaction(cdk_transaction).await
+        tx.add_transaction(cdk_transaction)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 
@@ -439,11 +524,17 @@ impl WalletDatabase for WalletSqliteDatabase {
 
     async fn remove_transaction(&self, transaction_id: TransactionId) -> Result<(), FfiError> {
         let cdk_id = transaction_id.try_into()?;
-        let mut tx = self.inner.begin_db_transaction().await
+        let mut tx = self
+            .inner
+            .begin_db_transaction()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        tx.remove_transaction(cdk_id).await
+        tx.remove_transaction(cdk_id)
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })?;
-        Box::new(tx).commit().await
+        Box::new(tx)
+            .commit()
+            .await
             .map_err(|e| FfiError::Database { msg: e.to_string() })
     }
 }

+ 5 - 3
crates/cdk-integration-tests/tests/bolt12.rs

@@ -327,7 +327,7 @@ async fn test_regtest_bolt12_mint_extra() -> Result<()> {
 
     let mut tx = wallet.localstore.begin_db_transaction().await?;
     let state = wallet
-        .mint_bolt12_quote_state(&mint_quote.id, &mut tx)
+        .mint_bolt12_quote_state(&mut tx, &mint_quote.id)
         .await?;
     tx.commit().await?;
 
@@ -351,7 +351,9 @@ async fn test_regtest_bolt12_mint_extra() -> Result<()> {
         .unwrap();
 
     let mut tx = wallet.localstore.begin_db_transaction().await?;
-    let state = wallet.mint_bolt12_quote_state(&mint_quote.id, &mut tx).await?;
+    let state = wallet
+        .mint_bolt12_quote_state(&mint_quote.id, &mut tx)
+        .await?;
     tx.commit().await?;
 
     assert_eq!(payment, state.amount_paid);
@@ -444,7 +446,7 @@ async fn test_attempt_to_mint_unpaid() {
 
     let mut tx = wallet.localstore.begin_db_transaction().await.expect("tx");
     let state = wallet
-        .mint_bolt12_quote_state(&mint_quote.id, &mut tx)
+        .mint_bolt12_quote_state(&mut tx, &mint_quote.id)
         .await
         .unwrap();
     tx.commit().await.expect("commit");

+ 1 - 1
crates/cdk-integration-tests/tests/integration_tests_pure.rs

@@ -778,7 +778,7 @@ async fn test_mint_change_with_fee_melt() {
         .await
         .unwrap();
     let w = wallet_alice
-        .melt_proofs_with_metadata(&melt_quote.id, proofs, HashMap::new(), &mut tx)
+        .melt_proofs_with_metadata(&mut tx, &melt_quote.id, proofs, HashMap::new())
         .await
         .unwrap();
     tx.commit().await.unwrap();

+ 1 - 1
crates/cdk-integration-tests/tests/test_fees.rs

@@ -112,7 +112,7 @@ async fn test_fake_melt_change_in_quote() {
 
     let mut tx = wallet.localstore.begin_db_transaction().await.unwrap();
     let melt = wallet
-        .melt_proofs_with_metadata(&melt_quote.id, proofs, HashMap::new(), &mut tx)
+        .melt_proofs_with_metadata(&mut tx, &melt_quote.id, proofs, HashMap::new())
         .await
         .unwrap();
     tx.commit().await.unwrap();

+ 3 - 3
crates/cdk/src/lib.rs

@@ -9,16 +9,16 @@ compile_error!("The 'tor' feature is not supported on wasm32 targets (browser).
 
 pub mod cdk_database {
     //! CDK Database
-    pub use cdk_common::database::{DbTransactionFinalizer, Error};
     #[cfg(all(feature = "mint", feature = "auth"))]
     pub use cdk_common::database::MintAuthDatabase;
-    #[cfg(feature = "wallet")]
-    pub use cdk_common::database::{WalletDatabase, WalletDatabaseTransaction};
+    pub use cdk_common::database::{DbTransactionFinalizer, Error};
     #[cfg(feature = "mint")]
     pub use cdk_common::database::{
         MintDatabase, MintKVStore, MintKVStoreDatabase, MintKVStoreTransaction, MintKeysDatabase,
         MintProofsDatabase, MintQuotesDatabase, MintSignaturesDatabase, MintTransaction,
     };
+    #[cfg(feature = "wallet")]
+    pub use cdk_common::database::{WalletDatabase, WalletDatabaseTransaction};
 }
 
 #[cfg(feature = "mint")]

+ 3 - 3
crates/cdk/src/wallet/issue/issue_bolt12.rs

@@ -114,7 +114,7 @@ impl Wallet {
             None => {
                 // If an amount it not supplied with check the status of the quote
                 // The mint will tell us how much can be minted
-                let state = self.mint_bolt12_quote_state(quote_id, &mut tx).await?;
+                let state = self.mint_bolt12_quote_state(&mut tx, quote_id).await?;
 
                 state.amount_paid - state.amount_issued
             }
@@ -248,11 +248,11 @@ impl Wallet {
     }
 
     /// Check mint quote status
-    #[instrument(skip(self, quote_id, tx))]
+    #[instrument(skip(self, tx, quote_id))]
     pub async fn mint_bolt12_quote_state(
         &self,
-        quote_id: &str,
         tx: &mut Tx<'_, '_>,
+        quote_id: &str,
     ) -> Result<MintQuoteBolt12Response<String>, Error> {
         let response = self.client.get_mint_quote_bolt12_status(quote_id).await?;
 

+ 1 - 2
crates/cdk/src/wallet/keysets.rs

@@ -4,11 +4,10 @@ use cdk_common::amount::{FeeAndAmounts, KeysetFeeAndAmounts};
 use cdk_common::nut02::{KeySetInfos, KeySetInfosMethods};
 use tracing::instrument;
 
+use super::Tx;
 use crate::nuts::{Id, KeySetInfo, Keys};
 use crate::{Error, Wallet};
 
-use super::Tx;
-
 impl Wallet {
     /// Load keys for mint keyset
     ///

+ 4 - 4
crates/cdk/src/wallet/melt/melt_bolt11.rs

@@ -132,13 +132,13 @@ impl Wallet {
     }
 
     /// Melt specific proofs
-    #[instrument(skip(self, proofs, tx))]
+    #[instrument(skip(self, tx, proofs))]
     pub async fn melt_proofs_with_metadata(
         &self,
+        tx: &mut Tx<'_, '_>,
         quote_id: &str,
         proofs: Proofs,
         metadata: HashMap<String, String>,
-        tx: &mut Tx<'_, '_>,
     ) -> Result<Melted, Error> {
         let quote_info = tx
             .get_melt_quote(quote_id)
@@ -211,7 +211,7 @@ impl Wallet {
                 tracing::error!("Could not melt: {}", err);
                 tracing::info!("Checking status of input proofs.");
 
-                self.reclaim_unspent(proofs, tx).await?;
+                self.reclaim_unspent(tx, proofs).await?;
 
                 return Err(err);
             }
@@ -415,7 +415,7 @@ impl Wallet {
         }
 
         let melted = self
-            .melt_proofs_with_metadata(quote_id, input_proofs, metadata, &mut tx)
+            .melt_proofs_with_metadata(&mut tx, quote_id, input_proofs, metadata)
             .await?;
 
         tx.commit().await?;

+ 1 - 2
crates/cdk/src/wallet/melt/mod.rs

@@ -5,9 +5,8 @@ use cdk_common::wallet::{MeltQuote, Transaction, TransactionDirection};
 use cdk_common::{Error, MeltQuoteBolt11Response, MeltQuoteState, ProofsMethods};
 use tracing::instrument;
 
-use crate::Wallet;
-
 use super::Tx;
+use crate::Wallet;
 
 #[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
 mod melt_bip353;

+ 3 - 4
crates/cdk/src/wallet/proofs.rs

@@ -5,6 +5,7 @@ use cdk_common::wallet::TransactionId;
 use cdk_common::Id;
 use tracing::instrument;
 
+use super::Tx;
 use crate::amount::SplitTarget;
 use crate::fees::calculate_fee;
 use crate::nuts::nut00::ProofsMethods;
@@ -14,8 +15,6 @@ use crate::nuts::{
 use crate::types::ProofInfo;
 use crate::{ensure_cdk, Amount, Error, Wallet};
 
-use super::Tx;
-
 impl Wallet {
     /// Get unspent proofs for mint
     #[instrument(skip(self))]
@@ -93,8 +92,8 @@ impl Wallet {
     /// Reclaim unspent proofs
     ///
     /// Checks the stats of [`Proofs`] swapping for a new [`Proof`] if unspent
-    #[instrument(skip(self, proofs, tx))]
-    pub async fn reclaim_unspent(&self, proofs: Proofs, tx: &mut Tx<'_, '_>) -> Result<(), Error> {
+    #[instrument(skip(self, tx, proofs))]
+    pub async fn reclaim_unspent(&self, tx: &mut Tx<'_, '_>, proofs: Proofs) -> Result<(), Error> {
         let proof_ys = proofs.ys()?;
 
         let transaction_id = TransactionId::new(proof_ys.clone());

+ 1 - 2
crates/cdk/src/wallet/receive.rs

@@ -8,6 +8,7 @@ use cdk_common::util::unix_time;
 use cdk_common::wallet::{Transaction, TransactionDirection};
 use tracing::instrument;
 
+use super::Tx;
 use crate::amount::SplitTarget;
 use crate::dhke::construct_proofs;
 use crate::nuts::nut00::ProofsMethods;
@@ -17,8 +18,6 @@ use crate::types::ProofInfo;
 use crate::util::hex;
 use crate::{ensure_cdk, Amount, Error, Wallet, SECP256K1};
 
-use super::Tx;
-
 impl Wallet {
     /// Receive proofs
     #[instrument(skip_all)]

+ 1 - 2
crates/cdk/src/wallet/swap.rs

@@ -1,6 +1,7 @@
 use cdk_common::nut02::KeySetInfosMethods;
 use tracing::instrument;
 
+use super::Tx;
 use crate::amount::SplitTarget;
 use crate::dhke::construct_proofs;
 use crate::nuts::nut00::ProofsMethods;
@@ -10,8 +11,6 @@ use crate::nuts::{
 use crate::types::ProofInfo;
 use crate::{ensure_cdk, Amount, Error, Wallet};
 
-use super::Tx;
-
 impl Wallet {
     async fn swap_inner(
         &self,

+ 1 - 1
crates/cdk/src/wallet/transactions.rs

@@ -53,7 +53,7 @@ impl Wallet {
             })
             .collect::<Vec<_>>();
 
-        self.reclaim_unspent(pending_spent_proofs, &mut db_tx)
+        self.reclaim_unspent(&mut db_tx, pending_spent_proofs)
             .await?;
 
         db_tx.commit().await?;