The conversion from markdown to manpages does not display lists and code blocks correctly if they are not preceded by an empty line. Changelog-None
2.3 KiB
lightning-wait -- Command to wait for creations, changes and deletions
SYNOPSIS
wait subsystem indexname nextvalue
DESCRIPTION
The wait RPC command returns once the index given by indexname in subsystem reaches or exceeds nextvalue. All indexes start at 0, when no events have happened (wait with a nextvalue of 0 is a way of getting the current index, though naturally this is racy!).
indexname is one of created
, updated
or deleted
:
created
is incremented by one for every new object.updated
is incremented by one every time an object is changed.deleted
is incremented by one every time an object is deleted.
subsystem is one of:
invoices
: corresponding tolistinvoices
.
RELIABILITY
Indices can go forward by more than one; in particlar, if multiple objects were created and the one deleted, you could see this effect. Similarly, there are some places (e.g. invoice expiration) where we can update multiple entries at once.
Indices only monotoncally increase.
USAGE
The wait RPC is used to track changes in the system. Consider tracking invoices being paid or expiring. The simplest (and inefficient method) would be:
- Call
listinvoices
to get the current state of all invoices, and remember the highestupdated_index
. Say it was 5. - Call
wait invoices updated 6
. - When it returns, call
listinvoices
again to see what changed.
This is obviously inefficient, so there are two optimizations:
- Call
listinvoices
withindex=updated
andstart=6
to only see invoices withupdated_index
greater than or equal to 6. wait
itself may also return some limited subset of fields from the list command (it can't do this in all cases); forinvoices
this islabel
andstatus
, allowing many callers to avoid thelistinvoices
call.
RETURN VALUE
FIXME
On error the returned object will contain code
and message
properties,
with code
being one of the following:
- -32602: If the given parameters are wrong.
AUTHOR
Rusty Russell <rusty@rustcorp.com.au> is mainly responsible.
SEE ALSO
lightning-listinvoice(7)
RESOURCES
Main web site: https://github.com/ElementsProject/lightning