From 68f3e3fba9b457e2d25063fe3efdde5655cf337f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 12 Dec 2022 14:31:54 +1030 Subject: [PATCH] pyln: add datastore routines. Without explicit definitions, we don't get proper names args and help messages. Signed-off-by: Rusty Russell --- contrib/pyln-client/pyln/client/lightning.py | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/contrib/pyln-client/pyln/client/lightning.py b/contrib/pyln-client/pyln/client/lightning.py index 28b2f0da2..a81c930b5 100644 --- a/contrib/pyln-client/pyln/client/lightning.py +++ b/contrib/pyln-client/pyln/client/lightning.py @@ -603,6 +603,26 @@ class LightningRpc(UnixDomainSocketRpc): } return self.call("connect", payload) + def datastore(self, key, string=None, hex=None, mode=None, generation=None): + """ + Add/replace an entry in the datastore; either string or hex. + {key} can be a single string, or a sequence of strings. + {mode} defaults to 'must-create', but other options are possible: + - 'must-replace': fail it it doesn't already exist. + - 'create-or-replace': don't fail. + - 'must-append': must exist, and append to existing. + - 'create-or-append': set, or append to existing. + {generation} only succeeds if the current entry has this generation count (mode must be 'must-replace' or 'must-append'). + """ + payload = { + "key": key, + "string": string, + "hex": hex, + "mode": mode, + "generation": generation, + } + return self.call("datastore", payload) + def decodepay(self, bolt11, description=None): """ Decode {bolt11}, using {description} if necessary. @@ -613,6 +633,18 @@ class LightningRpc(UnixDomainSocketRpc): } return self.call("decodepay", payload) + def deldatastore(self, key, generation=None): + """ + Remove an existing entry from the datastore. + {key} can be a single string, or a sequence of strings. + {generation} means delete only succeeds if the current entry has this generation count. + """ + payload = { + "key": key, + "generation": generation, + } + return self.call("deldatastore", payload) + def delexpiredinvoice(self, maxexpirytime=None): """ Delete all invoices that have expired on or before the given {maxexpirytime}. @@ -943,6 +975,16 @@ class LightningRpc(UnixDomainSocketRpc): } return self.call("listconfigs", payload) + def listdatastore(self, key=None): + """ + Show entries in the heirarchical datastore, or just one from one {key}root. + {key} can be a single string, or a sequence of strings. + """ + payload = { + "key": key, + } + return self.call("listdatastore", payload) + def listforwards(self, status=None, in_channel=None, out_channel=None): """List all forwarded payments and their information matching forward {status}, {in_channel} and {out_channel}.