Skip to content

Commit 4a1918d

Browse files
committed
pyln.proto: fix receiving unknown fields in TLVs.
We can still convert these (e.g. k=1) to Python, by just using hex strings. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent d6077b0 commit 4a1918d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,12 @@ def val_to_py(self, val: Dict[str, Any], otherfields: Dict[str, Any]) -> Dict[st
521521
ret: Dict[str, Any] = {}
522522
for k, v in val.items():
523523
field = self.find_field(k)
524-
assert field
525-
ret[k] = field.val_to_py(v, val)
524+
if field:
525+
ret[k] = field.val_to_py(v, val)
526+
else:
527+
# Unknown TLV, index by number.
528+
assert isinstance(k, int)
529+
ret[k] = v.hex()
526530
return ret
527531

528532
def write(self, io_out: BufferedIOBase, v: Optional[Dict[str, Any]], otherfields: Dict[str, Any]) -> None:

0 commit comments

Comments
 (0)