| 1431 | } |
| 1432 | |
| 1433 | static struct command_result *param_invreq(struct command *cmd, |
| 1434 | const char *name, |
| 1435 | const char *buffer, |
| 1436 | const jsmntok_t *tok, |
| 1437 | struct tlv_invoice_request **invreq) |
| 1438 | { |
| 1439 | const char *fail; |
| 1440 | int badf; |
| 1441 | struct sha256 merkle, sighash; |
| 1442 | |
| 1443 | /* BOLT #12: |
| 1444 | * - if `invreq_chain` is not present: |
| 1445 | * - MUST reject the invoice request if bitcoin is not a supported chain. |
| 1446 | * - otherwise: |
| 1447 | * - MUST reject the invoice request if `invreq_chain`.`chain` is not a |
| 1448 | * supported chain. |
| 1449 | */ |
| 1450 | *invreq = invrequest_decode(cmd, |
| 1451 | buffer + tok->start, tok->end - tok->start, |
| 1452 | plugin_feature_set(cmd->plugin), |
| 1453 | chainparams, |
| 1454 | &fail); |
| 1455 | if (!*invreq) |
| 1456 | return command_fail_badparam(cmd, name, buffer, tok, |
| 1457 | tal_fmt(cmd, |
| 1458 | "Unparsable invoice_request: %s", |
| 1459 | fail)); |
| 1460 | /* BOLT #12: |
| 1461 | * The reader: |
| 1462 | * - MUST reject the invoice request if `invreq_payer_id` or `invreq_metadata` |
| 1463 | * are not present. |
| 1464 | * - MUST reject the invoice request if any non-signature TLV fields are outside the inclusive ranges: 0 to 159 and 1000000000 to 2999999999 |
| 1465 | * - if `invreq_features` contains unknown _odd_ bits that are |
| 1466 | * non-zero: |
| 1467 | * - MUST ignore the bit. |
| 1468 | * - if `invreq_features` contains unknown _even_ bits that are |
| 1469 | * non-zero: |
| 1470 | * - MUST reject the invoice request. |
| 1471 | */ |
| 1472 | if (!(*invreq)->invreq_payer_id) |
| 1473 | return command_fail_badparam(cmd, name, buffer, tok, |
| 1474 | "Missing invreq_payer_id"); |
| 1475 | |
| 1476 | if (!(*invreq)->invreq_metadata) |
| 1477 | return command_fail_badparam(cmd, name, buffer, tok, |
| 1478 | "Missing invreq_metadata"); |
| 1479 | |
| 1480 | if (any_field_outside_range((*invreq)->fields, true, |
| 1481 | 0, 159, |
| 1482 | 1000000000, 2999999999)) { |
| 1483 | return command_fail_badparam(cmd, name, buffer, tok, |
| 1484 | "Invalid high-numbered fields"); |
| 1485 | } |
| 1486 | |
| 1487 | badf = features_unsupported(plugin_feature_set(cmd->plugin), |
| 1488 | (*invreq)->invreq_features, |
| 1489 | BOLT12_INVREQ_FEATURE); |
| 1490 | if (badf != -1) { |
nothing calls this directly
no test coverage detected