feat: signature on mint witness

This commit is contained in:
thesimplekid
2024-11-08 19:58:07 +00:00
parent 4c70dcb15a
commit 003a8f1b47
22 changed files with 1013 additions and 301 deletions

View File

@@ -10,7 +10,7 @@ use cdk::cdk_database::{self, WalletDatabase};
use cdk::mint_url::MintUrl;
use cdk::nuts::{
CurrencyUnit, Id, KeySetInfo, Keys, MeltQuoteState, MintInfo, MintQuoteState, Proof, PublicKey,
SpendingConditions, State,
SecretKey, SpendingConditions, State,
};
use cdk::secret::Secret;
use cdk::types::ProofInfo;
@@ -347,8 +347,8 @@ WHERE id=?
sqlx::query(
r#"
INSERT OR REPLACE INTO mint_quote
(id, mint_url, amount, unit, request, state, expiry)
VALUES (?, ?, ?, ?, ?, ?, ?);
(id, mint_url, amount, unit, request, state, expiry, secret_key)
VALUES (?, ?, ?, ?, ?, ?, ?, ?);
"#,
)
.bind(quote.id.to_string())
@@ -358,6 +358,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?);
.bind(quote.request)
.bind(quote.state.to_string())
.bind(quote.expiry as i64)
.bind(quote.secret_key.map(|p| p.to_string()))
.execute(&self.pool)
.await
.map_err(Error::from)?;
@@ -832,9 +833,14 @@ fn sqlite_row_to_mint_quote(row: &SqliteRow) -> Result<MintQuote, Error> {
let row_request: String = row.try_get("request").map_err(Error::from)?;
let row_state: String = row.try_get("state").map_err(Error::from)?;
let row_expiry: i64 = row.try_get("expiry").map_err(Error::from)?;
let row_secret: Option<String> = row.try_get("secret_key").map_err(Error::from)?;
let state = MintQuoteState::from_str(&row_state)?;
let secret_key = row_secret
.map(|key| SecretKey::from_str(&key))
.transpose()?;
Ok(MintQuote {
id: row_id,
mint_url: MintUrl::from_str(&row_mint_url)?,
@@ -843,6 +849,7 @@ fn sqlite_row_to_mint_quote(row: &SqliteRow) -> Result<MintQuote, Error> {
request: row_request,
state,
expiry: row_expiry as u64,
secret_key,
})
}