mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pay: don't require description for hashdesc invoices (i.e. undeprecate).
Since we didn't hash the descriptions properly (see previous commit), we cannot immediately deprecate omitting the descriptions (since you'd have to omit them for backwards compat!). And move the "must have description or hash" test into bolt11.c core. Changelog-Deprecated: `pay` has *undeprecated* paying a description-hash invoice without providing the description. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -893,6 +893,17 @@ struct bolt11 *bolt11_decode_nosig(const tal_t *ctx, const char *str,
|
|||||||
"h: does not match description");
|
"h: does not match description");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* BOLT #11:
|
||||||
|
* A writer:
|
||||||
|
*...
|
||||||
|
* - MUST include either exactly one `d` or exactly one `h` field.
|
||||||
|
*/
|
||||||
|
/* FIXME: It doesn't actually say the reader must check though! */
|
||||||
|
if (!have_field[bech32_charset_rev['d']]
|
||||||
|
&& !have_field[bech32_charset_rev['h']])
|
||||||
|
return decode_fail(b11, fail,
|
||||||
|
"must have either 'd' or 'h' field");
|
||||||
|
|
||||||
hash_u5_done(&hu5, hash);
|
hash_u5_done(&hu5, hash);
|
||||||
*sig = tal_dup_arr(ctx, u5, data, data_len, 0);
|
*sig = tal_dup_arr(ctx, u5, data, data_len, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -1053,24 +1053,6 @@ static struct command_result *json_pay(struct command *cmd,
|
|||||||
cmd, JSONRPC2_INVALID_PARAMS,
|
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 && !deprecated_apis) {
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
b12 = invoice_decode(tmpctx, b11str, strlen(b11str),
|
b12 = invoice_decode(tmpctx, b11str, strlen(b11str),
|
||||||
plugin_feature_set(cmd->plugin),
|
plugin_feature_set(cmd->plugin),
|
||||||
|
|||||||
@@ -724,10 +724,6 @@ def test_invoice_deschash(node_factory, chainparams):
|
|||||||
listinv = only_one(l2.rpc.listinvoices()['invoices'])
|
listinv = only_one(l2.rpc.listinvoices()['invoices'])
|
||||||
assert listinv['description'] == 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon'
|
assert listinv['description'] == 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon'
|
||||||
|
|
||||||
# To pay it we need to provide the (correct!) description.
|
|
||||||
with pytest.raises(RpcError, match=r'you did not provide description parameter'):
|
|
||||||
l1.rpc.pay(inv['bolt11'])
|
|
||||||
|
|
||||||
with pytest.raises(RpcError, match=r'does not match description'):
|
with pytest.raises(RpcError, match=r'does not match description'):
|
||||||
l1.rpc.pay(inv['bolt11'], description=listinv['description'][:-1])
|
l1.rpc.pay(inv['bolt11'], description=listinv['description'][:-1])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user