fix encode_msg: optional fields were not sent

This commit is contained in:
ThomasV 2019-06-08 15:14:23 +02:00
parent 67f1ade798
commit 0f00f4f655

View file

@ -115,7 +115,9 @@ class LNSerializer:
lengths = {}
for k in typ["payload"]:
poslenMap = typ["payload"][k]
if "feature" in poslenMap: continue
if k not in kwargs and "feature" in poslenMap:
continue
param = kwargs.get(k, 0)
leng = _eval_exp_with_ctx(poslenMap["length"], lengths)
try:
clone = dict(lengths)
@ -123,10 +125,6 @@ class LNSerializer:
leng = _eval_exp_with_ctx(poslenMap["length"], clone)
except KeyError:
pass
try:
param = kwargs[k]
except KeyError:
param = 0
try:
if not isinstance(param, bytes):
assert isinstance(param, int), "field {} is neither bytes or int".format(k)