| 1315 | } |
| 1316 | |
| 1317 | static bool json_add_invoice_fields(struct command *cmd, |
| 1318 | struct json_stream *js, |
| 1319 | struct blinded_path **invoice_paths, |
| 1320 | struct blinded_payinfo **invoice_blindedpay, |
| 1321 | const u64 *invoice_created_at, |
| 1322 | const u32 *invoice_relative_expiry, |
| 1323 | const struct sha256 *invoice_payment_hash, |
| 1324 | const u64 *invoice_amount, |
| 1325 | struct fallback_address **invoice_fallbacks, |
| 1326 | const u8 *invoice_features, |
| 1327 | const struct pubkey *invoice_node_id, |
| 1328 | const struct bitcoin_blkid *invreq_chain, |
| 1329 | const u64 *invoice_recurrence_basetime) |
| 1330 | { |
| 1331 | bool valid = true; |
| 1332 | |
| 1333 | if (invoice_paths) |
| 1334 | valid &= json_add_blinded_paths(cmd, js, "invoice_paths", |
| 1335 | invoice_paths, invoice_blindedpay); |
| 1336 | |
| 1337 | if (invoice_created_at) |
| 1338 | json_add_u64(js, "invoice_created_at", *invoice_created_at); |
| 1339 | |
| 1340 | if (invoice_relative_expiry) |
| 1341 | json_add_u32(js, "invoice_relative_expiry", |
| 1342 | *invoice_relative_expiry); |
| 1343 | |
| 1344 | if (invoice_payment_hash) |
| 1345 | json_add_sha256(js, "invoice_payment_hash", |
| 1346 | invoice_payment_hash); |
| 1347 | |
| 1348 | if (invoice_amount) |
| 1349 | json_add_amount_msat(js, "invoice_amount_msat", |
| 1350 | amount_msat(*invoice_amount)); |
| 1351 | |
| 1352 | if (invoice_fallbacks) |
| 1353 | valid &= json_add_fallbacks(js, invreq_chain, |
| 1354 | invoice_fallbacks); |
| 1355 | |
| 1356 | if (invoice_features) |
| 1357 | json_add_hex_talarr(js, "invoice_features", invoice_features); |
| 1358 | |
| 1359 | if (invoice_node_id) |
| 1360 | json_add_pubkey(js, "invoice_node_id", invoice_node_id); |
| 1361 | |
| 1362 | if (invoice_recurrence_basetime) |
| 1363 | json_add_u64(js, "invoice_recurrence_basetime", |
| 1364 | *invoice_recurrence_basetime); |
| 1365 | |
| 1366 | return valid; |
| 1367 | } |
| 1368 | |
| 1369 | static void json_add_b12_invoice(struct command *cmd, |
| 1370 | struct json_stream *js, |
no test coverage detected