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

Function add_new_entry

plugins/pay.c:375–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375static void add_new_entry(struct json_stream *ret,
376 const char *buf,
377 const struct pay_mpp *pm)
378{
379 json_object_start(ret, NULL);
380 if (pm->invstring)
381 json_add_invstring(ret, pm->invstring);
382 if (pm->description)
383 json_add_tok(ret, "description", pm->description, buf);
384 if (pm->destination)
385 json_add_tok(ret, "destination", pm->destination, buf);
386
387 json_add_sha256(ret, "payment_hash", pm->payment_hash);
388
389 if (pm->state & PAYMENT_COMPLETE)
390 json_add_string(ret, "status", "complete");
391 else if (pm->state & PAYMENT_PENDING || attempt_ongoing(pm->payment_hash))
392 json_add_string(ret, "status", "pending");
393 else
394 json_add_string(ret, "status", "failed");
395
396 json_add_u32(ret, "created_at", pm->timestamp);
397
398 if (pm->success_at < UINT64_MAX)
399 json_add_u64(ret, "completed_at", pm->success_at);
400
401 if (pm->label)
402 json_add_tok(ret, "label", pm->label, buf);
403 if (pm->preimage)
404 json_add_tok(ret, "preimage", pm->preimage, buf);
405
406 /* This is only tallied for pending and successful payments, not
407 * failures. */
408 if (pm->amount != NULL && pm->num_nonfailed_parts > 0)
409 json_add_amount_msat_only(ret, "amount_msat", *pm->amount);
410
411 json_add_amount_msat_only(ret, "amount_sent_msat",
412 pm->amount_sent);
413
414 if (pm->num_nonfailed_parts > 1)
415 json_add_u64(ret, "number_of_parts",
416 pm->num_nonfailed_parts);
417 json_object_end(ret);
418}
419
420static struct command_result *listsendpays_done(struct command *cmd,
421 const char *buf,

Callers 1

listsendpays_doneFunction · 0.85

Calls 10

json_add_tokFunction · 0.85
attempt_ongoingFunction · 0.85
json_object_startFunction · 0.50
json_add_invstringFunction · 0.50
json_add_sha256Function · 0.50
json_add_stringFunction · 0.50
json_add_u32Function · 0.50
json_add_u64Function · 0.50
json_object_endFunction · 0.50

Tested by

no test coverage detected