mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-19 13:44:55 +01:00
feat: store melt_quote_id for proof
This commit is contained in:
@@ -0,0 +1 @@
|
||||
ALTER TABLE proof ADD COLUMN quote_id TEXT;
|
||||
@@ -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)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user