decode: handle new bip353 fields.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-02-11 10:21:13 +10:30
committed by Alex Myers
parent 3d8238fef9
commit ba3e85bb43
12 changed files with 1035 additions and 723 deletions

View File

@@ -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;
}

View File

@@ -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 */