| 1825 | } |
| 1826 | |
| 1827 | static void payment_add_attempt(struct json_stream *s, const char *fieldname, struct payment *p, bool recurse) |
| 1828 | { |
| 1829 | bool finished = p->step >= PAYMENT_STEP_RETRY, |
| 1830 | success = p->step == PAYMENT_STEP_SUCCESS; |
| 1831 | |
| 1832 | /* A fieldname is only reasonable if we're not recursing. Otherwise the |
| 1833 | * fieldname would be reused for all attempts. */ |
| 1834 | assert(!recurse || fieldname == NULL); |
| 1835 | |
| 1836 | json_object_start(s, fieldname); |
| 1837 | |
| 1838 | if (!finished) |
| 1839 | json_add_string(s, "status", "pending"); |
| 1840 | else if (success) |
| 1841 | json_add_string(s, "status", "success"); |
| 1842 | else |
| 1843 | json_add_string(s, "status", "failed"); |
| 1844 | |
| 1845 | if (p->failreason != NULL) |
| 1846 | json_add_string(s, "failreason", p->failreason); |
| 1847 | |
| 1848 | json_add_u64(s, "partid", p->partid); |
| 1849 | if (deprecated_apis) |
| 1850 | json_add_amount_msat_only(s, "amount", p->amount); |
| 1851 | json_add_amount_msat_only(s, "amount_msat", p->amount); |
| 1852 | if (p->parent != NULL) |
| 1853 | json_add_u64(s, "parent_partid", p->parent->partid); |
| 1854 | |
| 1855 | json_object_end(s); |
| 1856 | for (size_t i=0; i<tal_count(p->children); i++) { |
| 1857 | payment_add_attempt(s, fieldname, p->children[i], recurse); |
| 1858 | } |
| 1859 | } |
| 1860 | |
| 1861 | static void payment_json_add_attempts(struct json_stream *s, |
| 1862 | const char *fieldname, struct payment *p) |
no test coverage detected