MCPcopy Create free account
hub / github.com/ElementsProject/lightning / payment_succeeded

Function payment_succeeded

plugins/xpay/xpay.c:457–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455}
456
457static 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
485static void payment_give_up(struct command *aux_cmd,
486 struct payment *payment,

Callers 2

payment_give_upFunction · 0.70

Calls 12

should_finish_commandFunction · 0.85
json_add_preimageFunction · 0.85
json_add_amount_msatFunction · 0.85
total_sentFunction · 0.85
json_add_u64Function · 0.85
json_add_pubkeyFunction · 0.85
json_add_sha256Function · 0.85
json_add_timeabsFunction · 0.85
was_pendingFunction · 0.70
jsonrpc_stream_successFunction · 0.50
json_add_stringFunction · 0.50
command_finishedFunction · 0.50

Tested by

no test coverage detected