| 1016 | } |
| 1017 | |
| 1018 | static void json_add_offer(struct command *cmd, struct json_stream *js, const struct tlv_offer *offer) |
| 1019 | { |
| 1020 | struct sha256 offer_id; |
| 1021 | bool valid = true; |
| 1022 | |
| 1023 | offer_offer_id(offer, &offer_id); |
| 1024 | json_add_sha256(js, "offer_id", &offer_id); |
| 1025 | |
| 1026 | valid &= json_add_offer_fields(cmd, js, |
| 1027 | offer->offer_chains, |
| 1028 | offer->offer_metadata, |
| 1029 | offer->offer_currency, |
| 1030 | offer->offer_amount, |
| 1031 | offer->offer_description, |
| 1032 | offer->offer_features, |
| 1033 | offer->offer_absolute_expiry, |
| 1034 | offer->offer_paths, |
| 1035 | offer->offer_issuer, |
| 1036 | offer->offer_quantity_max, |
| 1037 | offer->offer_issuer_id, |
| 1038 | offer->offer_recurrence_compulsory, |
| 1039 | offer->offer_recurrence_optional, |
| 1040 | offer->offer_recurrence_paywindow, |
| 1041 | offer->offer_recurrence_limit, |
| 1042 | offer->offer_recurrence_base); |
| 1043 | /* BOLT #12: |
| 1044 | * - if neither `offer_issuer_id` nor `offer_paths` are set: |
| 1045 | * - MUST NOT respond to the offer. |
| 1046 | */ |
| 1047 | if (!offer->offer_issuer_id && !offer->offer_paths) { |
| 1048 | json_add_string(js, "warning_missing_offer_issuer_id", |
| 1049 | "offers without an issuer_id or paths are invalid"); |
| 1050 | valid = false; |
| 1051 | } |
| 1052 | json_add_extra_fields(js, "unknown_offer_tlvs", offer->fields); |
| 1053 | json_add_bool(js, "valid", valid); |
| 1054 | } |
| 1055 | |
| 1056 | static bool json_add_invreq_fields(struct command *cmd, |
| 1057 | struct json_stream *js, |
no test coverage detected