|
@@ -26,6 +26,7 @@ use cdk_common::mint::{
|
|
|
};
|
|
};
|
|
|
use cdk_common::nut00::ProofsMethods;
|
|
use cdk_common::nut00::ProofsMethods;
|
|
|
use cdk_common::payment::PaymentIdentifier;
|
|
use cdk_common::payment::PaymentIdentifier;
|
|
|
|
|
+use cdk_common::quote_id::QuoteId;
|
|
|
use cdk_common::secret::Secret;
|
|
use cdk_common::secret::Secret;
|
|
|
use cdk_common::state::check_state_transition;
|
|
use cdk_common::state::check_state_transition;
|
|
|
use cdk_common::util::unix_time;
|
|
use cdk_common::util::unix_time;
|
|
@@ -309,7 +310,7 @@ where
|
|
|
#[inline(always)]
|
|
#[inline(always)]
|
|
|
async fn get_mint_quote_payments<C>(
|
|
async fn get_mint_quote_payments<C>(
|
|
|
conn: &C,
|
|
conn: &C,
|
|
|
- quote_id: &Uuid,
|
|
|
|
|
|
|
+ quote_id: &QuoteId,
|
|
|
) -> Result<Vec<IncomingPayment>, Error>
|
|
) -> Result<Vec<IncomingPayment>, Error>
|
|
|
where
|
|
where
|
|
|
C: DatabaseExecutor + Send + Sync,
|
|
C: DatabaseExecutor + Send + Sync,
|
|
@@ -327,7 +328,13 @@ where
|
|
|
quote_id=:quote_id
|
|
quote_id=:quote_id
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("quote_id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "quote_id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.fetch_all(conn)
|
|
.fetch_all(conn)
|
|
|
.await?
|
|
.await?
|
|
|
.into_iter()
|
|
.into_iter()
|
|
@@ -344,7 +351,7 @@ where
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
#[inline(always)]
|
|
|
-async fn get_mint_quote_issuance<C>(conn: &C, quote_id: &Uuid) -> Result<Vec<Issuance>, Error>
|
|
|
|
|
|
|
+async fn get_mint_quote_issuance<C>(conn: &C, quote_id: &QuoteId) -> Result<Vec<Issuance>, Error>
|
|
|
where
|
|
where
|
|
|
C: DatabaseExecutor + Send + Sync,
|
|
C: DatabaseExecutor + Send + Sync,
|
|
|
{
|
|
{
|
|
@@ -356,7 +363,13 @@ FROM mint_quote_issued
|
|
|
WHERE quote_id=:quote_id
|
|
WHERE quote_id=:quote_id
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("quote_id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "quote_id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.fetch_all(conn)
|
|
.fetch_all(conn)
|
|
|
.await?
|
|
.await?
|
|
|
.into_iter()
|
|
.into_iter()
|
|
@@ -542,7 +555,7 @@ where
|
|
|
#[instrument(skip(self))]
|
|
#[instrument(skip(self))]
|
|
|
async fn increment_mint_quote_amount_paid(
|
|
async fn increment_mint_quote_amount_paid(
|
|
|
&mut self,
|
|
&mut self,
|
|
|
- quote_id: &Uuid,
|
|
|
|
|
|
|
+ quote_id: &QuoteId,
|
|
|
amount_paid: Amount,
|
|
amount_paid: Amount,
|
|
|
payment_id: String,
|
|
payment_id: String,
|
|
|
) -> Result<Amount, Self::Err> {
|
|
) -> Result<Amount, Self::Err> {
|
|
@@ -578,7 +591,13 @@ where
|
|
|
FOR UPDATE
|
|
FOR UPDATE
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("quote_id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "quote_id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.fetch_one(&self.inner)
|
|
.fetch_one(&self.inner)
|
|
|
.await
|
|
.await
|
|
|
.inspect_err(|err| {
|
|
.inspect_err(|err| {
|
|
@@ -613,7 +632,13 @@ where
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
.bind("amount_paid", new_amount_paid.to_i64())
|
|
.bind("amount_paid", new_amount_paid.to_i64())
|
|
|
- .bind("quote_id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "quote_id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.execute(&self.inner)
|
|
.execute(&self.inner)
|
|
|
.await
|
|
.await
|
|
|
.inspect_err(|err| {
|
|
.inspect_err(|err| {
|
|
@@ -628,7 +653,13 @@ where
|
|
|
VALUES (:quote_id, :payment_id, :amount, :timestamp)
|
|
VALUES (:quote_id, :payment_id, :amount, :timestamp)
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("quote_id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "quote_id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.bind("payment_id", payment_id)
|
|
.bind("payment_id", payment_id)
|
|
|
.bind("amount", amount_paid.to_i64())
|
|
.bind("amount", amount_paid.to_i64())
|
|
|
.bind("timestamp", unix_time() as i64)
|
|
.bind("timestamp", unix_time() as i64)
|
|
@@ -645,7 +676,7 @@ where
|
|
|
#[instrument(skip_all)]
|
|
#[instrument(skip_all)]
|
|
|
async fn increment_mint_quote_amount_issued(
|
|
async fn increment_mint_quote_amount_issued(
|
|
|
&mut self,
|
|
&mut self,
|
|
|
- quote_id: &Uuid,
|
|
|
|
|
|
|
+ quote_id: &QuoteId,
|
|
|
amount_issued: Amount,
|
|
amount_issued: Amount,
|
|
|
) -> Result<Amount, Self::Err> {
|
|
) -> Result<Amount, Self::Err> {
|
|
|
// Get current amount_issued from quote
|
|
// Get current amount_issued from quote
|
|
@@ -657,7 +688,13 @@ where
|
|
|
FOR UPDATE
|
|
FOR UPDATE
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("quote_id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "quote_id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.fetch_one(&self.inner)
|
|
.fetch_one(&self.inner)
|
|
|
.await
|
|
.await
|
|
|
.inspect_err(|err| {
|
|
.inspect_err(|err| {
|
|
@@ -685,7 +722,13 @@ where
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
.bind("amount_issued", new_amount_issued.to_i64())
|
|
.bind("amount_issued", new_amount_issued.to_i64())
|
|
|
- .bind("quote_id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "quote_id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.execute(&self.inner)
|
|
.execute(&self.inner)
|
|
|
.await
|
|
.await
|
|
|
.inspect_err(|err| {
|
|
.inspect_err(|err| {
|
|
@@ -701,7 +744,13 @@ INSERT INTO mint_quote_issued
|
|
|
VALUES (:quote_id, :amount, :timestamp);
|
|
VALUES (:quote_id, :amount, :timestamp);
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("quote_id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "quote_id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.bind("amount", amount_issued.to_i64())
|
|
.bind("amount", amount_issued.to_i64())
|
|
|
.bind("timestamp", current_time as i64)
|
|
.bind("timestamp", current_time as i64)
|
|
|
.execute(&self.inner)
|
|
.execute(&self.inner)
|
|
@@ -741,9 +790,15 @@ VALUES (:quote_id, :amount, :timestamp);
|
|
|
Ok(())
|
|
Ok(())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async fn remove_mint_quote(&mut self, quote_id: &Uuid) -> Result<(), Self::Err> {
|
|
|
|
|
|
|
+ async fn remove_mint_quote(&mut self, quote_id: &QuoteId) -> Result<(), Self::Err> {
|
|
|
query(r#"DELETE FROM mint_quote WHERE id=:id"#)?
|
|
query(r#"DELETE FROM mint_quote WHERE id=:id"#)?
|
|
|
- .bind("id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.execute(&self.inner)
|
|
.execute(&self.inner)
|
|
|
.await?;
|
|
.await?;
|
|
|
Ok(())
|
|
Ok(())
|
|
@@ -800,13 +855,16 @@ VALUES (:quote_id, :amount, :timestamp);
|
|
|
|
|
|
|
|
async fn update_melt_quote_request_lookup_id(
|
|
async fn update_melt_quote_request_lookup_id(
|
|
|
&mut self,
|
|
&mut self,
|
|
|
- quote_id: &Uuid,
|
|
|
|
|
|
|
+ quote_id: &QuoteId,
|
|
|
new_request_lookup_id: &PaymentIdentifier,
|
|
new_request_lookup_id: &PaymentIdentifier,
|
|
|
) -> Result<(), Self::Err> {
|
|
) -> Result<(), Self::Err> {
|
|
|
query(r#"UPDATE melt_quote SET request_lookup_id = :new_req_id, request_lookup_id_kind = :new_kind WHERE id = :id"#)?
|
|
query(r#"UPDATE melt_quote SET request_lookup_id = :new_req_id, request_lookup_id_kind = :new_kind WHERE id = :id"#)?
|
|
|
.bind("new_req_id", new_request_lookup_id.to_string())
|
|
.bind("new_req_id", new_request_lookup_id.to_string())
|
|
|
.bind("new_kind",new_request_lookup_id.kind() )
|
|
.bind("new_kind",new_request_lookup_id.kind() )
|
|
|
- .bind("id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind("id", match quote_id {
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ })
|
|
|
.execute(&self.inner)
|
|
.execute(&self.inner)
|
|
|
.await?;
|
|
.await?;
|
|
|
Ok(())
|
|
Ok(())
|
|
@@ -814,7 +872,7 @@ VALUES (:quote_id, :amount, :timestamp);
|
|
|
|
|
|
|
|
async fn update_melt_quote_state(
|
|
async fn update_melt_quote_state(
|
|
|
&mut self,
|
|
&mut self,
|
|
|
- quote_id: &Uuid,
|
|
|
|
|
|
|
+ quote_id: &QuoteId,
|
|
|
state: MeltQuoteState,
|
|
state: MeltQuoteState,
|
|
|
payment_proof: Option<String>,
|
|
payment_proof: Option<String>,
|
|
|
) -> Result<(MeltQuoteState, mint::MeltQuote), Self::Err> {
|
|
) -> Result<(MeltQuoteState, mint::MeltQuote), Self::Err> {
|
|
@@ -842,7 +900,13 @@ VALUES (:quote_id, :amount, :timestamp);
|
|
|
AND state != :state
|
|
AND state != :state
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.bind("state", state.to_string())
|
|
.bind("state", state.to_string())
|
|
|
.fetch_one(&self.inner)
|
|
.fetch_one(&self.inner)
|
|
|
.await?
|
|
.await?
|
|
@@ -856,13 +920,22 @@ VALUES (:quote_id, :amount, :timestamp);
|
|
|
.bind("state", state.to_string())
|
|
.bind("state", state.to_string())
|
|
|
.bind("paid_time", current_time as i64)
|
|
.bind("paid_time", current_time as i64)
|
|
|
.bind("payment_preimage", payment_proof)
|
|
.bind("payment_preimage", payment_proof)
|
|
|
- .bind("id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind("id", match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ })
|
|
|
.execute(&self.inner)
|
|
.execute(&self.inner)
|
|
|
.await
|
|
.await
|
|
|
} else {
|
|
} else {
|
|
|
query(r#"UPDATE melt_quote SET state = :state WHERE id = :id"#)?
|
|
query(r#"UPDATE melt_quote SET state = :state WHERE id = :id"#)?
|
|
|
.bind("state", state.to_string())
|
|
.bind("state", state.to_string())
|
|
|
- .bind("id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.execute(&self.inner)
|
|
.execute(&self.inner)
|
|
|
.await
|
|
.await
|
|
|
};
|
|
};
|
|
@@ -895,7 +968,7 @@ VALUES (:quote_id, :amount, :timestamp);
|
|
|
Ok(())
|
|
Ok(())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async fn get_mint_quote(&mut self, quote_id: &Uuid) -> Result<Option<MintQuote>, Self::Err> {
|
|
|
|
|
|
|
+ async fn get_mint_quote(&mut self, quote_id: &QuoteId) -> Result<Option<MintQuote>, Self::Err> {
|
|
|
let payments = get_mint_quote_payments(&self.inner, quote_id).await?;
|
|
let payments = get_mint_quote_payments(&self.inner, quote_id).await?;
|
|
|
let issuance = get_mint_quote_issuance(&self.inner, quote_id).await?;
|
|
let issuance = get_mint_quote_issuance(&self.inner, quote_id).await?;
|
|
|
|
|
|
|
@@ -920,7 +993,13 @@ VALUES (:quote_id, :amount, :timestamp);
|
|
|
FOR UPDATE
|
|
FOR UPDATE
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.fetch_one(&self.inner)
|
|
.fetch_one(&self.inner)
|
|
|
.await?
|
|
.await?
|
|
|
.map(|row| sql_row_to_mint_quote(row, payments, issuance))
|
|
.map(|row| sql_row_to_mint_quote(row, payments, issuance))
|
|
@@ -1053,7 +1132,7 @@ where
|
|
|
{
|
|
{
|
|
|
type Err = Error;
|
|
type Err = Error;
|
|
|
|
|
|
|
|
- async fn get_mint_quote(&self, quote_id: &Uuid) -> Result<Option<MintQuote>, Self::Err> {
|
|
|
|
|
|
|
+ async fn get_mint_quote(&self, quote_id: &QuoteId) -> Result<Option<MintQuote>, Self::Err> {
|
|
|
let conn = self.pool.get().map_err(|e| Error::Database(Box::new(e)))?;
|
|
let conn = self.pool.get().map_err(|e| Error::Database(Box::new(e)))?;
|
|
|
|
|
|
|
|
let payments = get_mint_quote_payments(&*conn, quote_id).await?;
|
|
let payments = get_mint_quote_payments(&*conn, quote_id).await?;
|
|
@@ -1078,7 +1157,13 @@ where
|
|
|
mint_quote
|
|
mint_quote
|
|
|
WHERE id = :id"#,
|
|
WHERE id = :id"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.fetch_one(&*conn)
|
|
.fetch_one(&*conn)
|
|
|
.await?
|
|
.await?
|
|
|
.map(|row| sql_row_to_mint_quote(row, payments, issuance))
|
|
.map(|row| sql_row_to_mint_quote(row, payments, issuance))
|
|
@@ -1206,7 +1291,10 @@ where
|
|
|
Ok(mint_quotes)
|
|
Ok(mint_quotes)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async fn get_melt_quote(&self, quote_id: &Uuid) -> Result<Option<mint::MeltQuote>, Self::Err> {
|
|
|
|
|
|
|
+ async fn get_melt_quote(
|
|
|
|
|
+ &self,
|
|
|
|
|
+ quote_id: &QuoteId,
|
|
|
|
|
+ ) -> Result<Option<mint::MeltQuote>, Self::Err> {
|
|
|
let conn = self.pool.get().map_err(|e| Error::Database(Box::new(e)))?;
|
|
let conn = self.pool.get().map_err(|e| Error::Database(Box::new(e)))?;
|
|
|
Ok(query(
|
|
Ok(query(
|
|
|
r#"
|
|
r#"
|
|
@@ -1231,7 +1319,13 @@ where
|
|
|
id=:id
|
|
id=:id
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("id", quote_id.as_hyphenated().to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.fetch_one(&*conn)
|
|
.fetch_one(&*conn)
|
|
|
.await?
|
|
.await?
|
|
|
.map(sql_row_to_melt_quote)
|
|
.map(sql_row_to_melt_quote)
|
|
@@ -1386,7 +1480,7 @@ where
|
|
|
&mut self,
|
|
&mut self,
|
|
|
blinded_messages: &[PublicKey],
|
|
blinded_messages: &[PublicKey],
|
|
|
blind_signatures: &[BlindSignature],
|
|
blind_signatures: &[BlindSignature],
|
|
|
- quote_id: Option<Uuid>,
|
|
|
|
|
|
|
+ quote_id: Option<QuoteId>,
|
|
|
) -> Result<(), Self::Err> {
|
|
) -> Result<(), Self::Err> {
|
|
|
let current_time = unix_time();
|
|
let current_time = unix_time();
|
|
|
|
|
|
|
@@ -1403,7 +1497,10 @@ where
|
|
|
.bind("amount", u64::from(signature.amount) as i64)
|
|
.bind("amount", u64::from(signature.amount) as i64)
|
|
|
.bind("keyset_id", signature.keyset_id.to_string())
|
|
.bind("keyset_id", signature.keyset_id.to_string())
|
|
|
.bind("c", signature.c.to_bytes().to_vec())
|
|
.bind("c", signature.c.to_bytes().to_vec())
|
|
|
- .bind("quote_id", quote_id.map(|q| q.hyphenated().to_string()))
|
|
|
|
|
|
|
+ .bind("quote_id", quote_id.as_ref().map(|q| match q {
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ QuoteId::UUID(u) => u.hyphenated().to_string(),
|
|
|
|
|
+ }))
|
|
|
.bind(
|
|
.bind(
|
|
|
"dleq_e",
|
|
"dleq_e",
|
|
|
signature.dleq.as_ref().map(|dleq| dleq.e.to_secret_hex()),
|
|
signature.dleq.as_ref().map(|dleq| dleq.e.to_secret_hex()),
|
|
@@ -1547,7 +1644,7 @@ where
|
|
|
/// Get [`BlindSignature`]s for quote
|
|
/// Get [`BlindSignature`]s for quote
|
|
|
async fn get_blind_signatures_for_quote(
|
|
async fn get_blind_signatures_for_quote(
|
|
|
&self,
|
|
&self,
|
|
|
- quote_id: &Uuid,
|
|
|
|
|
|
|
+ quote_id: &QuoteId,
|
|
|
) -> Result<Vec<BlindSignature>, Self::Err> {
|
|
) -> Result<Vec<BlindSignature>, Self::Err> {
|
|
|
let conn = self.pool.get().map_err(|e| Error::Database(Box::new(e)))?;
|
|
let conn = self.pool.get().map_err(|e| Error::Database(Box::new(e)))?;
|
|
|
Ok(query(
|
|
Ok(query(
|
|
@@ -1564,7 +1661,13 @@ where
|
|
|
quote_id=:quote_id
|
|
quote_id=:quote_id
|
|
|
"#,
|
|
"#,
|
|
|
)?
|
|
)?
|
|
|
- .bind("quote_id", quote_id.to_string())
|
|
|
|
|
|
|
+ .bind(
|
|
|
|
|
+ "quote_id",
|
|
|
|
|
+ match quote_id {
|
|
|
|
|
+ QuoteId::BASE64(s) => s.to_string(),
|
|
|
|
|
+ QuoteId::UUID(u) => u.as_hyphenated().to_string(),
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
.fetch_all(&*conn)
|
|
.fetch_all(&*conn)
|
|
|
.await?
|
|
.await?
|
|
|
.into_iter()
|
|
.into_iter()
|
|
@@ -1658,7 +1761,7 @@ fn sql_row_to_mint_quote(
|
|
|
let payment_method = column_as_string!(payment_method, PaymentMethod::from_str);
|
|
let payment_method = column_as_string!(payment_method, PaymentMethod::from_str);
|
|
|
|
|
|
|
|
Ok(MintQuote::new(
|
|
Ok(MintQuote::new(
|
|
|
- Some(Uuid::parse_str(&id).map_err(|_| Error::InvalidUuid(id))?),
|
|
|
|
|
|
|
+ Some(QuoteId::from_str(&id)?),
|
|
|
request_str,
|
|
request_str,
|
|
|
column_as_string!(unit, CurrencyUnit::from_str),
|
|
column_as_string!(unit, CurrencyUnit::from_str),
|
|
|
amount.map(Amount::from),
|
|
amount.map(Amount::from),
|
|
@@ -1745,7 +1848,7 @@ fn sql_row_to_melt_quote(row: Vec<Column>) -> Result<mint::MeltQuote, Error> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
Ok(MeltQuote {
|
|
Ok(MeltQuote {
|
|
|
- id: Uuid::parse_str(&id).map_err(|_| Error::InvalidUuid(id))?,
|
|
|
|
|
|
|
+ id: QuoteId::from_str(&id)?,
|
|
|
unit: CurrencyUnit::from_str(&unit)?,
|
|
unit: CurrencyUnit::from_str(&unit)?,
|
|
|
amount: Amount::from(amount),
|
|
amount: Amount::from(amount),
|
|
|
request,
|
|
request,
|