| 373 | } |
| 374 | |
| 375 | static 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 | |
| 420 | static struct command_result *listsendpays_done(struct command *cmd, |
| 421 | const char *buf, |
no test coverage detected