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

Function fail_invreq_level

plugins/offers_invreq_hook.c:44–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42};
43
44static struct command_result *WARN_UNUSED_RESULT
45fail_invreq_level(struct command *cmd,
46 const struct invreq *invreq,
47 enum log_level l,
48 const char *fmt, va_list ap)
49{
50 char *full_fmt, *msg;
51 struct tlv_onionmsg_tlv *payload;
52 struct tlv_invoice_error *err;
53
54 full_fmt = tal_fmt(tmpctx, "Failed invreq");
55 if (invreq->invreq) {
56 tal_append_fmt(&full_fmt, " %s",
57 invrequest_encode(tmpctx, invreq->invreq));
58 }
59 tal_append_fmt(&full_fmt, ": %s", fmt);
60
61 msg = tal_vfmt(tmpctx, full_fmt, ap);
62 plugin_log(cmd->plugin, l, "%s", msg);
63
64 /* Don't send back internal error details. */
65 if (l == LOG_BROKEN)
66 msg = "Internal error";
67
68 err = tlv_invoice_error_new(cmd);
69 /* Remove NUL terminator */
70 err->error = tal_dup_arr(err, char, msg, strlen(msg), 0);
71 /* FIXME: Add suggested_value / erroneous_field! */
72
73 if (!invreq->reply_path)
74 return command_hook_success(cmd);
75
76 payload = tlv_onionmsg_tlv_new(tmpctx);
77 payload->invoice_error = tal_arr(payload, u8, 0);
78 towire_tlv_invoice_error(&payload->invoice_error, err);
79 return send_onion_reply(cmd, invreq->reply_path, payload);
80}
81
82static struct command_result *WARN_UNUSED_RESULT PRINTF_FMT(3,4)
83fail_invreq(struct command *cmd,

Callers 2

fail_internalerrFunction · 0.85

Calls 5

tal_append_fmtFunction · 0.85
invrequest_encodeFunction · 0.85
send_onion_replyFunction · 0.85
plugin_logFunction · 0.70
command_hook_successFunction · 0.70

Tested by

no test coverage detected