-
Notifications
You must be signed in to change notification settings - Fork 1k
offers: fix recurrence proportional amount #9413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -563,10 +563,13 @@ static struct command_result *check_period(struct command *cmd, | |
| u64 end = offer_period_start(basetime, period_idx + 1, | ||
| invreq_recurrence(ir->invreq)); | ||
|
|
||
| if (*ir->inv->invoice_created_at > start) { | ||
| assert(end > start); | ||
| if (*ir->inv->invoice_created_at >= end) { | ||
| *ir->inv->invoice_amount = 1; | ||
|
Comment on lines
+567
to
+568
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } else if (*ir->inv->invoice_created_at > start) { | ||
| *ir->inv->invoice_amount | ||
| *= (double)((*ir->inv->invoice_created_at - start) | ||
| / (end - start)); | ||
| *= ((double)end - *ir->inv->invoice_created_at) | ||
| / (end - start); | ||
| /* Round up to make it non-zero if necessary. */ | ||
| if (*ir->inv->invoice_amount == 0) | ||
| *ir->inv->invoice_amount = 1; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this a
fail_invreq()rather than anassert(). offer_period_start() gives no guarantee that end > start. param_recurrence() (plugins/offers_offer.c:96) has no non-zero check on period, and the period == 0 guard at common/bolt12.c:290 is in offer_decode(), not invrequest_decode(), so a recurrence=0seconds offer reaches here with start == end. period_idx is also invreq_recurrence_start + invreq_recurrence_counter, i.e. remote-chosen, and offer_period_start() truncates period*n into time_change()'s u32number(common/bolt12.c:449), so the sequence is not monotone across that range either.offersis a builtin and soimportant, and NDEBUG is never defined, so an abort heretakes the node down.