pyln.proto: fix handling of subtypes in TLVs.

This was revealed by using lnprototest on channel_types.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-06-24 15:00:52 +09:30
parent eaa2ff23f1
commit ca3680246e
1 changed files with 3 additions and 3 deletions

View File

@ -305,8 +305,8 @@ other types. Since 'msgtype' is almost identical, it inherits from this too.
raise ValueError("Missing field {} {}".format(f.name, otherfields))
val = None
if self.name in otherfields:
otherfields = otherfields[self.name]
if type(f.fieldtype) is SubtypeType:
otherfields = otherfields[f.name]
f.fieldtype.write(io_out, val, otherfields)
def read(self, io_in: BufferedIOBase, otherfields: Dict[str, Any]) -> Optional[Dict[str, Any]]:
@ -554,7 +554,7 @@ tlvdata,reply_channel_range_tlvs,timestamps_tlv,encoding_type,u8,
for typenum, writefunc, val in ordered:
buf = BytesIO()
writefunc(cast(BufferedIOBase, buf), val, otherfields)
writefunc(cast(BufferedIOBase, buf), val, val)
BigSizeType.write(io_out, typenum)
BigSizeType.write(io_out, len(buf.getvalue()))
io_out.write(buf.getvalue())