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

Function json_paystatus

plugins/pay.c:183–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected