| 455 | } |
| 456 | |
| 457 | static void payment_succeeded(struct payment *payment, |
| 458 | const struct preimage *preimage) |
| 459 | { |
| 460 | struct json_stream *js; |
| 461 | |
| 462 | /* Only succeed once */ |
| 463 | if (payment->cmd && should_finish_command(payment)) { |
| 464 | js = jsonrpc_stream_success(payment->cmd); |
| 465 | json_add_preimage(js, "payment_preimage", preimage); |
| 466 | json_add_amount_msat(js, "amount_msat", payment->amount); |
| 467 | json_add_amount_msat(js, "amount_sent_msat", total_sent(payment)); |
| 468 | /* Pay's schema expects these fields */ |
| 469 | if (payment->pay_compat) { |
| 470 | json_add_u64(js, "parts", payment->total_num_attempts); |
| 471 | json_add_pubkey(js, "destination", &payment->destination); |
| 472 | json_add_sha256(js, "payment_hash", &payment->payment_hash); |
| 473 | json_add_string(js, "status", "complete"); |
| 474 | json_add_timeabs(js, "created_at", payment->start_time); |
| 475 | } else { |
| 476 | json_add_u64(js, "failed_parts", payment->num_failures); |
| 477 | json_add_u64(js, "successful_parts", |
| 478 | payment->total_num_attempts - payment->num_failures); |
| 479 | } |
| 480 | was_pending(command_finished(payment->cmd, js)); |
| 481 | payment->cmd = NULL; |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | static void payment_give_up(struct command *aux_cmd, |
| 486 | struct payment *payment, |
no test coverage detected