noise: Remove overeager limitation for varints

This commit is contained in:
Christian Decker
2020-01-20 13:53:19 +01:00
parent c3e316d79e
commit 3a39b61ab7
2 changed files with 44 additions and 6 deletions

View File

@@ -11,7 +11,7 @@ def varint_encode(i, w):
elif i <= 0xFFFFFFFF:
w.write(struct.pack("!BL", 0xFE, i))
else:
raise ValueError("Integers beyond 0xFFFFFFFF are not allowed in TLVs")
w.write(struct.pack("!BQ", 0xFF, i))
def varint_decode(r):
@@ -29,7 +29,7 @@ def varint_decode(r):
elif i == 0xFE:
return struct.unpack("!L", r.read(4))[0]
else:
raise ValueError("Attempted to unpack")
return struct.unpack("!Q", r.read(8))[0]
class ShortChannelId(object):