Skip to content

Commit f447e39

Browse files
committed
offers: neater response on malformed invoice.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 7829f2e commit f447e39

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

plugins/offers_inv_hook.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ fail_inv_level(struct command *cmd,
2828
struct tlv_invoice_error *err;
2929
u8 *errdata;
3030

31-
full_fmt = tal_fmt(tmpctx, "Failed invoice %s",
32-
invoice_encode(tmpctx, inv->inv));
33-
if (inv->inv->offer_id)
34-
tal_append_fmt(&full_fmt, " for offer %s",
35-
type_to_string(tmpctx, struct sha256,
36-
inv->inv->offer_id));
31+
full_fmt = tal_fmt(tmpctx, "Failed invoice");
32+
if (inv->inv) {
33+
tal_append_fmt(&full_fmt, " %s",
34+
invoice_encode(tmpctx, inv->inv));
35+
if (inv->inv->offer_id)
36+
tal_append_fmt(&full_fmt, " for offer %s",
37+
type_to_string(tmpctx, struct sha256,
38+
inv->inv->offer_id));
39+
}
3740
tal_append_fmt(&full_fmt, ": %s", fmt);
3841

3942
msg = tal_vfmt(tmpctx, full_fmt, ap);

plugins/offers_invreq_hook.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ fail_invreq_level(struct command *cmd,
3838
struct tlv_invoice_error *err;
3939
u8 *errdata;
4040

41-
full_fmt = tal_fmt(tmpctx, "Failed invoice_request %s",
42-
invrequest_encode(tmpctx, invreq->invreq));
43-
if (invreq->invreq->offer_id)
44-
tal_append_fmt(&full_fmt, " for offer %s",
45-
type_to_string(tmpctx, struct sha256,
46-
invreq->invreq->offer_id));
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+
}
4750
tal_append_fmt(&full_fmt, ": %s", fmt);
4851

4952
msg = tal_vfmt(tmpctx, full_fmt, ap);

0 commit comments

Comments
 (0)