add port argument in connect, add getpeer method for test convenience

This commit is contained in:
gdassori 2018-01-27 20:49:13 +01:00 committed by Christian Decker
parent 67dbe71dfa
commit bdcf38442b
1 changed files with 13 additions and 3 deletions

View File

@ -214,12 +214,13 @@ class LightningRpc(UnixDomainSocketRpc):
"""
return self._call("listpayments")
def connect(self, peer_id, host=None):
def connect(self, peer_id, host=None, port=None):
"""
Connect to {peer_id} at {host} (which can end in ':port' if not default)
Connect to {peer_id} at {host} and {port}
"""
args = [peer_id]
host is not None and args.append(host)
host and args.append(host)
port and args.append(port)
return self._call("connect", args=args)
def listpeers(self, peer_id=None, logs=None):
@ -230,6 +231,15 @@ class LightningRpc(UnixDomainSocketRpc):
logs is not None and args.append(logs)
return self._call("listpeers", args=args)
def getpeer(self, peer_id, logs=None):
"""
Show peer with {peer_id}, if {level} is set, include {log}s
"""
args = [peer_id]
logs is not None and args.append(logs)
res = self.listpeers(peer_id, logs)
return res.get('peers') and res['peers'][0]
def fundchannel(self, peer_id, satoshi):
"""
Fund channel with {id} using {satoshi} satoshis"