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

Function invreq_amount_by_quantity

plugins/offers_invreq_hook.c:666–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

664}
665
666static struct command_result *invreq_amount_by_quantity(struct command *cmd,
667 const struct invreq *ir,
668 u64 *raw_amt)
669{
670 assert(ir->invreq->offer_amount);
671
672 /* BOLT #12:
673 * - MUST calculate the *expected amount* using the `offer_amount`:
674 */
675 *raw_amt = *ir->invreq->offer_amount;
676
677 /* BOLT #12:
678 * - if `invreq_quantity` is present, multiply by `invreq_quantity`.`quantity`.
679 */
680 if (ir->invreq->invreq_quantity) {
681 if (mul_overflows_u64(*ir->invreq->invreq_quantity, *raw_amt)) {
682 return fail_invreq(cmd, ir,
683 "quantity %"PRIu64
684 " causes overflow",
685 *ir->invreq->invreq_quantity);
686 }
687 *raw_amt *= *ir->invreq->invreq_quantity;
688 }
689
690 return NULL;
691}
692
693/* The non-currency-converting case. */
694static 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