From 218a9efaec094d8c4b2f06559d795a744e046b0f Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Tue, 8 Sep 2020 18:15:16 +0200 Subject: [PATCH] pyln-testing: add get_channel_id helper --- contrib/pyln-testing/pyln/testing/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/pyln-testing/pyln/testing/utils.py b/contrib/pyln-testing/pyln/testing/utils.py index 0b08e2d13..48b0b8a6d 100644 --- a/contrib/pyln-testing/pyln/testing/utils.py +++ b/contrib/pyln-testing/pyln/testing/utils.py @@ -800,6 +800,15 @@ class LightningNode(object): channel = peers[0]['channels'][0] return channel['short_channel_id'] + def get_channel_id(self, other): + """Get the 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['channel_id'] + def is_channel_active(self, chanid): channels = self.rpc.listchannels(chanid)['channels'] active = [(c['short_channel_id'], c['channel_flags']) for c in channels if c['active']]