mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
pyln.proto.message: allow fields with options to be missing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ee6c58cbd5
commit
acfeaebb62
@ -142,7 +142,7 @@ class MessageTypeField(object):
|
||||
|
||||
def missing_fields(self, fields):
|
||||
"""Return this field if it's not in fields"""
|
||||
if self.name not in fields and not self.fieldtype.is_optional():
|
||||
if self.name not in fields and not self.option and not self.fieldtype.is_optional():
|
||||
return [self]
|
||||
return []
|
||||
|
||||
@ -294,7 +294,9 @@ inherit from this too.
|
||||
for field in self.fields:
|
||||
val = field.fieldtype.read(io_in, otherfields)
|
||||
if val is None:
|
||||
raise ValueError("{}.{}: short read".format(self, field))
|
||||
# Might only exist with certain options available
|
||||
if field.fieldtype.option is None:
|
||||
raise ValueError("{}.{}: short read".format(self, field))
|
||||
vals[field.name] = val
|
||||
|
||||
return vals
|
||||
|
Loading…
Reference in New Issue
Block a user