Skip to content

Commit

Permalink
fix: mint nut04
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Oct 26, 2024
1 parent 0f7bec5 commit b8137c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/cdk-integration-tests/tests/regtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ async fn test_pay_invoice_twice() -> Result<()> {
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_internal_payment() -> Result<()> {
async fn test_regtest_internal_payment() -> Result<()> {
let lnd_client = init_lnd_client().await?;

let seed = Mnemonic::generate(12)?.to_seed_normalized("");
Expand Down
14 changes: 5 additions & 9 deletions crates/cdk/src/mint/mint_nut04.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ impl Mint {
.localstore
.update_mint_quote_state(&mint_request.quote, MintQuoteState::Pending)
.await?;

let quote = self
.localstore
.get_mint_quote(&mint_request.quote)
Expand All @@ -289,14 +290,6 @@ impl Mint {
MintQuoteState::Paid => (),
}

let amount_can_issue = quote.amount_paid - quote.amount_issued;

let messages_amount = mint_request.total_amount().unwrap();

if amount_can_issue < messages_amount {
return Err(Error::IssuedQuote);
}

let blinded_messages: Vec<PublicKey> = mint_request
.outputs
.iter()
Expand Down Expand Up @@ -357,7 +350,10 @@ impl Mint {
state: MintQuoteState::Issued,
expiry: quote.expiry,
amount_paid: quote.amount_paid,
amount_issued: quote.amount_issued + messages_amount,
amount_issued: quote.amount_issued
+ mint_request
.total_amount()
.map_err(|_| Error::AmountOverflow)?,
request_lookup_id: quote.request_lookup_id,
single_use: None,
};
Expand Down

0 comments on commit b8137c3

Please sign in to comment.