Skip to content

Commit

Permalink
Fix potential max_allowed_to_receive_msats underflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dangeross committed Nov 16, 2023
1 parent c4b6da1 commit 26ae6cf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libs/sdk-core/src/greenlight/node_api.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::cmp::{max, min, Reverse};
use std::cmp::{min, Reverse};
use std::pin::Pin;
use std::str::FromStr;
use std::sync::Arc;
Expand Down Expand Up @@ -702,7 +702,8 @@ impl NodeAPI for Greenlight {
Ok(())
})?;

let max_allowed_to_receive_msats = max(MAX_INBOUND_LIQUIDITY_MSAT - channels_balance, 0);
let max_allowed_to_receive_msats =
MAX_INBOUND_LIQUIDITY_MSAT.saturating_sub(channels_balance);
let node_pubkey = hex::encode(node_info.id);

// construct the node state
Expand Down

0 comments on commit 26ae6cf

Please sign in to comment.