Skip to content

Commit 03c89d7

Browse files
committed
fix: wallet sql db internal txs
1 parent ff167ab commit 03c89d7

File tree

1 file changed

+13
-4
lines changed
  • crates/cdk-sql-common/src/wallet

1 file changed

+13
-4
lines changed

crates/cdk-sql-common/src/wallet/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ where
746746
removed_ys: Vec<PublicKey>,
747747
) -> Result<(), database::Error> {
748748
let conn = self.pool.get().map_err(|e| Error::Database(Box::new(e)))?;
749+
let tx = ConnectionWithTransaction::new(conn).await?;
749750

750751
for proof in added {
751752
query(
@@ -803,7 +804,7 @@ where
803804
"dleq_r",
804805
proof.proof.dleq.as_ref().map(|dleq| dleq.r.to_secret_bytes().to_vec()),
805806
)
806-
.execute(&*conn)
807+
.execute(&tx)
807808
.await?;
808809
}
809810

@@ -813,10 +814,12 @@ where
813814
"ys",
814815
removed_ys.iter().map(|y| y.to_bytes().to_vec()).collect(),
815816
)
816-
.execute(&*conn)
817+
.execute(&tx)
817818
.await?;
818819
}
819820

821+
tx.commit().await?;
822+
820823
Ok(())
821824
}
822825

@@ -906,6 +909,7 @@ where
906909
new_mint_url: MintUrl,
907910
) -> Result<(), database::Error> {
908911
let conn = self.pool.get().map_err(|e| Error::Database(Box::new(e)))?;
912+
let tx = ConnectionWithTransaction::new(conn).await?;
909913
let tables = ["mint_quote", "proof"];
910914

911915
for table in &tables {
@@ -918,10 +922,12 @@ where
918922
))?
919923
.bind("new_mint_url", new_mint_url.to_string())
920924
.bind("old_mint_url", old_mint_url.to_string())
921-
.execute(&*conn)
925+
.execute(&tx)
922926
.await?;
923927
}
924928

929+
tx.commit().await?;
930+
925931
Ok(())
926932
}
927933

@@ -1093,6 +1099,7 @@ where
10931099
keysets: Vec<KeySetInfo>,
10941100
) -> Result<(), database::Error> {
10951101
let conn = self.pool.get().map_err(|e| Error::Database(Box::new(e)))?;
1102+
let tx = ConnectionWithTransaction::new(conn).await?;
10961103

10971104
for keyset in keysets {
10981105
query(
@@ -1113,10 +1120,12 @@ where
11131120
.bind("input_fee_ppk", keyset.input_fee_ppk as i64)
11141121
.bind("final_expiry", keyset.final_expiry.map(|v| v as i64))
11151122
.bind("keyset_u32", u32::from(keyset.id))
1116-
.execute(&*conn)
1123+
.execute(&tx)
11171124
.await?;
11181125
}
11191126

1127+
tx.commit().await?;
1128+
11201129
Ok(())
11211130
}
11221131

0 commit comments

Comments
 (0)