From 4e78e49d6ddccc95d176b398bf50eb317446dc1a Mon Sep 17 00:00:00 2001 From: jjy Date: Wed, 16 Oct 2024 12:01:24 +0800 Subject: [PATCH] fix sat and msat conversion --- mutiny-core/src/node.rs | 8 ++++++-- mutiny-core/src/nodemanager.rs | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mutiny-core/src/node.rs b/mutiny-core/src/node.rs index 73c7bfbc7..989c4a727 100644 --- a/mutiny-core/src/node.rs +++ b/mutiny-core/src/node.rs @@ -1596,6 +1596,7 @@ impl Node { .into_iter() .map(|b| b.claimable_amount_satoshis()) .sum::() + * 1000 < send_msats { // Channels exist but not enough capacity @@ -1669,7 +1670,8 @@ impl Node { .get_claimable_balances(&[]) .into_iter() .map(|b| b.claimable_amount_satoshis()) - .sum(); + .sum::() + * 1000; log_debug!( self.logger, "current channel details: {:?}", @@ -1821,6 +1823,7 @@ impl Node { .into_iter() .map(|b| b.claimable_amount_satoshis()) .sum::() + * 1000 < amt_msats { // Channels exist but not enough capacity @@ -1921,7 +1924,8 @@ impl Node { .get_claimable_balances(&[]) .into_iter() .map(|b| b.claimable_amount_satoshis()) - .sum(); + .sum::() + * 1000; Err(map_sending_failure( error, amt_msats, diff --git a/mutiny-core/src/nodemanager.rs b/mutiny-core/src/nodemanager.rs index 4fafb141a..6f5adf27c 100644 --- a/mutiny-core/src/nodemanager.rs +++ b/mutiny-core/src/nodemanager.rs @@ -964,7 +964,7 @@ impl NodeManager { }; let nodes = self.nodes.read().await; - let lightning_msats: u64 = nodes + let lightning_sats: u64 = nodes .iter() .flat_map(|(_, n)| { n.chain_monitor @@ -999,7 +999,7 @@ impl NodeManager { Ok(NodeBalance { confirmed: (onchain.confirmed + onchain.trusted_pending).to_sat(), unconfirmed: (onchain.untrusted_pending + onchain.immature).to_sat(), - lightning: lightning_msats / 1_000, + lightning: lightning_sats, force_close, }) }