Skip to content

Commit

Permalink
fix sat and msat conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr committed Oct 16, 2024
1 parent 2f11875 commit 4e78e49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions mutiny-core/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,7 @@ impl<S: MutinyStorage> Node<S> {
.into_iter()
.map(|b| b.claimable_amount_satoshis())
.sum::<u64>()
* 1000
< send_msats
{
// Channels exist but not enough capacity
Expand Down Expand Up @@ -1669,7 +1670,8 @@ impl<S: MutinyStorage> Node<S> {
.get_claimable_balances(&[])
.into_iter()
.map(|b| b.claimable_amount_satoshis())
.sum();
.sum::<u64>()
* 1000;
log_debug!(
self.logger,
"current channel details: {:?}",
Expand Down Expand Up @@ -1821,6 +1823,7 @@ impl<S: MutinyStorage> Node<S> {
.into_iter()
.map(|b| b.claimable_amount_satoshis())
.sum::<u64>()
* 1000
< amt_msats
{
// Channels exist but not enough capacity
Expand Down Expand Up @@ -1921,7 +1924,8 @@ impl<S: MutinyStorage> Node<S> {
.get_claimable_balances(&[])
.into_iter()
.map(|b| b.claimable_amount_satoshis())
.sum();
.sum::<u64>()
* 1000;
Err(map_sending_failure(
error,
amt_msats,
Expand Down
4 changes: 2 additions & 2 deletions mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ impl<S: MutinyStorage> NodeManager<S> {
};

let nodes = self.nodes.read().await;
let lightning_msats: u64 = nodes
let lightning_sats: u64 = nodes
.iter()
.flat_map(|(_, n)| {
n.chain_monitor
Expand Down Expand Up @@ -999,7 +999,7 @@ impl<S: MutinyStorage> NodeManager<S> {
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,
})
}
Expand Down

0 comments on commit 4e78e49

Please sign in to comment.