From c40f304dc77d5ba013669d6c6ce356d9645d3676 Mon Sep 17 00:00:00 2001 From: erdoganishe Date: Mon, 22 Dec 2025 14:43:50 +0200 Subject: [PATCH] gRPC: lightningd: Fix empty description field in listpays & listsendpays Changelog-Added: Fix empty `description` field for gRPC `listpays` and `listsendpays`. No schema change required; the field already existed but was not populated. --- lightningd/pay.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/lightningd/pay.c b/lightningd/pay.c index 17a41a2ed081..ab2611b85e30 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -17,6 +17,30 @@ #include #include +/* Helper functions for extracting description from bolt11/12 string*/ +static const char *decode_bolt11_description_simple(const tal_t *ctx, + const char *invstr) +{ + char *fail; + struct bolt11 *b11 = bolt11_decode(ctx, invstr, NULL, NULL, NULL, &fail); + if (!b11) + return NULL; + if (b11->description) + return tal_strdup(ctx, b11->description); + return NULL; +} + +static const char *decode_bolt12_description(const tal_t *ctx, const char *invstr) { + char *fail; + struct tlv_invoice *tinv = invoice_decode(ctx, invstr, strlen(invstr), + NULL, NULL, &fail); + if (!tinv) + return NULL; + if (tinv->invreq_payer_note) + return tal_strdup(ctx, tinv->invreq_payer_note); + return NULL; +} + /* Routing failure object */ struct routing_failure { unsigned int erring_index; @@ -138,6 +162,7 @@ add_waitsendpay_waiter_(struct lightningd *ld, void json_add_payment_fields(struct json_stream *response, const struct wallet_payment *t) { + const char *description = NULL; json_add_u64(response, "created_index", t->id); json_add_u64(response, "id", t->id); json_add_sha256(response, "payment_hash", &t->payment_hash); @@ -176,13 +201,18 @@ void json_add_payment_fields(struct json_stream *response, if (t->label) json_add_string(response, "label", t->label); if (t->invstring) { - if (strstarts(t->invstring, "lni")) - json_add_string(response, "bolt12", t->invstring); - else - json_add_string(response, "bolt11", t->invstring); - } + if (strstarts(t->invstring, "lni")) { + json_add_string(response, "bolt12", t->invstring); + description = decode_bolt12_description(response, t->invstring); + } else { + json_add_string(response, "bolt11", t->invstring); + description = decode_bolt11_description_simple(response, t->invstring); + } +} if (t->description) json_add_string(response, "description", t->description); + else if (description) + json_add_string(response, "description", description); if (t->failonion) json_add_hex(response, "erroronion", t->failonion,