mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-08 15:44:19 +01:00
pytest: Add a helper to determine a node's peer channel state
This commit is contained in:
committed by
Rusty Russell
parent
88217369c2
commit
2c77fc5bf2
@@ -507,6 +507,28 @@ class LightningNode(object):
|
||||
return group.group(1)
|
||||
raise ValueError("No daemon {} found".format(subd))
|
||||
|
||||
def channel_state(self, other):
|
||||
"""Return the state of the channel to the other node.
|
||||
|
||||
Returns None if there is no such peer, or a channel hasn't been funded
|
||||
yet.
|
||||
|
||||
"""
|
||||
peers = self.rpc.listpeers(other.info['id'])['peers']
|
||||
if not peers or 'channels' not in peers[0]:
|
||||
return None
|
||||
channel = peers[0]['channels'][0]
|
||||
return channel['state']
|
||||
|
||||
def get_channel_scid(self, other):
|
||||
"""Get the short_channel_id for the channel to the other node.
|
||||
"""
|
||||
peers = self.rpc.listpeers(other.info['id'])['peers']
|
||||
if not peers or 'channels' not in peers[0]:
|
||||
return None
|
||||
channel = peers[0]['channels'][0]
|
||||
return channel['short_channel_id']
|
||||
|
||||
def is_channel_active(self, chanid):
|
||||
channels = self.rpc.listchannels()['channels']
|
||||
active = [(c['short_channel_id'], c['flags']) for c in channels if c['active']]
|
||||
|
||||
Reference in New Issue
Block a user