diff --git a/doc/lightning-invoice.7.md b/doc/lightning-invoice.7.md index b52ed45b4ded..aab55ad72f31 100644 --- a/doc/lightning-invoice.7.md +++ b/doc/lightning-invoice.7.md @@ -33,10 +33,8 @@ viewable by any node you send this invoice to (unless *deschashonly* is true as described below). It must be UTF-8, and cannot use *\\u* JSON escape codes. -The *expiry* is optionally the time the invoice is valid for; without a -suffix it is interpreted as seconds, otherwise suffixes *s*, *m*, *h*, -*d*, *w* indicate seconds, minutes, hours, days and weeks respectively. -If no value is provided the default of 604800 (1w) is used. +The *expiry* is optionally the time the invoice is valid for, in seconds. +If no value is provided the default of 604800 (1 week) is used. The *fallbacks* array is one or more fallback addresses to include in the invoice (in order from most-preferred to least): note that these diff --git a/lightningd/invoice.c b/lightningd/invoice.c index 1c95e48d4abb..e68fb92208f7 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -1035,6 +1035,9 @@ static struct command_result *param_time(struct command *cmd, const char *name, { 'd', 24*60*60 }, { 'w', 7*24*60*60 } }; + if (!deprecated_apis) + return param_u64(cmd, name, buffer, tok, secs); + mul = 1; if (timetok.end == timetok.start) s = '\0'; @@ -1059,7 +1062,7 @@ static struct command_result *param_time(struct command *cmd, const char *name, } return command_fail_badparam(cmd, name, buffer, tok, - "should be a number with optional {s,m,h,d,w} suffix"); + "should be a number"); } static struct command_result *param_chanhints(struct command *cmd, diff --git a/tests/test_invoices.py b/tests/test_invoices.py index e02dd2561926..8052a2e06074 100644 --- a/tests/test_invoices.py +++ b/tests/test_invoices.py @@ -437,37 +437,12 @@ def test_invoice_expiry(node_factory, executor): # all invoices are expired and should be deleted assert len(l2.rpc.listinvoices()['invoices']) == 0 - # Test expiry suffixes. start = int(time.time()) - inv = l2.rpc.invoice(msatoshi=123000, label='inv_s', description='description', expiry='1s')['bolt11'] + inv = l2.rpc.invoice(msatoshi=123000, label='inv_s', description='description', expiry=1)['bolt11'] end = int(time.time()) expiry = only_one(l2.rpc.listinvoices('inv_s')['invoices'])['expires_at'] assert expiry >= start + 1 and expiry <= end + 1 - start = int(time.time()) - inv = l2.rpc.invoice(msatoshi=123000, label='inv_m', description='description', expiry='1m')['bolt11'] - end = int(time.time()) - expiry = only_one(l2.rpc.listinvoices('inv_m')['invoices'])['expires_at'] - assert expiry >= start + 60 and expiry <= end + 60 - - start = int(time.time()) - inv = l2.rpc.invoice(msatoshi=123000, label='inv_h', description='description', expiry='1h')['bolt11'] - end = int(time.time()) - expiry = only_one(l2.rpc.listinvoices('inv_h')['invoices'])['expires_at'] - assert expiry >= start + 3600 and expiry <= end + 3600 - - start = int(time.time()) - inv = l2.rpc.invoice(msatoshi=123000, label='inv_d', description='description', expiry='1d')['bolt11'] - end = int(time.time()) - expiry = only_one(l2.rpc.listinvoices('inv_d')['invoices'])['expires_at'] - assert expiry >= start + 24 * 3600 and expiry <= end + 24 * 3600 - - start = int(time.time()) - inv = l2.rpc.invoice(msatoshi=123000, label='inv_w', description='description', expiry='1w')['bolt11'] - end = int(time.time()) - expiry = only_one(l2.rpc.listinvoices('inv_w')['invoices'])['expires_at'] - assert expiry >= start + 7 * 24 * 3600 and expiry <= end + 7 * 24 * 3600 - @pytest.mark.developer("Too slow without --dev-fast-gossip") def test_waitinvoice(node_factory, executor):