feat: store melt_quote_id for proof

This commit is contained in:
thesimplekid
2024-09-19 13:19:11 +02:00
parent 3413c24936
commit 117443d126
8 changed files with 72 additions and 23 deletions

View File

@@ -746,14 +746,14 @@ FROM keyset;
}
}
async fn add_proofs(&self, proofs: Proofs) -> Result<(), Self::Err> {
async fn add_proofs(&self, proofs: Proofs, quote_id: Option<String>) -> Result<(), Self::Err> {
let mut transaction = self.pool.begin().await.map_err(Error::from)?;
for proof in proofs {
if let Err(err) = sqlx::query(
r#"
INSERT INTO proof
(y, amount, keyset_id, secret, c, witness, state)
VALUES (?, ?, ?, ?, ?, ?, ?);
(y, amount, keyset_id, secret, c, witness, state, quote_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?);
"#,
)
.bind(proof.y()?.to_bytes().to_vec())
@@ -763,6 +763,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?);
.bind(proof.c.to_bytes().to_vec())
.bind(proof.witness.map(|w| serde_json::to_string(&w).unwrap()))
.bind("UNSPENT")
.bind(quote_id.clone())
.execute(&mut transaction)
.await
.map_err(Error::from)
@@ -774,6 +775,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?);
Ok(())
}
async fn get_proofs_by_ys(&self, ys: &[PublicKey]) -> Result<Vec<Option<Proof>>, Self::Err> {
let mut transaction = self.pool.begin().await.map_err(Error::from)?;