renepay: pay BOLT11 invoices with description_hash

This remove an unnecessary check for existing description field if the
description_hash is provided in the invoice. The bolt11_decode function
already checks the description against the hash if both are provided.

Changelog-Fix: renepay: allow to pay BOLT11 invoices with description_hash, the description field is made optional

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
This commit is contained in:
Lagrang3 2024-11-05 12:32:22 +01:00 committed by Vincenzo Palazzo
parent 555376e5c7
commit 2d9277a9a1

View file

@ -256,24 +256,6 @@ static struct command_result *json_pay(struct command *cmd, const char *buf,
return command_fail(cmd, JSONRPC2_INVALID_PARAMS, return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Invalid bolt11:" "Invalid bolt11:"
" sets feature var_onion with no secret"); " sets feature var_onion with no secret");
/* BOLT #11:
* A reader:
*...
* - MUST check that the SHA2 256-bit hash in the `h` field
* exactly matches the hashed description.
*/
if (!b11->description) {
if (!b11->description_hash)
return command_fail(
cmd, JSONRPC2_INVALID_PARAMS,
"Invalid bolt11: missing description");
if (!description)
return command_fail(
cmd, JSONRPC2_INVALID_PARAMS,
"bolt11 uses description_hash, but you did "
"not provide description parameter");
}
if (b11->msat) { if (b11->msat) {
// amount is written in the invoice // amount is written in the invoice