offers: don't crash in decode if there's no signature on the offer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-07-05 15:53:24 +09:30 committed by neil saitug
parent 424ac84263
commit d4c441f1d7

View File

@ -368,9 +368,14 @@ static void json_add_offer(struct json_stream *js, const struct tlv_offer *offer
json_object_end(js);
}
/* offer_decode fails if node_id or signature not set */
json_add_pubkey32(js, "node_id", offer->node_id);
json_add_bip340sig(js, "signature", offer->signature);
if (offer->node_id)
json_add_pubkey32(js, "node_id", offer->node_id);
else
valid = false;
/* If it's present, offer_decode checked it was valid */
if (offer->signature)
json_add_bip340sig(js, "signature", offer->signature);
json_add_bool(js, "valid", valid);
}