diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c62fc5f1..9b17287f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - JSON API: `pay` and `decodepay` accept and ignore `lightning:` prefixes. +- pylightning: Allow either keyword arguments or positional arguments. ### Deprecated diff --git a/contrib/pylightning/lightning/lightning.py b/contrib/pylightning/lightning/lightning.py index 9d1686c3d..61cd88996 100644 --- a/contrib/pylightning/lightning/lightning.py +++ b/contrib/pylightning/lightning/lightning.py @@ -48,8 +48,13 @@ class UnixDomainSocketRpc(object): """ name = name.replace('_', '-') - def wrapper(**kwargs): - return self.call(name, payload=kwargs) + def wrapper(*args, **kwargs): + if len(args) != 0 and len(kwargs) != 0: + raise RpcError("Cannot mix positional and non-positional arguments") + elif len(args) != 0: + return self.call(name, payload=args) + else: + return self.call(name, payload=kwargs) return wrapper def call(self, method, payload=None): @@ -58,7 +63,8 @@ class UnixDomainSocketRpc(object): if payload is None: payload = {} # Filter out arguments that are None - payload = {k: v for k, v in payload.items() if v is not None} + if isinstance(payload, dict): + payload = {k: v for k, v in payload.items() if v is not None} # FIXME: we open a new socket for every readobj call... sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)