From: Matt Corallo Date: Thu, 11 Nov 2021 17:49:45 +0000 (+0000) Subject: Include total local balance across all channels in `nodeinfo` X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=1db442581294d073de85c4e9f21393f87bb0515c;p=ldk-sample Include total local balance across all channels in `nodeinfo` --- diff --git a/src/cli.rs b/src/cli.rs index 197c0ec..0bea870 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -388,8 +388,14 @@ fn help() { fn node_info(channel_manager: Arc, peer_manager: Arc) { println!("\t{{"); println!("\t\t node_pubkey: {}", channel_manager.get_our_node_id()); - println!("\t\t num_channels: {}", channel_manager.list_channels().len()); - println!("\t\t num_usable_channels: {}", channel_manager.list_usable_channels().len()); + let chans = channel_manager.list_channels(); + println!("\t\t num_channels: {}", chans.len()); + println!("\t\t num_usable_channels: {}", chans.iter().filter(|c| c.is_usable).count()); + let local_balance_msat = chans + .iter() + .map(|c| c.unspendable_punishment_reserve.unwrap_or(0) * 1000 + c.outbound_capacity_msat) + .sum::(); + println!("\t\t local_balance_msat: {}", local_balance_msat); println!("\t\t num_peers: {}", peer_manager.get_peer_node_ids().len()); println!("\t}},"); }