Skip to content

Commit

Permalink
chore: update v1 api
Browse files Browse the repository at this point in the history
  • Loading branch information
ngutech21 committed Dec 4, 2023
1 parent 2b438cd commit 5fcadcd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions moksha-core/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ pub struct PostMintQuoteBolt11Request {
pub struct PostMintQuoteBolt11Response {
pub quote: String,
pub request: String,
pub paid: bool,
pub expiry: u64,
}

#[derive(Deserialize, Serialize, Debug, Clone)]
Expand Down Expand Up @@ -166,8 +168,7 @@ pub struct PostMeltBolt11Request {
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct PostMeltBolt11Response {
pub paid: bool,
/// payment preimage
pub proof: String,
pub payment_preimage: String,
}

#[cfg(test)]
Expand Down
4 changes: 4 additions & 0 deletions moksha-mint/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,17 @@ async fn post_mint_quote_bolt11(
// FIXME check currency unit
let (pr, _hash) = mint.create_invoice(request.amount).await?;

let invoice = mint.lightning.decode_invoice(pr.clone()).await?;

let quote = Quote::new(pr.clone());
let quote_id = quote.quote_id.to_string();
mint.db.add_quote(quote_id.clone(), quote)?;

Ok(Json(PostMintQuoteBolt11Response {
quote: quote_id,
request: pr,
paid: false,
expiry: invoice.expiry_time().as_secs(), // FIXME check if this is correct
}))
}

Expand Down

0 comments on commit 5fcadcd

Please sign in to comment.