json_add_invoice: fix crash if missing invstring

If this field is missing for whatever reason (weird db state?)
clightning will crash when listing invoices.

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin 2022-01-18 06:13:44 -08:00 committed by Rusty Russell
parent 167fade0fa
commit ff84b3f773

View File

@ -39,7 +39,8 @@ static void json_add_invoice(struct json_stream *response,
const struct invoice_details *inv)
{
json_add_escaped_string(response, "label", inv->label);
json_add_invstring(response, inv->invstring);
if (inv->invstring)
json_add_invstring(response, inv->invstring);
json_add_sha256(response, "payment_hash", &inv->rhash);
if (inv->msat)
json_add_amount_msat_compat(response, *inv->msat,