| 1522 | } |
| 1523 | |
| 1524 | static struct command_result *param_invreq(struct command *cmd, |
| 1525 | const char *name, |
| 1526 | const char *buffer, |
| 1527 | const jsmntok_t *tok, |
| 1528 | struct tlv_invoice_request **invreq) |
| 1529 | { |
| 1530 | const char *fail; |
| 1531 | int badf; |
| 1532 | struct sha256 merkle, sighash; |
| 1533 | |
| 1534 | /* BOLT #12: |
| 1535 | * - if `invreq_chain` is not present: |
| 1536 | * - MUST reject the invoice request if bitcoin is not a supported chain. |
| 1537 | * - otherwise: |
| 1538 | * - MUST reject the invoice request if `invreq_chain`.`chain` is not a |
| 1539 | * supported chain. |
| 1540 | */ |
| 1541 | *invreq = invrequest_decode(cmd, |
| 1542 | buffer + tok->start, tok->end - tok->start, |
| 1543 | plugin_feature_set(cmd->plugin), |
| 1544 | chainparams, |
| 1545 | &fail); |
| 1546 | if (!*invreq) |
| 1547 | return command_fail_badparam(cmd, name, buffer, tok, |
| 1548 | tal_fmt(cmd, |
| 1549 | "Unparsable invoice_request: %s", |
| 1550 | fail)); |
| 1551 | /* BOLT #12: |
| 1552 | * The reader: |
| 1553 | * - MUST reject the invoice request if `invreq_payer_id` or `invreq_metadata` |
| 1554 | * are not present. |
| 1555 | * - MUST reject the invoice request if any non-signature TLV fields are outside the inclusive ranges: 0 to 159 and 1000000000 to 2999999999 |
| 1556 | * - if `invreq_features` contains unknown _odd_ bits that are |
| 1557 | * non-zero: |
| 1558 | * - MUST ignore the bit. |
| 1559 | * - if `invreq_features` contains unknown _even_ bits that are |
| 1560 | * non-zero: |
| 1561 | * - MUST reject the invoice request. |
| 1562 | */ |
| 1563 | if (!(*invreq)->invreq_payer_id) |
| 1564 | return command_fail_badparam(cmd, name, buffer, tok, |
| 1565 | "Missing invreq_payer_id"); |
| 1566 | |
| 1567 | if (!(*invreq)->invreq_metadata) |
| 1568 | return command_fail_badparam(cmd, name, buffer, tok, |
| 1569 | "Missing invreq_metadata"); |
| 1570 | |
| 1571 | if (any_field_outside_range((*invreq)->fields, true, |
| 1572 | 0, 159, |
| 1573 | 1000000000, 2999999999)) { |
| 1574 | return command_fail_badparam(cmd, name, buffer, tok, |
| 1575 | "Invalid high-numbered fields"); |
| 1576 | } |
| 1577 | |
| 1578 | badf = features_unsupported(plugin_feature_set(cmd->plugin), |
| 1579 | (*invreq)->invreq_features, |
| 1580 | BOLT12_INVREQ_FEATURE); |
| 1581 | if (badf != -1) { |
nothing calls this directly
no test coverage detected