decode: handle new bip353 fields.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Alex Myers
parent
3d8238fef9
commit
ba3e85bb43
@@ -798,3 +798,21 @@ const struct tlv_field *any_field_outside_range(const struct tlv_field *fields,
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool bolt12_bip353_valid_string(const u8 *str, size_t len)
|
||||
{
|
||||
/* BOLT #12:
|
||||
* - if `invreq_bip_353_name` is present:
|
||||
* - MUST reject the invoice request if `name` or `domain`
|
||||
* contain any bytes which are not `0`-`9`, `a`-`z`,
|
||||
* `A`-`Z`, `-`, `_` or `.`.
|
||||
*/
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
if (cisalnum(str[i]))
|
||||
continue;
|
||||
if (str[i] == '-' || str[i] == '_' || str[i] == '.')
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -175,4 +175,11 @@ const struct tlv_field *any_field_outside_range(const struct tlv_field *fields,
|
||||
size_t r2_start, size_t r2_end);
|
||||
|
||||
|
||||
/* BOLT #12:
|
||||
* - if `invreq_bip_353_name` is present:
|
||||
* - MUST reject the invoice request if `name` or `domain`
|
||||
* contain any bytes which are not `0`-`9`, `a`-`z`,
|
||||
* `A`-`Z`, `-`, `_` or `.`.
|
||||
*/
|
||||
bool bolt12_bip353_valid_string(const u8 *str, size_t strlen);
|
||||
#endif /* LIGHTNING_COMMON_BOLT12_H */
|
||||
|
||||
Reference in New Issue
Block a user