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

Function injectonion_fail

lightningd/pay.c:1707–1739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1705AUTODATA(json_command, &waitsendpay_command);
1706
1707static struct command_result *
1708injectonion_fail(struct command *cmd,
1709 const struct wallet_payment *payment,
1710 enum jsonrpc_errcode pay_errcode,
1711 const struct onionreply *onionreply,
1712 const struct routing_failure *fail,
1713 const char *errmsg,
1714 struct secret *shared_secret)
1715{
1716 struct json_stream *js;
1717
1718 /* Turn local errors into onion reply. */
1719 if (!onionreply) {
1720 const u8 *err;
1721
1722 /* Local error with no context, use default error */
1723 if (fail->msg)
1724 err = fail->msg;
1725 else
1726 err = towire_temporary_channel_failure(tmpctx, NULL);
1727
1728 onionreply = create_onionreply(tmpctx, shared_secret, err);
1729 }
1730
1731 js = json_stream_fail(cmd, PAY_INJECTPAYMENTONION_FAILED, errmsg);
1732 /* We wrap the onion reply, as it expects. */
1733 json_add_hex_talarr(js, "onionreply",
1734 wrap_onionreply(tmpctx, shared_secret, onionreply)
1735 ->contents);
1736
1737 json_object_end(js);
1738 return command_failed(cmd, js);
1739}
1740
1741static struct command_result *
1742injectonion_succeed(struct command *cmd,

Callers

nothing calls this directly

Calls 6

create_onionreplyFunction · 0.85
json_add_hex_talarrFunction · 0.85
wrap_onionreplyFunction · 0.85
json_object_endFunction · 0.85
json_stream_failFunction · 0.70
command_failedFunction · 0.70

Tested by

no test coverage detected