Skip to content

Commit

Permalink
offers: remove deprecated @ prefix.
Browse files Browse the repository at this point in the history
Somehow, this documentation got lost during the Great Rewrite, so
restore that too.

Signed-off-by: Rusty Russell <[email protected]>
Changelog-EXPERIMENTAL: JSON-RPC: `offer` removed `@` prefix support from `recurrence_base` (use `recurrence_start_any_period` set to `false`)
  • Loading branch information
rustyrussell committed Jun 14, 2024
1 parent fc2f1f4 commit d1d9d7e
Show file tree
Hide file tree
Showing 10 changed files with 460 additions and 456 deletions.
5 changes: 5 additions & 0 deletions .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -2660,6 +2660,7 @@
"Offer.recurrence_base": 8,
"Offer.recurrence_limit": 10,
"Offer.recurrence_paywindow": 9,
"Offer.recurrence_start_any_period": 12,
"Offer.single_use": 11
},
"OfferResponse": {
Expand Down Expand Up @@ -9586,6 +9587,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"Offer.recurrence_start_any_period": {
"added": "v24.02",
"deprecated": false
},
"Offer.single_use": {
"added": "pre-v0.10.1",
"deprecated": false
Expand Down
1 change: 1 addition & 0 deletions cln-grpc/proto/node.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cln-grpc/src/convert.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cln-rpc/src/model.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -23108,16 +23108,9 @@
]
},
"recurrence_base": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
],
"type": "integer",
"description": [
"Time in seconds since the first day of 1970 UTC, optionally with a `@` prefix. This indicates when the first period begins; without this, the recurrence periods start from the first invoice. The `@` prefix means that the invoice must start by paying the first period; otherwise it is permitted to start at any period. This is encoded in the offer. e.g. `@1609459200` indicates you must start paying on the 1st January 2021."
"Time in seconds since the first day of 1970 UTC. This indicates when the first period begins; without this, the recurrence periods start from the first invoice."
]
},
"recurrence_paywindow": {
Expand All @@ -23139,6 +23132,14 @@
"Indicates that the offer is only valid once; we may issue multiple invoices, but as soon as one is paid all other invoices will be expired (i.e. only one person can pay this offer)."
],
"default": "False"
},
"recurrence_start_any_period": {
"added": "v24.02",
"type": "boolean",
"description": [
"This means that the invoice may start by paying during any period; otherwise it must start by paying at the first period. Setting this to false only makes sense if *recurrence_base* was provided. This is encoded in the offer."
],
"default": "True"
}
}
},
Expand Down
836 changes: 418 additions & 418 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion doc/developers-guide/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ hidden: false
| options.flag.default-not-false | Getmanifest Reply | v23.08 | v24.08 | `flag` options with a default which is not `false` (would be meaningless, since user can only set it to `true` |
| plugin.nonumericids | Getmanifest Reply | v23.08 | v24.08 | Plugins must specify that they can accept non-numeric command ids (numeric ids are deprecated) |
| listchannels.include_private | Field(s) | v24.02 | v24.08 | `listchannels` including private channels (now use listpeerchannels which gives far more detail) |
| offer.recurrence_base.at_prefix | Parameter | v24.02 | v24.05 | `recurrence_base` with `@` prefix (use `recurrence_start_any_period`) |
| max-locktime-blocks | Config | v24.05 | v24.11 | --max-locktime-blocks is now set to 2016 in the BOLT 4 spec |


Expand Down
19 changes: 10 additions & 9 deletions doc/schemas/lightning-offer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,9 @@
]
},
"recurrence_base": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
],
"type": "integer",
"description": [
"Time in seconds since the first day of 1970 UTC, optionally with a `@` prefix. This indicates when the first period begins; without this, the recurrence periods start from the first invoice. The `@` prefix means that the invoice must start by paying the first period; otherwise it is permitted to start at any period. This is encoded in the offer. e.g. `@1609459200` indicates you must start paying on the 1st January 2021."
"Time in seconds since the first day of 1970 UTC. This indicates when the first period begins; without this, the recurrence periods start from the first invoice."
]
},
"recurrence_paywindow": {
Expand All @@ -97,6 +90,14 @@
"Indicates that the offer is only valid once; we may issue multiple invoices, but as soon as one is paid all other invoices will be expired (i.e. only one person can pay this offer)."
],
"default": "False"
},
"recurrence_start_any_period": {
"added": "v24.02",
"type": "boolean",
"description": [
"This means that the invoice may start by paying during any period; otherwise it must start by paying at the first period. Setting this to false only makes sense if *recurrence_base* was provided. This is encoded in the offer."
],
"default": "True"
}
}
},
Expand Down
12 changes: 2 additions & 10 deletions plugins/offers_offer.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,10 @@ static struct command_result *param_recurrence_base(struct command *cmd,
const jsmntok_t *tok,
struct recurrence_base **base)
{
/* Make copy so we can manipulate it */
jsmntok_t t = *tok;

*base = tal(cmd, struct recurrence_base);
if (command_deprecated_in_ok(cmd, "recurrence_base.at_prefix", "v24.02", "v24.05")
&& json_tok_startswith(buffer, &t, "@")) {
t.start++;
(*base)->start_any_period = false;
} else
(*base)->start_any_period = true;
(*base)->start_any_period = true;

if (!json_to_u64(buffer, &t, &(*base)->basetime))
if (!json_to_u64(buffer, tok, &(*base)->basetime))
return command_fail_badparam(cmd, name, buffer, tok,
"not a valid basetime");
return NULL;
Expand Down
19 changes: 10 additions & 9 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -4390,13 +4390,6 @@ def test_offer(node_factory, bitcoind):
# Test base
# (1456740000 == 10:00:00 (am) UTC on 29 February, 2016)

# This is deprecated, try modern alternative:
with pytest.raises(RpcError, match='invalid token'):
l1.rpc.call('offer', {'amount': '100000sat',
'description': 'quantity_max test',
'recurrence': '10minutes',
'recurrence_base': '@1456740000'})

# Cannot use recurrence_start_any_period without recurrence_base
with pytest.raises(RpcError, match='Cannot set to false without specifying recurrence_base'):
l1.rpc.call('offer', {'amount': '100000sat',
Expand All @@ -4407,7 +4400,7 @@ def test_offer(node_factory, bitcoind):
ret = l1.rpc.call('offer', {'amount': '100000sat',
'description': 'quantity_max test',
'recurrence': '10minutes',
'recurrence_base': '1456740000',
'recurrence_base': 1456740000,
'recurrence_start_any_period': False})
offer = only_one(l1.rpc.call('listoffers', [ret['offer_id']])['offers'])
output = subprocess.check_output([bolt12tool, 'decode',
Expand All @@ -4418,7 +4411,7 @@ def test_offer(node_factory, bitcoind):
ret = l1.rpc.call('offer', {'amount': '100000sat',
'description': 'quantity_max test',
'recurrence': '10minutes',
'recurrence_base': '1456740000'})
'recurrence_base': 1456740000})
offer = only_one(l1.rpc.call('listoffers', [ret['offer_id']])['offers'])
output = subprocess.check_output([bolt12tool, 'decode',
offer['bolt12']]).decode('UTF-8')
Expand All @@ -4444,6 +4437,14 @@ def test_offer(node_factory, bitcoind):
offer['bolt12']]).decode('UTF-8')
assert 'recurrence: every 600 seconds paywindow -10 to +600 (pay proportional)\n' in output

# This is deprecated:
l1.rpc.jsonschemas = {}
with pytest.raises(RpcError, match='invalid token'):
l1.rpc.call('offer', {'amount': '100000sat',
'description': 'test deprecated recurrence_base',
'recurrence': '10minutes',
'recurrence_base': '@1456740000'})


def test_offer_deprecated_api(node_factory, bitcoind):
l1, l2 = node_factory.line_graph(2, opts={'experimental-offers': None,
Expand Down

0 comments on commit d1d9d7e

Please sign in to comment.