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

Function fail_inv_level

plugins/offers_inv_hook.c:24–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22};
23
24static struct command_result *WARN_UNUSED_RESULT
25fail_inv_level(struct command *cmd,
26 const struct inv *inv,
27 enum log_level l,
28 const char *fmt, va_list ap)
29{
30 char *full_fmt, *msg;
31 struct tlv_onionmsg_tlv *payload;
32 struct tlv_invoice_error *err;
33
34 full_fmt = tal_fmt(tmpctx, "Failed invoice");
35 if (inv->inv) {
36 tal_append_fmt(&full_fmt, " %s",
37 invoice_encode(tmpctx, inv->inv));
38 }
39 tal_append_fmt(&full_fmt, ": %s", fmt);
40
41 msg = tal_vfmt(tmpctx, full_fmt, ap);
42 plugin_log(cmd->plugin, l, "%s", msg);
43
44 /* Only reply if they gave us a path */
45 if (!inv->reply_path)
46 return command_hook_success(cmd);
47
48 /* Don't send back internal error details. */
49 if (l == LOG_BROKEN)
50 msg = "Internal error";
51
52 /* Get path (maybe connect) to send reply */
53 err = tlv_invoice_error_new(cmd);
54 /* Remove NUL terminator */
55 err->error = tal_dup_arr(err, char, msg, strlen(msg), 0);
56 /* FIXME: Add suggested_value / erroneous_field! */
57
58 payload = tlv_onionmsg_tlv_new(NULL);
59 payload->invoice_error = tal_arr(payload, u8, 0);
60 towire_tlv_invoice_error(&payload->invoice_error, err);
61 return send_onion_reply(cmd, inv->reply_path, payload);
62}
63
64static struct command_result *WARN_UNUSED_RESULT
65fail_inv(struct command *cmd,

Callers 2

fail_invFunction · 0.85
fail_internalerrFunction · 0.85

Calls 5

tal_append_fmtFunction · 0.85
invoice_encodeFunction · 0.85
send_onion_replyFunction · 0.85
plugin_logFunction · 0.70
command_hook_successFunction · 0.70

Tested by

no test coverage detected