mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
pyln.proto.message: fix handling of missing optional fields.
If they don't exist, that's OK. These will eventually be going away from the spec, but there are still some in gossip messages for now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
fd3ea91b44
commit
aaefbe2e9e
@ -591,6 +591,8 @@ Returns None on EOF
|
||||
fields[f.name] = f.fieldtype.read(io_in, fields)
|
||||
if fields[f.name] is None:
|
||||
# optional fields are OK to be missing at end!
|
||||
if f.option is not None:
|
||||
break
|
||||
raise ValueError('{}: truncated at field {}'
|
||||
.format(mtype, f.name))
|
||||
|
||||
@ -641,6 +643,9 @@ Must not have missing fields.
|
||||
if f.name in self.fields:
|
||||
val = self.fields[f.name]
|
||||
else:
|
||||
# If this isn't present, and it's marked optional, don't write.
|
||||
if f.option is not None:
|
||||
return
|
||||
val = None
|
||||
f.fieldtype.write(io_out, val, self.fields)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user