Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit

Permalink
Merge pull request #978 from MutinyWallet/verify-inv-amt
Browse files Browse the repository at this point in the history
Verify LSP invoice amount
  • Loading branch information
AnthonyRonning authored Jan 23, 2024
2 parents 6eb9522 + a0cf6f7 commit 24b74a9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mutiny-core/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,8 @@ impl<S: MutinyStorage> Node<S> {
.map(|c| c.inbound_capacity_msat)
.sum();

log_debug!(self.logger, "Current inbound liquidity {inbound_capacity_msat}msats, creating invoice for {}msats", amount_sat * 1000);

let has_inbound_capacity = inbound_capacity_msat > amount_sat * 1_000;

let min_amount_sat = if has_inbound_capacity {
Expand Down Expand Up @@ -1059,7 +1061,14 @@ impl<S: MutinyStorage> Node<S> {

if lsp_invoice.payment_hash() != invoice.payment_hash()
|| lsp_invoice.recover_payee_pub_key() != client.get_lsp_pubkey()
|| lsp_invoice.amount_milli_satoshis() != Some(amount_sat * 1_000)
{
log_error!(
self.logger,
"Received unexpected invoice from LSP: {:?} != {}",
lsp_invoice.amount_milli_satoshis(),
amount_sat * 1_000
);
return Err(MutinyError::InvoiceCreationFailed);
}

Expand Down

0 comments on commit 24b74a9

Please sign in to comment.