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

Function fail_inv_level

plugins/offers_inv_hook.c:22–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

fail_invFunction · 0.85
fail_internalerrFunction · 0.85

Calls 6

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

Tested by

no test coverage detected