| 418 | } |
| 419 | |
| 420 | static struct command_result *listsendpays_done(struct command *cmd, |
| 421 | const char *buf, |
| 422 | const jsmntok_t *result, |
| 423 | char *invstring) |
| 424 | { |
| 425 | size_t i; |
| 426 | const jsmntok_t *t, *arr; |
| 427 | struct json_stream *ret; |
| 428 | struct pay_map pay_map; |
| 429 | struct pay_mpp *pm; |
| 430 | struct pay_sort_key *order = tal_arr(tmpctx, struct pay_sort_key, 0); |
| 431 | |
| 432 | pay_map_init(&pay_map); |
| 433 | |
| 434 | arr = json_get_member(buf, result, "payments"); |
| 435 | if (!arr || arr->type != JSMN_ARRAY) |
| 436 | return command_fail(cmd, LIGHTNINGD, |
| 437 | "Unexpected non-array result from listsendpays"); |
| 438 | |
| 439 | json_for_each_arr(i, t, arr) { |
| 440 | const jsmntok_t *status, *invstrtok, *hashtok, *createdtok, |
| 441 | *completedtok, *grouptok; |
| 442 | const char *invstr = invstring; |
| 443 | struct sha256 payment_hash; |
| 444 | u32 created_at; |
| 445 | u64 completed_at; |
| 446 | u64 groupid; |
| 447 | struct pay_sort_key key; |
| 448 | |
| 449 | invstrtok = json_get_member(buf, t, "bolt11"); |
| 450 | if (!invstrtok) |
| 451 | invstrtok = json_get_member(buf, t, "bolt12"); |
| 452 | hashtok = json_get_member(buf, t, "payment_hash"); |
| 453 | createdtok = json_get_member(buf, t, "created_at"); |
| 454 | completedtok = json_get_member(buf, t, "completed_at"); |
| 455 | assert(hashtok != NULL); |
| 456 | assert(createdtok != NULL); |
| 457 | |
| 458 | if (completedtok != NULL) |
| 459 | json_to_u64(buf, completedtok, &completed_at); |
| 460 | else |
| 461 | completed_at = UINT64_MAX; |
| 462 | |
| 463 | grouptok = json_get_member(buf, t, "groupid"); |
| 464 | if (grouptok != NULL) |
| 465 | json_to_u64(buf, grouptok, &groupid); |
| 466 | else |
| 467 | groupid = 0; |
| 468 | |
| 469 | json_to_sha256(buf, hashtok, &payment_hash); |
| 470 | json_to_u32(buf, createdtok, &created_at); |
| 471 | if (invstrtok) |
| 472 | invstr = json_strdup(cmd, buf, invstrtok); |
| 473 | |
| 474 | key.payment_hash = &payment_hash; |
| 475 | key.groupid = groupid; |
| 476 | |
| 477 | pm = pay_map_get(&pay_map, &key); |
nothing calls this directly
no test coverage detected