Skip to content

Commit d6077b0

Browse files
committed
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>
1 parent b90cc5b commit d6077b0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

contrib/pyln-proto/pyln/proto/message/message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ def write(self, io_out: BufferedIOBase, v: Dict[str, Any], otherfields: Dict[str
305305
raise ValueError("Missing field {} {}".format(f.name, otherfields))
306306
val = None
307307

308-
if self.name in otherfields:
309-
otherfields = otherfields[self.name]
308+
if type(f.fieldtype) is SubtypeType:
309+
otherfields = otherfields[f.name]
310310
f.fieldtype.write(io_out, val, otherfields)
311311

312312
def read(self, io_in: BufferedIOBase, otherfields: Dict[str, Any]) -> Optional[Dict[str, Any]]:
@@ -554,7 +554,7 @@ def get_value(tup):
554554

555555
for typenum, writefunc, val in ordered:
556556
buf = BytesIO()
557-
writefunc(cast(BufferedIOBase, buf), val, otherfields)
557+
writefunc(cast(BufferedIOBase, buf), val, val)
558558
BigSizeType.write(io_out, typenum)
559559
BigSizeType.write(io_out, len(buf.getvalue()))
560560
io_out.write(buf.getvalue())

0 commit comments

Comments
 (0)