| 664 | } |
| 665 | |
| 666 | static 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. */ |
| 694 | static struct command_result *invreq_base_amount_simple(struct command *cmd, |
no test coverage detected