Returns true if valid */
| 247 | |
| 248 | /* Returns true if valid */ |
| 249 | static bool json_add_blinded_paths(struct json_stream *js, |
| 250 | struct blinded_path **paths, |
| 251 | struct blinded_payinfo **blindedpay) |
| 252 | { |
| 253 | size_t n = 0; |
| 254 | json_array_start(js, "paths"); |
| 255 | for (size_t i = 0; i < tal_count(paths); i++) { |
| 256 | json_object_start(js, NULL); |
| 257 | json_add_pubkey(js, "blinding", &paths[i]->blinding); |
| 258 | json_array_start(js, "path"); |
| 259 | for (size_t j = 0; j < tal_count(paths[i]->path); j++) { |
| 260 | json_add_onionmsg_path(js, NULL, paths[i]->path[j], |
| 261 | n < tal_count(blindedpay) |
| 262 | ? blindedpay[n] : NULL); |
| 263 | n++; |
| 264 | } |
| 265 | json_array_end(js); |
| 266 | json_object_end(js); |
| 267 | } |
| 268 | json_array_end(js); |
| 269 | |
| 270 | /* BOLT-offers #12: |
| 271 | * - MUST reject the invoice if `blinded_payinfo` does not contain |
| 272 | * exactly as many `payinfo` as total `onionmsg_path` in |
| 273 | * `blinded_path`. |
| 274 | */ |
| 275 | if (blindedpay && n != tal_count(blindedpay)) { |
| 276 | json_add_string(js, "warning_invoice_invalid_blinded_payinfo", |
| 277 | "invoice does not have correct number of blinded_payinfo"); |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | return true; |
| 282 | } |
| 283 | |
| 284 | static const char *recurrence_time_unit_name(u8 time_unit) |
| 285 | { |
no test coverage detected