MCPcopy Create free account
hub / github.com/ElementsProject/lightning / invreq_amount_by_quantity

Function invreq_amount_by_quantity

plugins/offers_invreq_hook.c:442–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

440}
441
442static struct command_result *invreq_amount_by_quantity(struct command *cmd,
443 const struct invreq *ir,
444 u64 *raw_amt)
445{
446 assert(ir->offer->amount);
447
448 /* BOLT-offers #12:
449 * - MUST calculate the *base invoice amount* using the offer `amount`:
450 */
451 *raw_amt = *ir->offer->amount;
452
453 /* BOLT-offers #12:
454 * - if request contains `quantity`, multiply by `quantity`.
455 */
456 if (ir->invreq->quantity) {
457 if (mul_overflows_u64(*ir->invreq->quantity, *raw_amt)) {
458 return fail_invreq(cmd, ir,
459 "quantity %"PRIu64
460 " causes overflow",
461 *ir->invreq->quantity);
462 }
463 *raw_amt *= *ir->invreq->quantity;
464 }
465
466 return NULL;
467}
468
469/* The non-currency-converting case. */
470static struct command_result *invreq_base_amount_simple(struct command *cmd,

Callers 2

convert_currencyFunction · 0.85

Calls 1

mul_overflows_u64Function · 0.85

Tested by

no test coverage detected