diff --git a/contrib/pyln-proto/pyln/proto/message/message.py b/contrib/pyln-proto/pyln/proto/message/message.py index fea95cb56..461d16332 100644 --- a/contrib/pyln-proto/pyln/proto/message/message.py +++ b/contrib/pyln-proto/pyln/proto/message/message.py @@ -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())