| 1233 | } |
| 1234 | |
| 1235 | static void json_add_invoice_request(struct command *cmd, |
| 1236 | struct json_stream *js, |
| 1237 | const struct tlv_invoice_request *invreq) |
| 1238 | { |
| 1239 | bool valid = true; |
| 1240 | |
| 1241 | /* If there's an offer_issuer_id or offer_paths, then there's an offer. */ |
| 1242 | if (invreq->offer_issuer_id || invreq->offer_paths) { |
| 1243 | struct sha256 offer_id; |
| 1244 | |
| 1245 | invreq_offer_id(invreq, &offer_id); |
| 1246 | json_add_sha256(js, "offer_id", &offer_id); |
| 1247 | } |
| 1248 | |
| 1249 | valid &= json_add_offer_fields(cmd, js, |
| 1250 | invreq->offer_chains, |
| 1251 | invreq->offer_metadata, |
| 1252 | invreq->offer_currency, |
| 1253 | invreq->offer_amount, |
| 1254 | invreq->offer_description, |
| 1255 | invreq->offer_features, |
| 1256 | invreq->offer_absolute_expiry, |
| 1257 | invreq->offer_paths, |
| 1258 | invreq->offer_issuer, |
| 1259 | invreq->offer_quantity_max, |
| 1260 | invreq->offer_issuer_id, |
| 1261 | invreq->offer_recurrence_compulsory, |
| 1262 | invreq->offer_recurrence_optional, |
| 1263 | invreq->offer_recurrence_paywindow, |
| 1264 | invreq->offer_recurrence_limit, |
| 1265 | invreq->offer_recurrence_base); |
| 1266 | valid &= json_add_invreq_fields(cmd, js, |
| 1267 | invreq->invreq_metadata, |
| 1268 | invreq->invreq_chain, |
| 1269 | invreq->invreq_amount, |
| 1270 | invreq->invreq_features, |
| 1271 | invreq->invreq_quantity, |
| 1272 | invreq->invreq_payer_id, |
| 1273 | invreq->invreq_payer_note, |
| 1274 | invreq->invreq_paths, |
| 1275 | invreq->invreq_bip_353_name, |
| 1276 | invreq->invreq_recurrence_counter, |
| 1277 | invreq->invreq_recurrence_start, |
| 1278 | invreq->invreq_recurrence_cancel); |
| 1279 | |
| 1280 | /* BOLT #12: |
| 1281 | * - MUST reject the invoice request if `invreq_payer_id` or `invreq_metadata` are not present. |
| 1282 | */ |
| 1283 | if (!invreq->invreq_payer_id) { |
| 1284 | json_add_string(js, "warning_missing_invreq_payer_id", |
| 1285 | "invreq_payer_id required"); |
| 1286 | valid = false; |
| 1287 | } |
| 1288 | |
| 1289 | /* BOLT #12: |
| 1290 | * - MUST reject the invoice request if `signature` is not correct as detailed |
| 1291 | * in [Signature Calculation](#signature-calculation) using the |
| 1292 | * `invreq_payer_id`. |
no test coverage detected