lightningd/invoice.c: Add timeout parameter to waitanyinvoice.

Fixes: #3192

Changelog-Added: `waitanyinvoice` now supports a `timeout` parameter, which when set will cause the command to fail when the timeout is reached; can set this to 0 to fail immediately if no new invoice has been paid yet.
This commit is contained in:
ZmnSCPxj jxPCSnmZ
2020-01-28 09:30:00 +08:00
committed by Christian Decker
parent e379528254
commit 67590fc6be
5 changed files with 61 additions and 5 deletions

View File

@@ -988,14 +988,18 @@ class LightningRpc(UnixDomainSocketRpc):
"""
return self.call("stop")
def waitanyinvoice(self, lastpay_index=None):
def waitanyinvoice(self, lastpay_index=None, timeout=None, **kwargs):
"""
Wait for the next invoice to be paid, after {lastpay_index}
(if supplied)
Fail after {timeout} seconds has passed without an invoice
being paid.
"""
payload = {
"lastpay_index": lastpay_index
"lastpay_index": lastpay_index,
"timeout": timeout
}
payload.update({k: v for k, v in kwargs.items()})
return self.call("waitanyinvoice", payload)
def waitblockheight(self, blockheight, timeout=None):