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

Function fail_invreq_level

plugins/offers_invreq_hook.c:31–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29};
30
31static struct command_result *WARN_UNUSED_RESULT
32fail_invreq_level(struct command *cmd,
33 const struct invreq *invreq,
34 enum log_level l,
35 const char *fmt, va_list ap)
36{
37 char *full_fmt, *msg;
38 struct tlv_onionmsg_payload *payload;
39 struct tlv_invoice_error *err;
40
41 full_fmt = tal_fmt(tmpctx, "Failed invoice_request");
42 if (invreq->invreq) {
43 tal_append_fmt(&full_fmt, " %s",
44 invrequest_encode(tmpctx, invreq->invreq));
45 if (invreq->invreq->offer_id)
46 tal_append_fmt(&full_fmt, " for offer %s",
47 type_to_string(tmpctx, struct sha256,
48 invreq->invreq->offer_id));
49 }
50 tal_append_fmt(&full_fmt, ": %s", fmt);
51
52 msg = tal_vfmt(tmpctx, full_fmt, ap);
53 plugin_log(cmd->plugin, l, "%s", msg);
54
55 /* Don't send back internal error details. */
56 if (l == LOG_BROKEN)
57 msg = "Internal error";
58
59 err = tlv_invoice_error_new(cmd);
60 /* Remove NUL terminator */
61 err->error = tal_dup_arr(err, char, msg, strlen(msg), 0);
62 /* FIXME: Add suggested_value / erroneous_field! */
63
64 payload = tlv_onionmsg_payload_new(tmpctx);
65 payload->invoice_error = tal_arr(payload, u8, 0);
66 towire_tlv_invoice_error(&payload->invoice_error, err);
67 return send_onion_reply(cmd, invreq->reply_path, payload);
68}
69
70static struct command_result *WARN_UNUSED_RESULT PRINTF_FMT(3,4)
71fail_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
type_to_stringClass · 0.50

Tested by

no test coverage detected