| 300 | } |
| 301 | |
| 302 | static void payment_add_attempt(struct json_stream *s, const char *fieldname, struct payment *p, bool recurse) |
| 303 | { |
| 304 | bool finished = p->step >= PAYMENT_STEP_RETRY, |
| 305 | success = p->step == PAYMENT_STEP_SUCCESS; |
| 306 | |
| 307 | /* A fieldname is only reasonable if we're not recursing. Otherwise the |
| 308 | * fieldname would be reused for all attempts. */ |
| 309 | assert(!recurse || fieldname == NULL); |
| 310 | |
| 311 | json_object_start(s, fieldname); |
| 312 | |
| 313 | if (!finished) |
| 314 | json_add_string(s, "status", "pending"); |
| 315 | else if (success) |
| 316 | json_add_string(s, "status", "success"); |
| 317 | else |
| 318 | json_add_string(s, "status", "failed"); |
| 319 | |
| 320 | if (p->failreason != NULL) |
| 321 | json_add_string(s, "failreason", p->failreason); |
| 322 | |
| 323 | json_add_u64(s, "partid", p->partid); |
| 324 | json_add_amount_msat(s, "amount_msat", p->our_amount); |
| 325 | if (p->parent != NULL) |
| 326 | json_add_u64(s, "parent_partid", p->parent->partid); |
| 327 | |
| 328 | json_object_end(s); |
| 329 | for (size_t i=0; i<tal_count(p->children); i++) { |
| 330 | payment_add_attempt(s, fieldname, p->children[i], recurse); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | static void payment_json_add_attempts(struct json_stream *s, |
| 335 | const char *fieldname, struct payment *p) |
no test coverage detected