| 649 | } |
| 650 | |
| 651 | static void payment_add_attempt(struct json_stream *s, const char *fieldname, struct payment *p, bool recurse) |
| 652 | { |
| 653 | bool finished = p->step >= PAYMENT_STEP_RETRY, |
| 654 | success = p->step == PAYMENT_STEP_SUCCESS; |
| 655 | |
| 656 | /* A fieldname is only reasonable if we're not recursing. Otherwise the |
| 657 | * fieldname would be reused for all attempts. */ |
| 658 | assert(!recurse || fieldname == NULL); |
| 659 | |
| 660 | json_object_start(s, fieldname); |
| 661 | |
| 662 | if (!finished) |
| 663 | json_add_string(s, "status", "pending"); |
| 664 | else if (success) |
| 665 | json_add_string(s, "status", "success"); |
| 666 | else |
| 667 | json_add_string(s, "status", "failed"); |
| 668 | |
| 669 | if (p->failreason != NULL) |
| 670 | json_add_string(s, "failreason", p->failreason); |
| 671 | |
| 672 | json_add_u64(s, "partid", p->partid); |
| 673 | if (deprecated_apis) |
| 674 | json_add_amount_msat_only(s, "amount", p->amount); |
| 675 | json_add_amount_msat_only(s, "amount_msat", p->amount); |
| 676 | if (p->parent != NULL) |
| 677 | json_add_u64(s, "parent_partid", p->parent->partid); |
| 678 | |
| 679 | json_object_end(s); |
| 680 | for (size_t i=0; i<tal_count(p->children); i++) { |
| 681 | payment_add_attempt(s, fieldname, p->children[i], recurse); |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | static void payment_json_add_attempts(struct json_stream *s, |
| 686 | const char *fieldname, struct payment *p) |
no test coverage detected