Browse Source
lnbase: do not catch all exceptions, tolerate calculations with variables from kwargs
regtest_lnd
Janus
7 years ago
committed by
SomberNight
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
1 changed files with
5 additions and
3 deletions
-
lib/lnbase.py
|
|
@ -97,8 +97,10 @@ def gen_msg(msg_type, **kwargs): |
|
|
|
poslenMap = typ["payload"][k] |
|
|
|
leng = calcexp(poslenMap["length"], lengths) |
|
|
|
try: |
|
|
|
leng = kwargs[poslenMap["length"]] |
|
|
|
except: |
|
|
|
clone = dict(lengths) |
|
|
|
clone.update(kwargs) |
|
|
|
leng = calcexp(poslenMap["length"], clone) |
|
|
|
except KeyError: |
|
|
|
pass |
|
|
|
try: |
|
|
|
param = kwargs[k] |
|
|
@ -106,7 +108,7 @@ def gen_msg(msg_type, **kwargs): |
|
|
|
param = 0 |
|
|
|
try: |
|
|
|
param = param.to_bytes(length=leng, byteorder="big") |
|
|
|
except: |
|
|
|
except ValueError: |
|
|
|
raise Exception("{} does not fit in {} bytes".format(k, leng)) |
|
|
|
lengths[k] = len(param) |
|
|
|
data += param |
|
|
|