bolt12: update comments to match latest spec.

No code changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-11-09 13:02:01 +10:30
committed by Christian Decker
parent 37bc4603b8
commit 8a217f13cf
10 changed files with 81 additions and 75 deletions

View File

@@ -624,7 +624,13 @@ static struct command_result *check_previous_invoice(struct command *cmd,
}
/* BOLT-offers #12:
* - MUST fail the request if `signature` is not correct.
* - MUST fail the request if `signature` is not correct as detailed in
* [Signature Calculation](#signature-calculation) using the
* `invreq_payer_id`.
*...
* - MUST reject the invoice if `signature` is not a valid signature using
* `invoice_node_id` as described in [Signature Calculation](#signature-calculation).
*/
static bool check_payer_sig(struct command *cmd,
const struct tlv_invoice_request *invreq,
@@ -645,12 +651,12 @@ static struct command_result *invreq_amount_by_quantity(struct command *cmd,
assert(ir->invreq->offer_amount);
/* BOLT-offers #12:
* - MUST calculate the *base invoice amount* using the offer `amount`:
* - MUST calculate the *expected amount* using the `offer_amount`:
*/
*raw_amt = *ir->invreq->offer_amount;
/* BOLT-offers #12:
* - if request contains `quantity`, multiply by `quantity`.
* - if `invreq_quantity` is present, multiply by `invreq_quantity`.`quantity`.
*/
if (ir->invreq->invreq_quantity) {
if (mul_overflows_u64(*ir->invreq->invreq_quantity, *raw_amt)) {
@@ -703,11 +709,9 @@ static struct command_result *handle_amount_and_recurrence(struct command *cmd,
struct amount_msat base_inv_amount)
{
/* BOLT-offers #12:
* - if the offer included `amount`:
*...
* - if the request contains `amount`:
* - MUST fail the request if its `amount` is less than the
* *base invoice amount*.
* - if `invreq_amount` is present:
* - MUST fail the request if `invreq_amount`.`msat` is less than the
* *expected amount*.
*/
if (ir->invreq->offer_amount && ir->invreq->invreq_amount) {
if (amount_msat_less(amount_msat(*ir->invreq->invreq_amount), base_inv_amount)) {
@@ -716,8 +720,8 @@ static struct command_result *handle_amount_and_recurrence(struct command *cmd,
&base_inv_amount));
}
/* BOLT-offers #12:
* - MAY fail the request if its `amount` is much greater than
* the *base invoice amount*.
* - MAY fail the request if `invreq_amount`.`msat` greatly exceeds
* the *expected amount*.
*/
/* Much == 5? Easier to divide and compare, than multiply. */
if (amount_msat_greater(amount_msat_div(amount_msat(*ir->invreq->invreq_amount), 5),
@@ -726,13 +730,15 @@ static struct command_result *handle_amount_and_recurrence(struct command *cmd,
type_to_string(tmpctx, struct amount_msat,
&base_inv_amount));
}
/* BOLT-offers #12:
* - MUST use the request's `amount` as the *base invoice
* amount*.
*/
base_inv_amount = amount_msat(*ir->invreq->invreq_amount);
}
/* BOLT-offers #12:
* - if `invreq_amount` is present:
* - MUST set `invoice_amount` to `invreq_amount`
* - otherwise:
* - MUST set `invoice_amount` to the *expected amount*.
*/
/* This may be adjusted by recurrence if proportional_amount set */
ir->inv->invoice_amount = tal_dup(ir->inv, u64,
&base_inv_amount.millisatoshis); /* Raw: wire protocol */
@@ -794,10 +800,9 @@ static struct command_result *convert_currency(struct command *cmd,
return err;
/* BOLT-offers #12:
* - MUST calculate the *base invoice amount* using the offer
* `amount`:
* - if offer `currency` is not the invoice currency, convert
* to the invoice currency.
* - MUST calculate the *expected amount* using the `offer_amount`:
* - if `offer_currency` is not the `invreq_chain` currency, convert to the
* `invreq_chain` currency.
*/
iso4217 = find_iso4217(ir->invreq->offer_currency,
tal_bytelen(ir->invreq->offer_currency));
@@ -900,7 +905,7 @@ static struct command_result *listoffers_done(struct command *cmd,
}
/* BOLT-offers #12:
* - MUST fail the request if `invreq_signature` is not correct as
* - MUST fail the request if `signature` is not correct as
* detailed in [Signature Calculation](#signature-calculation) using
* the `invreq_payer_id`.
*/
@@ -940,10 +945,10 @@ static struct command_result *listoffers_done(struct command *cmd,
}
/* BOLT-offers #12:
* The writer of an invoice:
* A writer of an invoice:
*...
* - if the invoice is in response to an `invoice_request`:
* - MUST copy all non-signature fields from the invreq (including
* - MUST copy all non-signature fields from the `invoice_request` (including
* unknown fields).
*/
ir->inv = invoice_for_invreq(cmd, ir->invreq);
@@ -1035,7 +1040,7 @@ struct command_result *handle_invoice_request(struct command *cmd,
/* BOLT-offers #12:
*
* The reader of an invreq:
* The reader:
*...
* - if `invreq_features` contains unknown _even_ bits that are non-zero:
* - MUST fail the request.