electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 34e236c9b613cd5645d9fe522df42e5c23af76fd
parent 17a893441a88eb1b3bc89fd960edfc28140e266f
Author: ThomasV <thomasv@electrum.org>
Date:   Fri,  6 Mar 2020 09:57:37 +0100

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

Diffstat:
Melectrum/commands.py | 11+++++++----
Melectrum/lnchannel.py | 8++++++--
2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -994,15 +994,18 @@ class Commands: l = list(wallet.lnworker.channels.items()) return [ { - 'local_htlcs': json.loads(encoder.encode(chan.hm.log[LOCAL])), - 'remote_htlcs': json.loads(encoder.encode(chan.hm.log[REMOTE])), - 'channel_id': format_short_channel_id(chan.short_channel_id) if chan.short_channel_id else None, - 'full_channel_id': bh2u(chan.channel_id), + 'short_channel_id': format_short_channel_id(chan.short_channel_id) if chan.short_channel_id else None, + 'channel_id': bh2u(chan.channel_id), 'channel_point': chan.funding_outpoint.to_str(), 'state': chan.get_state().name, + 'peer_state': chan.peer_state.name, 'remote_pubkey': bh2u(chan.node_id), 'local_balance': chan.balance(LOCAL)//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 ] diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py @@ -644,8 +644,12 @@ class Channel(Logger): """ assert type(whose) is HTLCOwner ctn = self.get_next_ctn(ctx_owner) - return self.balance(whose, ctx_owner=ctx_owner, ctn=ctn)\ - - htlcsum(self.hm.htlcs_by_direction(ctx_owner, SENT, ctn).values()) + return self.balance(whose, ctx_owner=ctx_owner, ctn=ctn) + - 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): """