json-rpc: Give waitblockheight an error code for timeouts

We need to differentiate timeouts from other results, so make it recognizable.
This commit is contained in:
Christian Decker 2021-01-06 16:22:34 +01:00
parent 8e908ff652
commit 0d1b45dfcc
4 changed files with 7 additions and 4 deletions

View File

@ -84,4 +84,7 @@ static const errcode_t OFFER_EXPIRED = 1002;
static const errcode_t OFFER_ROUTE_NOT_FOUND = 1003;
static const errcode_t OFFER_BAD_INVREQ_REPLY = 1004;
/* Errors from wait* commands */
static const errcode_t WAIT_TIMEOUT = 2000;
#endif /* LIGHTNING_COMMON_JSONRPC_ERRORS_H */

View File

@ -23,7 +23,7 @@ the block height at the time the command returns\.
If \fItimeout\fR seconds is reached without the specified blockheight
being reached, this command will fail\.
being reached, this command will fail with a code of \fB2000\fR\.
.SH AUTHOR
@ -33,4 +33,4 @@ ZmnSCPxj \fI<ZmnSCPxj@protonmail.com\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:5714e6333e5ba57cc00de425e6dc411f2c30812bbc8d95d01d50c460ee002e29
\" SHA256STAMP:ac3320b4b9e679d8c407e42c9663540e2fc2aca75143d192f58ce255ca9b3700

View File

@ -24,7 +24,7 @@ an object with the single field *blockheight* is returned, which is
the block height at the time the command returns.
If *timeout* seconds is reached without the specified blockheight
being reached, this command will fail.
being reached, this command will fail with a code of `2000`.
AUTHOR
------

View File

@ -1850,7 +1850,7 @@ timeout_waitblockheight_waiter(struct waitblockheight_waiter *w)
list_del(&w->list);
w->removed = true;
tal_steal(tmpctx, w);
was_pending(command_fail(w->cmd, LIGHTNINGD,
was_pending(command_fail(w->cmd, WAIT_TIMEOUT,
"Timed out."));
}
/* Called by lightningd at each new block. */