Skip to content

Commit

Permalink
msggen: Fix the offer schemas
Browse files Browse the repository at this point in the history
I had to do some trickery with the interchangeability between string
and int, but now it works as expected.
  • Loading branch information
cdecker committed Feb 7, 2024
1 parent afa7ab2 commit a47d699
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 243 deletions.
23 changes: 3 additions & 20 deletions cln-grpc/proto/node.proto

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

76 changes: 6 additions & 70 deletions cln-grpc/src/convert.rs

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

28 changes: 3 additions & 25 deletions cln-rpc/src/model.rs

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

134 changes: 64 additions & 70 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Large diffs are not rendered by default.

59 changes: 6 additions & 53 deletions doc/schemas/offer.request.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,63 +31,16 @@
"description": "the time the offer is valid until, in seconds since the first day of 1970 UTC"
},
"recurrence": {
"type": "object",
"required": [
"time_unit",
"period"
],
"properties": {
"time_unit": {
"type": "u32",
"description": "a positive number referring to a time unit - 0 (seconds), 1 (days), 2 (months), 3 (years)"
},
"period": {
"type": "u32",
"description": "the positive number which the time unit refers to"
},
"time_unit_name": {
"type": "string",
"description": "the name of the specified time unit - either \"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\" or \"years\""
}
}
"type": "string",
"description": "A recurrence period with unit (matches '[0-9]+(seconds|minutes|hours|days|weeks|months|years)' "
},
"recurrence_base": {
"type": "object",
"required": [
"basetime",
"start_any_period"
],
"properties": {
"basetime": {
"type": "u64",
"description": "time in seconds since the first day of 1970 UTC"
},
"start_any_period": {
"type": "boolean",
"description": "whether or not the invoice should start at any period"
}
}
"type": "string",
"description": "Time in seconds since the first day of 1970 UTC. If not prefixed with an '@' the offer will start in any period (no missed payments will be performed)"
},
"recurrence_paywindow": {
"type": "object",
"required": [
"seconds_before",
"seconds_after"
],
"properties": {
"seconds_before": {
"type": "u32",
"description": "number of seconds before the start of a period in which an invoice and payment is valid"
},
"seconds_after": {
"type": "u32",
"description": "number of seconds after the start of a period in which an invoice and payment is valid"
},
"proportional_amount": {
"type": "boolean",
"description": "indicates whether the amount of the invoice will be scaled by the time remaining in the period"
}
}
"type": "string",
"description": "an optional argument of form '-time+time[%]'. The first time is the number of seconds before the start of a period in which an invoice and payment is valid, the second time is the number of seconds after the start of the period. For example -604800+86400 means you can fetch an pay the invoice 4 weeks before the given period starts, and up to 1 day afterwards. The optional % indicates that the amount of the invoice will be scaled by the time remaining in the period. If this is not specified, the default is that payment is allowed during the current and previous periods. This is encoded in the offer."
},
"recurrence_limit": {
"type": "u64",
Expand Down
13 changes: 8 additions & 5 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -4360,9 +4360,12 @@ def test_offer(node_factory, bitcoind):
['10months', 'months', 10],
['1year', 'years', 1],
['10years', 'years', 10]]:
ret = l1.rpc.call('offer', {'amount': '100000sat',
'description': 'quantity_max test',
'recurrence': r[0]})
ret = l1.rpc.call('offer', {
'amount': '100000sat',
'description': 'quantity_max test',
'recurrence': r[0],
})

offer = only_one(l1.rpc.call('listoffers', [ret['offer_id']])['offers'])
output = subprocess.check_output([bolt12tool, 'decode',
offer['bolt12']]).decode('UTF-8')
Expand Down Expand Up @@ -4398,7 +4401,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 @@ -4409,7 +4412,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 Down

0 comments on commit a47d699

Please sign in to comment.