MCPcopy Create free account
hub / github.com/ElementsProject/lightning / payment_add_attempt

Function payment_add_attempt

plugins/libplugin-pay.c:2078–2108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2076}
2077
2078static void payment_add_attempt(struct json_stream *s, const char *fieldname, struct payment *p, bool recurse)
2079{
2080 bool finished = p->step >= PAYMENT_STEP_RETRY,
2081 success = p->step == PAYMENT_STEP_SUCCESS;
2082
2083 /* A fieldname is only reasonable if we're not recursing. Otherwise the
2084 * fieldname would be reused for all attempts. */
2085 assert(!recurse || fieldname == NULL);
2086
2087 json_object_start(s, fieldname);
2088
2089 if (!finished)
2090 json_add_string(s, "status", "pending");
2091 else if (success)
2092 json_add_string(s, "status", "success");
2093 else
2094 json_add_string(s, "status", "failed");
2095
2096 if (p->failreason != NULL)
2097 json_add_string(s, "failreason", p->failreason);
2098
2099 json_add_u64(s, "partid", p->partid);
2100 json_add_amount_msat(s, "amount_msat", p->our_amount);
2101 if (p->parent != NULL)
2102 json_add_u64(s, "parent_partid", p->parent->partid);
2103
2104 json_object_end(s);
2105 for (size_t i=0; i<tal_count(p->children); i++) {
2106 payment_add_attempt(s, fieldname, p->children[i], recurse);
2107 }
2108}
2109
2110static void payment_json_add_attempts(struct json_stream *s,
2111 const char *fieldname, struct payment *p)

Callers 1

Calls 5

json_object_startFunction · 0.85
json_add_u64Function · 0.85
json_add_amount_msatFunction · 0.85
json_object_endFunction · 0.85
json_add_stringFunction · 0.50

Tested by

no test coverage detected