Skip to content

Commit

Permalink
json-rpc: Retrieve the invoice description in listinvoices
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker authored and rustyrussell committed Jul 30, 2018
1 parent 7f45947 commit 259a699
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lightningd/invoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ static void json_add_invoice(struct json_result *response,
inv->msatoshi_received);
json_add_u64(response, "paid_at", inv->paid_timestamp);
}

if (inv->description)
json_add_string(response, "description", inv->description);

json_add_u64(response, "expires_at", inv->expiry_time);

json_object_end(response);
Expand Down
10 changes: 9 additions & 1 deletion wallet/invoices.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,14 @@ static void wallet_stmt2invoice_details(const tal_t *ctx,
dtl->paid_timestamp = sqlite3_column_int64(stmt, 8);
}

dtl->bolt11 = tal_strndup(ctx, sqlite3_column_blob(stmt, 9), sqlite3_column_bytes(stmt, 9));
dtl->bolt11 = tal_strndup(ctx, sqlite3_column_blob(stmt, 9),
sqlite3_column_bytes(stmt, 9));

if (sqlite3_column_type(stmt, 10) != SQLITE_NULL)
dtl->description = tal_strdup(
ctx, (const char *)sqlite3_column_text(stmt, 10));
else
dtl->description = NULL;
}

struct invoices *invoices_new(const tal_t *ctx,
Expand Down Expand Up @@ -643,6 +650,7 @@ void invoices_get_details(const tal_t *ctx,
"SELECT state, payment_key, payment_hash"
" , label, msatoshi, expiry_time, pay_index"
" , msatoshi_received, paid_timestamp, bolt11"
" , description"
" FROM invoices"
" WHERE id = ?;");
sqlite3_bind_int64(stmt, 1, invoice.id);
Expand Down

0 comments on commit 259a699

Please sign in to comment.