| 651 | } |
| 652 | |
| 653 | static 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. */ |
| 681 | static struct command_result *invreq_base_amount_simple(struct command *cmd, |
no test coverage detected