| 638 | } |
| 639 | |
| 640 | static 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. */ |
| 668 | static struct command_result *invreq_base_amount_simple(struct command *cmd, |
no test coverage detected