Skip to content

Commit

Permalink
fix: store payment_request in db
Browse files Browse the repository at this point in the history
  • Loading branch information
ngutech21 committed Dec 7, 2023
1 parent 320b199 commit 30f39bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions moksha-mint/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub enum Quote {
quote_id: Uuid,
amount: u64,
fee_reserve: u64,
payment_request: String,
expiry: u64,
},
}
12 changes: 8 additions & 4 deletions moksha-mint/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ async fn post_melt_quote_bolt11(
amount: amount_sat,
fee_reserve,
expiry: invoice.expiry_time().as_secs(), // FIXME check if this is correct
payment_request: melt_request.request.clone(),
};
mint.db.add_quote(key.to_string(), quote)?;

Expand All @@ -403,14 +404,16 @@ async fn post_melt_bolt11(
let quote = mint.db.get_quote(melt_request.quote.clone())?;

match quote {
Quote::Bolt11Melt { .. } => {
let (paid, preimage, change) = mint
.melt(melt_request.quote, &melt_request.inputs, &[], &mint.keyset)
Quote::Bolt11Melt {
payment_request, ..
} => {
let (paid, payment_preimage, change) = mint
.melt(payment_request, &melt_request.inputs, &[], &mint.keyset)
.await?;

Ok(Json(PostMeltBolt11Response {
paid,
payment_preimage: preimage,
payment_preimage,
change,
}))
}
Expand Down Expand Up @@ -462,6 +465,7 @@ async fn get_melt_quote_bolt11(
amount,
fee_reserve,
expiry,
..
} => Ok(Json(PostMeltQuoteBolt11Response {
amount,
fee_reserve,
Expand Down

0 comments on commit 30f39bd

Please sign in to comment.