mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-23 08:04:20 +01:00
noise: Sort TlvPayload fields before serializing
This is part of the spec
This commit is contained in:
@@ -146,6 +146,7 @@ class TlvPayload(OnionPayload):
|
|||||||
return default
|
return default
|
||||||
|
|
||||||
def to_bytes(self):
|
def to_bytes(self):
|
||||||
|
self.fields = sorted(self.fields, key=lambda f: f.typenum)
|
||||||
ser = [f.to_bytes() for f in self.fields]
|
ser = [f.to_bytes() for f in self.fields]
|
||||||
b = BytesIO()
|
b = BytesIO()
|
||||||
varint_encode(sum([len(b) for b in ser]), b)
|
varint_encode(sum([len(b) for b in ser]), b)
|
||||||
|
|||||||
Reference in New Issue
Block a user