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

Verify LSP invoice amount #978

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading