Browse Source

CLI: show channel reserves and unsettled balances. fixes #5817

hard-fail-on-bad-server-string
ThomasV 5 years ago
parent
commit
34e236c9b6
  1. 11
      electrum/commands.py
  2. 8
      electrum/lnchannel.py

11
electrum/commands.py

@ -994,15 +994,18 @@ class Commands:
l = list(wallet.lnworker.channels.items()) l = list(wallet.lnworker.channels.items())
return [ return [
{ {
'local_htlcs': json.loads(encoder.encode(chan.hm.log[LOCAL])), 'short_channel_id': format_short_channel_id(chan.short_channel_id) if chan.short_channel_id else None,
'remote_htlcs': json.loads(encoder.encode(chan.hm.log[REMOTE])), 'channel_id': bh2u(chan.channel_id),
'channel_id': format_short_channel_id(chan.short_channel_id) if chan.short_channel_id else None,
'full_channel_id': bh2u(chan.channel_id),
'channel_point': chan.funding_outpoint.to_str(), 'channel_point': chan.funding_outpoint.to_str(),
'state': chan.get_state().name, 'state': chan.get_state().name,
'peer_state': chan.peer_state.name,
'remote_pubkey': bh2u(chan.node_id), 'remote_pubkey': bh2u(chan.node_id),
'local_balance': chan.balance(LOCAL)//1000, 'local_balance': chan.balance(LOCAL)//1000,
'remote_balance': chan.balance(REMOTE)//1000, 'remote_balance': chan.balance(REMOTE)//1000,
'local_reserve': chan.config[LOCAL].reserve_sat,
'remote_reserve': chan.config[REMOTE].reserve_sat,
'local_unsettled_sent': chan.unsettled_sent_balance(LOCAL),
'remote_unsettled_sent': chan.unsettled_sent_balance(REMOTE),
} for channel_id, chan in l } for channel_id, chan in l
] ]

8
electrum/lnchannel.py

@ -644,8 +644,12 @@ class Channel(Logger):
""" """
assert type(whose) is HTLCOwner assert type(whose) is HTLCOwner
ctn = self.get_next_ctn(ctx_owner) ctn = self.get_next_ctn(ctx_owner)
return self.balance(whose, ctx_owner=ctx_owner, ctn=ctn)\ return self.balance(whose, ctx_owner=ctx_owner, ctn=ctn)
- htlcsum(self.hm.htlcs_by_direction(ctx_owner, SENT, ctn).values()) - self.unsettled_sent_balance(ctx_owner)
def unsettled_sent_balance(self, subject: HTLCOwner = LOCAL):
ctn = self.get_next_ctn(subject)
return htlcsum(self.hm.htlcs_by_direction(subject, SENT, ctn).values())
def available_to_spend(self, subject): def available_to_spend(self, subject):
""" """

Loading…
Cancel
Save