mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 07:23:25 +00:00
move list_channels to commands.py
This commit is contained in:
parent
238fb46d87
commit
9451ca9568
2 changed files with 18 additions and 19 deletions
|
@ -956,7 +956,23 @@ class Commands:
|
|||
|
||||
@command('w')
|
||||
async def list_channels(self, wallet: Abstract_Wallet = None):
|
||||
return list(wallet.lnworker.list_channels())
|
||||
# we output the funding_outpoint instead of the channel_id because lnd uses channel_point (funding outpoint) to identify channels
|
||||
from .lnutil import LOCAL, REMOTE, format_short_channel_id
|
||||
encoder = util.MyEncoder()
|
||||
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),
|
||||
'channel_point': chan.funding_outpoint.to_str(),
|
||||
'state': chan.get_state().name,
|
||||
'remote_pubkey': bh2u(chan.node_id),
|
||||
'local_balance': chan.balance(LOCAL)//1000,
|
||||
'remote_balance': chan.balance(REMOTE)//1000,
|
||||
} for channel_id, chan in l
|
||||
]
|
||||
|
||||
@command('wn')
|
||||
async def dumpgraph(self, wallet: Abstract_Wallet = None):
|
||||
|
|
|
@ -51,7 +51,7 @@ from .lnutil import (Outpoint, LNPeerAddr,
|
|||
generate_keypair, LnKeyFamily, LOCAL, REMOTE,
|
||||
UnknownPaymentHash, MIN_FINAL_CLTV_EXPIRY_FOR_INVOICE,
|
||||
NUM_MAX_EDGES_IN_PAYMENT_PATH, SENT, RECEIVED, HTLCOwner,
|
||||
UpdateAddHtlc, Direction, LnLocalFeatures, format_short_channel_id,
|
||||
UpdateAddHtlc, Direction, LnLocalFeatures,
|
||||
ShortChannelID, PaymentAttemptLog, PaymentAttemptFailureDetails)
|
||||
from .lnutil import ln_dummy_address
|
||||
from .transaction import PartialTxOutput, PartialTransaction, PartialTxInput
|
||||
|
@ -1171,23 +1171,6 @@ class LNWallet(LNWorker):
|
|||
with self.lock:
|
||||
return Decimal(max(chan.available_to_spend(REMOTE) if chan.is_open() else 0 for chan in self.channels.values()))/1000
|
||||
|
||||
def list_channels(self):
|
||||
encoder = MyEncoder()
|
||||
with self.lock:
|
||||
# we output the funding_outpoint instead of the channel_id because lnd uses channel_point (funding outpoint) to identify channels
|
||||
for channel_id, chan in self.channels.items():
|
||||
yield {
|
||||
'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),
|
||||
'channel_point': chan.funding_outpoint.to_str(),
|
||||
'state': chan.get_state().name,
|
||||
'remote_pubkey': bh2u(chan.node_id),
|
||||
'local_balance': chan.balance(LOCAL)//1000,
|
||||
'remote_balance': chan.balance(REMOTE)//1000,
|
||||
}
|
||||
|
||||
async def close_channel(self, chan_id):
|
||||
chan = self.channels[chan_id]
|
||||
peer = self.peers[chan.node_id]
|
||||
|
|
Loading…
Add table
Reference in a new issue