Skip to content

Commit

Permalink
Fix melt change amount
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcaseria authored and thesimplekid committed Sep 21, 2024
1 parent 11fa39a commit 4ba2b07
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/cdk/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,11 @@ impl Wallet {
return Err(Error::UnknownQuote);
};

let proofs_total = Amount::try_sum(proofs.iter().map(|p| p.amount))?;
if proofs_total < quote_info.amount + quote_info.fee_reserve {
return Err(Error::InsufficientFunds);
}

let ys = proofs
.iter()
.map(|p| p.y())
Expand All @@ -1410,7 +1415,7 @@ impl Wallet {
active_keyset_id,
count,
self.xpriv,
quote_info.fee_reserve,
proofs_total - quote_info.amount,
)?;

let melt_response = self
Expand Down

0 comments on commit 4ba2b07

Please sign in to comment.