Skip to content

Commit 691f483

Browse files
committed
pyln.proto.message: allow fields with options to be missing.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 3ff8fe0 commit 691f483

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def __init__(self, ownername, name, fieldtype, option=None):
142142

143143
def missing_fields(self, fields):
144144
"""Return this field if it's not in fields"""
145-
if self.name not in fields and not self.fieldtype.is_optional():
145+
if self.name not in fields and not self.option and not self.fieldtype.is_optional():
146146
return [self]
147147
return []
148148

@@ -294,7 +294,9 @@ def read(self, io_in, otherfields):
294294
for field in self.fields:
295295
val = field.fieldtype.read(io_in, otherfields)
296296
if val is None:
297-
raise ValueError("{}.{}: short read".format(self, field))
297+
# Might only exist with certain options available
298+
if field.fieldtype.option is None:
299+
raise ValueError("{}.{}: short read".format(self, field))
298300
vals[field.name] = val
299301

300302
return vals

0 commit comments

Comments
 (0)