utf8: handle UTF-8 arrays.

BOLT 12 introduces this as a new fundamental type, which lets us easily
validate them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-12-05 12:49:54 +10:30
parent 2734fd274e
commit a11edebb7c
40 changed files with 56 additions and 38 deletions

View File

@@ -204,6 +204,7 @@ class Type(FieldSet):
'bool',
'secp256k1_ecdsa_signature',
'secp256k1_ecdsa_recoverable_signature',
'utf8',
'wirestring',
'errcode_t',
'bigsize',
@@ -318,9 +319,10 @@ class Type(FieldSet):
return prefix + self.struct_name()
# We only accelerate the u8 case: it's common and trivial.
# We accelerate the u8 case: it's common and trivial.
# We handle the utf8 case so we can be sure it's actually a UTF-8 string.
def has_array_helper(self):
return self.name in ['u8']
return self.name in ['u8', 'utf8']
def struct_name(self):
if self.is_tlv():