lightningd: add description field to offer related responces
What changed, and why it matters
This commit simply adds a human-readable 'description' field to several RPC responses that already expose a BOLT12 offer string. It decodes the existing offer string and, if the offer contains a description, includes it in the JSON output. There is no security-relevant change.
No security action required. This is a normal feature addition exposing already-present offer metadata.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces offer_description_from_b12(), which calls offer_decode() on a BOLT12 string and returns offer->offer_description if present. It then adds this description to the JSON responses of listoffers, disableoffer, and enableoffer. The function returns NULL on decode failure and logs at debug level. No memory management, input validation, or authorization behavior changes in a security-relevant way; the input b12 values are already stored/retrieved from the wallet or validated earlier in the RPC handlers.
Changed components
lightningd/offer.cRPC: listoffersRPC: disableofferRPC: enableofferInspect captured patch +35 / −0
diff --git a/lightningd/offer.c b/lightningd/offer.c
index 27996281..bd4357eb 100644
--- a/lightningd/offer.c
+++ b/lightningd/offer.c
@@ -25,6 +25,26 @@ static void json_populate_offer(struct json_stream *response,
json_add_escaped_string(response, "label", label);
}
+static const char *offer_description_from_b12(const tal_t *ctx,
+ struct lightningd *ld,
+ const char *b12)
+{
+ struct tlv_offer *offer;
+ char *fail;
+
+ offer = offer_decode(ctx, b12, strlen(b12),
+ NULL, NULL, &fail);
+ if (!offer) {
+ log_debug(ld->log, "Failed to decode BOLT12: %s", fail);
+ return NULL;
+ }
+
+ if (!offer->offer_description)
+ return NULL;
+
+ return offer->offer_description;
+}
+
static struct command_result *param_b12_offer(struct command *cmd,
const char *name,
const char *buffer,
@@ -134,6 +154,7 @@ static struct command_result *json_listoffers(struct command *cmd,
struct json_stream *response;
struct wallet *wallet = cmd->ld->wallet;
const char *b12;
+ const char *description;
const struct json_escape *label;
bool *active_only;
enum offer_status status;
@@ -154,6 +175,9 @@ static struct command_result *json_listoffers(struct command *cmd,
json_populate_offer(response,
offer_id, b12,
label, status);
+ description = offer_description_from_b12(tmpctx, cmd->ld, b12);
+ if (description)
+ json_add_stringn(response, "description", description, tal_bytelen(description));
json_object_end(response);
}
} else {
@@ -170,6 +194,9 @@ static struct command_result *json_listoffers(struct command *cmd,
json_populate_offer(response,
&id, b12,
label, status);
+ description = offer_description_from_b12(tmpctx, cmd->ld, b12);
+ if (description)
+ json_add_stringn(response, "description", description, tal_bytelen(description));
json_object_end(response);
}
}
@@ -193,6 +220,7 @@ static struct command_result *json_disableoffer(struct command *cmd,
struct sha256 *offer_id;
struct wallet *wallet = cmd->ld->wallet;
const char *b12;
+ const char *description;
const struct json_escape *label;
enum offer_status status;
@@ -216,6 +244,9 @@ static struct command_result *json_disableoffer(struct command *cmd,
response = json_stream_success(cmd);
json_populate_offer(response, offer_id, b12, label, status);
+ description = offer_description_from_b12(tmpctx, cmd->ld, b12);
+ if (description)
+ json_add_stringn(response, "description", description, tal_bytelen(description));
return command_success(cmd, response);
}
@@ -234,6 +265,7 @@ static struct command_result *json_enableoffer(struct command *cmd,
struct sha256 *offer_id;
struct wallet *wallet = cmd->ld->wallet;
const char *b12;
+ const char *description;
const struct json_escape *label;
enum offer_status status;
@@ -257,6 +289,9 @@ static struct command_result *json_enableoffer(struct command *cmd,
response = json_stream_success(cmd);
json_populate_offer(response, offer_id, b12, label, status);
+ description = offer_description_from_b12(tmpctx, cmd->ld, b12);
+ if (description)
+ json_add_stringn(response, "description", description, tal_bytelen(description));
return command_success(cmd, response);
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.