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

Function invreq_amount_by_quantity

plugins/offers_invreq_hook.c:653–678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651}
652
653static struct command_result *invreq_amount_by_quantity(struct command *cmd,
654 const struct invreq *ir,
655 u64 *raw_amt)
656{
657 assert(ir->invreq->offer_amount);
658
659 /* BOLT #12:
660 * - MUST calculate the *expected amount* using the `offer_amount`:
661 */
662 *raw_amt = *ir->invreq->offer_amount;
663
664 /* BOLT #12:
665 * - if `invreq_quantity` is present, multiply by `invreq_quantity`.`quantity`.
666 */
667 if (ir->invreq->invreq_quantity) {
668 if (mul_overflows_u64(*ir->invreq->invreq_quantity, *raw_amt)) {
669 return fail_invreq(cmd, ir,
670 "quantity %"PRIu64
671 " causes overflow",
672 *ir->invreq->invreq_quantity);
673 }
674 *raw_amt *= *ir->invreq->invreq_quantity;
675 }
676
677 return NULL;
678}
679
680/* The non-currency-converting case. */
681static 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