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

Function invreq_amount_by_quantity

plugins/offers_invreq_hook.c:640–665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

638}
639
640static struct command_result *invreq_amount_by_quantity(struct command *cmd,
641 const struct invreq *ir,
642 u64 *raw_amt)
643{
644 assert(ir->invreq->offer_amount);
645
646 /* BOLT #12:
647 * - MUST calculate the *expected amount* using the `offer_amount`:
648 */
649 *raw_amt = *ir->invreq->offer_amount;
650
651 /* BOLT #12:
652 * - if `invreq_quantity` is present, multiply by `invreq_quantity`.`quantity`.
653 */
654 if (ir->invreq->invreq_quantity) {
655 if (mul_overflows_u64(*ir->invreq->invreq_quantity, *raw_amt)) {
656 return fail_invreq(cmd, ir,
657 "quantity %"PRIu64
658 " causes overflow",
659 *ir->invreq->invreq_quantity);
660 }
661 *raw_amt *= *ir->invreq->invreq_quantity;
662 }
663
664 return NULL;
665}
666
667/* The non-currency-converting case. */
668static 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