| 327 | pay_map); |
| 328 | |
| 329 | static void add_amount_sent(struct plugin *p, |
| 330 | const char *invstring, |
| 331 | struct pay_mpp *mpp, |
| 332 | const char *buf, |
| 333 | const jsmntok_t *t) |
| 334 | { |
| 335 | struct amount_msat sent, recv; |
| 336 | const jsmntok_t *msattok; |
| 337 | |
| 338 | |
| 339 | json_to_msat(buf, json_get_member(buf, t, "amount_sent_msat"), &sent); |
| 340 | if (!amount_msat_add(&mpp->amount_sent, mpp->amount_sent, sent)) |
| 341 | plugin_log(p, LOG_BROKEN, |
| 342 | "Cannot add amount_sent_msat for %s: %s + %s", |
| 343 | invstring, |
| 344 | type_to_string(tmpctx, struct amount_msat, &mpp->amount_sent), |
| 345 | type_to_string(tmpctx, struct amount_msat, &sent)); |
| 346 | |
| 347 | msattok = json_get_member(buf, t, "amount_msat"); |
| 348 | |
| 349 | /* If this is an unannotated partial payment we drop out estimate for |
| 350 | * all parts. */ |
| 351 | if (msattok == NULL) { |
| 352 | mpp->amount = tal_free(mpp->amount); |
| 353 | return; |
| 354 | } |
| 355 | |
| 356 | /* If we had a part of this multi-part payment for which we don't know |
| 357 | * the amount, then this is NULL. No point in summing up if we don't |
| 358 | * have the exact value.*/ |
| 359 | if (mpp->amount == NULL) |
| 360 | return; |
| 361 | |
| 362 | if (!json_to_msat(buf, msattok, &recv)) |
| 363 | plugin_err(p, "Cannot convert amount_sat %.*s", |
| 364 | json_tok_full_len(msattok), |
| 365 | json_tok_full(buf, msattok)); |
| 366 | |
| 367 | if (!amount_msat_add(mpp->amount, *mpp->amount, recv)) |
| 368 | plugin_log(p, LOG_BROKEN, |
| 369 | "Cannot add amount_msat for %s: %s + %s", |
| 370 | invstring, |
| 371 | type_to_string(tmpctx, struct amount_msat, mpp->amount), |
| 372 | type_to_string(tmpctx, struct amount_msat, &sent)); |
| 373 | } |
| 374 | |
| 375 | static void add_new_entry(struct json_stream *ret, |
| 376 | const char *buf, |
no test coverage detected