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

Function json_paystatus

plugins/pay.c:191–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191static struct command_result *json_paystatus(struct command *cmd,
192 const char *buf,
193 const jsmntok_t *params)
194{
195 const char *invstring;
196 struct json_stream *ret;
197 struct payment *p;
198
199 if (!param(cmd, buf, params,
200 /* FIXME: rename to invstring */
201 p_opt("bolt11", param_string, &invstring),
202 NULL))
203 return command_param_failed();
204
205 ret = jsonrpc_stream_success(cmd);
206 json_array_start(ret, "pay");
207
208 list_for_each(&payments, p, list) {
209 assert(p->parent == NULL);
210 if (invstring && !streq(invstring, p->invstring))
211 continue;
212
213 json_object_start(ret, NULL);
214 if (p->label != NULL)
215 json_add_string(ret, "label", p->label);
216
217 if (p->invstring)
218 json_add_invstring(ret, p->invstring);
219 json_add_amount_msat_only(ret, "amount_msat", p->amount);
220
221 json_add_node_id(ret, "destination", p->destination);
222
223 /* TODO(cdecker) Add label in once we track labels. */
224 /* TODO(cdecker) Add routehint_modifications in once we track
225 * them. */
226 /* TODO(cdecker) Add shadow route once we support it. */
227
228 /* If it's in listpeers right now, this can be 0 */
229 json_array_start(ret, "attempts");
230 paystatus_add_payment(ret, p);
231 json_array_end(ret);
232 json_object_end(ret);
233 }
234 json_array_end(ret);
235
236 return command_finished(cmd, ret);
237}
238
239static bool attempt_ongoing(const struct sha256 *payment_hash)
240{

Callers

nothing calls this directly

Calls 13

paystatus_add_paymentFunction · 0.85
command_param_failedFunction · 0.70
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70
paramFunction · 0.50
json_array_startFunction · 0.50
json_object_startFunction · 0.50
json_add_stringFunction · 0.50
json_add_invstringFunction · 0.50
json_add_node_idFunction · 0.50
json_array_endFunction · 0.50

Tested by

no test coverage detected