| 143 | } |
| 144 | |
| 145 | static void add_new_entry(struct plugin *plugin, |
| 146 | struct json_stream *ret, |
| 147 | const char *buf, |
| 148 | const struct pay_mpp *pm) |
| 149 | { |
| 150 | json_object_start(ret, NULL); |
| 151 | if (pm->invstring) |
| 152 | json_add_invstring(ret, pm->invstring); |
| 153 | if (pm->description) |
| 154 | json_add_tok(ret, "description", pm->description, buf); |
| 155 | if (pm->destination) |
| 156 | json_add_tok(ret, "destination", pm->destination, buf); |
| 157 | |
| 158 | json_add_sha256(ret, "payment_hash", pm->payment_hash); |
| 159 | |
| 160 | if (pm->state & PAYMENT_COMPLETE) |
| 161 | json_add_string(ret, "status", "complete"); |
| 162 | else if (pm->state & PAYMENT_PENDING || attempt_ongoing(plugin, pm->payment_hash)) |
| 163 | json_add_string(ret, "status", "pending"); |
| 164 | else |
| 165 | json_add_string(ret, "status", "failed"); |
| 166 | |
| 167 | json_add_u32(ret, "created_at", pm->timestamp); |
| 168 | |
| 169 | if (pm->success_at < UINT64_MAX) |
| 170 | json_add_u64(ret, "completed_at", pm->success_at); |
| 171 | |
| 172 | if (pm->label) |
| 173 | json_add_tok(ret, "label", pm->label, buf); |
| 174 | if (pm->preimage) |
| 175 | json_add_tok(ret, "preimage", pm->preimage, buf); |
| 176 | |
| 177 | /* This is only tallied for pending and successful payments, not |
| 178 | * failures. */ |
| 179 | if (pm->amount != NULL && pm->num_nonfailed_parts > 0) |
| 180 | json_add_amount_msat(ret, "amount_msat", *pm->amount); |
| 181 | |
| 182 | json_add_amount_msat(ret, "amount_sent_msat", pm->amount_sent); |
| 183 | |
| 184 | if (pm->num_nonfailed_parts > 1) |
| 185 | json_add_u64(ret, "number_of_parts", |
| 186 | pm->num_nonfailed_parts); |
| 187 | |
| 188 | json_add_u64(ret, "created_index", pm->created_index); |
| 189 | |
| 190 | if(pm->updated_index) |
| 191 | json_add_u64(ret, "updated_index", pm->updated_index); |
| 192 | json_object_end(ret); |
| 193 | } |
| 194 | |
| 195 | static struct command_result *listsendpays_done(struct command *cmd, |
| 196 | const char *method, |
no test coverage detected