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

Function paystatus_add_payment

plugins/pay.c:135–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135static void paystatus_add_payment(struct json_stream *s, const struct payment *p)
136{
137 char timestr[UTC_TIMELEN];
138
139 utc_timestring(&p->start_time, timestr);
140
141 json_object_start(s, NULL);
142 if (p->why != NULL)
143 json_add_string(s, "strategy", p->why);
144 json_add_string(s, "start_time", timestr);
145 json_add_u64(s, "age_in_seconds",
146 time_to_sec(time_between(clock_time(), p->start_time)));
147
148 /* Any final state will have an end time. */
149 if (p->step >= PAYMENT_STEP_SPLIT) {
150 utc_timestring(&p->end_time, timestr);
151 json_add_string(s, "end_time", timestr);
152 }
153
154 /* TODO Add routehint. */
155 /* TODO Add route details */
156
157 if (p->step < PAYMENT_STEP_SPLIT)
158 json_add_string(s, "state", "pending");
159 else
160 json_add_string(s, "state", "completed");
161
162 if (p->step == PAYMENT_STEP_SPLIT) {
163 /* Don't add anything, this is neither a success nor a failure. */
164 } else if (p->result != NULL) {
165 if (p->step == PAYMENT_STEP_SUCCESS)
166 json_object_start(s, "success");
167 else
168 json_object_start(s, "failure");
169 json_add_sendpay_result(s, p->result);
170 json_object_end(s);
171 } else if (p->step >= PAYMENT_STEP_SPLIT) {
172 json_object_start(s, "failure");
173 json_add_num(s, "code", PAY_ROUTE_NOT_FOUND);
174 json_add_string(s, "message", "Call to getroute: Could not find a route");
175 json_object_end(s);
176 }
177
178 json_object_end(s);
179 for (size_t i = 0; i < tal_count(p->children); i++)
180 paystatus_add_payment(s, p->children[i]);
181}
182
183static struct command_result *json_paystatus(struct command *cmd,
184 const char *buf,

Callers 1

json_paystatusFunction · 0.85

Calls 10

utc_timestringFunction · 0.85
json_object_startFunction · 0.85
json_add_u64Function · 0.85
time_to_secFunction · 0.85
time_betweenFunction · 0.85
clock_timeFunction · 0.85
json_add_sendpay_resultFunction · 0.85
json_object_endFunction · 0.85
json_add_numFunction · 0.85
json_add_stringFunction · 0.50

Tested by

no test coverage detected