sendinvoice: don't allow separate invoice and command timeouts.

It was too confusing, and can be added later if desired.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-01-08 05:23:47 +10:30
parent fdc1f75745
commit 030a19a8af
3 changed files with 11 additions and 30 deletions

View File

@ -6,7 +6,7 @@ lightning-sendinvoice - Command for send an invoice for an offer
\fIEXPERIMENTAL_FEATURES only\fR
\fBsendinvoice\fR \fIoffer\fR [\fIlabel\fR] [\fImsatoshi\fR] [\fItimeout\fR] [\fIinvoice_timeout\fR] [\fIquantity\fR]
\fBsendinvoice\fR \fIoffer\fR [\fIlabel\fR] [\fImsatoshi\fR] [\fItimeout\fR] [\fIquantity\fR]
.SH DESCRIPTION
@ -28,12 +28,8 @@ amount contained in the offer (multiplied by \fIquantity\fR if any)\.
\fItimeout\fR is how many seconds to wait for the offering node to pay the
invoice or return an error, default 90 seconds\.
\fIinvoice_timeout\fR can be set to greater than \fItimeout\fR, to give the
offering node longer to pay; in this case \fIsendinvoice\fR will time out
but the invoice will still be valid, and the caller should monitor it\.
invoice or return an error, default 90 seconds\. This will also be the
timeout on the invoice that is sent\.
\fIquantity\fR is optional: it is required if the \fIoffer\fR specifies
@ -71,4 +67,4 @@ Rusty Russell \fI<rusty@rustcorp.com.au\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:403f142342802de658c6721a5caed11a9753fb1b437feceb19bcae30c79a4615
\" SHA256STAMP:cfb235f88de77288c3a757f9d7252591cb61adb773d7a88062464011a6586753

View File

@ -6,7 +6,7 @@ SYNOPSIS
*EXPERIMENTAL_FEATURES only*
**sendinvoice** *offer* \[*label*\] \[*msatoshi*\] \[*timeout*\] \[*invoice_timeout*\] \[*quantity*\]
**sendinvoice** *offer* \[*label*\] \[*msatoshi*\] \[*timeout*\] \[*quantity*\]
DESCRIPTION
-----------
@ -25,11 +25,8 @@ you may set it (e.g. to provide a tip), and if not it defaults to the
amount contained in the offer (multiplied by *quantity* if any).
*timeout* is how many seconds to wait for the offering node to pay the
invoice or return an error, default 90 seconds.
*invoice_timeout* can be set to greater than *timeout*, to give the
offering node longer to pay; in this case *sendinvoice* will time out
but the invoice will still be valid, and the caller should monitor it.
invoice or return an error, default 90 seconds. This will also be the
timeout on the invoice that is sent.
*quantity* is optional: it is required if the *offer* specifies
*quantity_min* or *quantity_max*, otherwise it is not allowed.

View File

@ -643,9 +643,7 @@ static void timeout_sent_inv(struct sent *sent)
json_out_addstr(details, "invstring", invoice_encode(tmpctx, sent->inv));
/* This will free sent! */
discard_result(command_done_err(sent->cmd, OFFER_TIMEOUT,
"Timeout waiting for response"
" (but use waitinvoice if invoice_timeout"
" was greater)",
"Failed: timeout waiting for response",
details));
}
@ -1148,7 +1146,7 @@ static struct command_result *json_sendinvoice(struct command *cmd,
{
struct amount_msat *msat;
struct out_req *req;
u32 *timeout, *invoice_timeout;
u32 *timeout;
struct sent *sent = tal(cmd, struct sent);
sent->inv = tlv_invoice_new(cmd);
@ -1161,7 +1159,6 @@ static struct command_result *json_sendinvoice(struct command *cmd,
p_req("label", param_label, &sent->inv_label),
p_opt("msatoshi", param_msat, &msat),
p_opt_def("timeout", param_number, &timeout, 90),
p_opt("invoice_timeout", param_number, &invoice_timeout),
p_opt("quantity", param_u64, &sent->inv->quantity),
NULL))
return command_param_failed();
@ -1259,15 +1256,6 @@ static struct command_result *json_sendinvoice(struct command *cmd,
sent->inv->timestamp = tal(sent->inv, u64);
*sent->inv->timestamp = time_now().ts.tv_sec;
/* If they don't specify an invoice_timeout, make it the same as we're
* prepare to wait. */
if (!invoice_timeout)
invoice_timeout = timeout;
else if (*invoice_timeout < *timeout)
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"invoice_timeout %u must be >= timeout %u",
*invoice_timeout, *timeout);
/* BOLT-offers #12:
* - if the expiry for accepting payment is not 7200 seconds after
* `timestamp`:
@ -1275,9 +1263,9 @@ static struct command_result *json_sendinvoice(struct command *cmd,
* of seconds after `timestamp` that payment of this invoice should
* not be attempted.
*/
if (*invoice_timeout != 7200) {
if (sent->wait_timeout != 7200) {
sent->inv->relative_expiry = tal(sent->inv, u32);
*sent->inv->relative_expiry = *invoice_timeout;
*sent->inv->relative_expiry = sent->wait_timeout;
}
/* BOLT-offers #12: