mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
bolt-gen: add truncated uint support for TLV fields
TLV's have truncated values, add support for them. plus some 'compilation' tests.
This commit is contained in:
committed by
Rusty Russell
parent
4261e508a9
commit
cedebfd2d9
@@ -153,10 +153,12 @@ class Type(FieldSet):
|
||||
'u16',
|
||||
'u32',
|
||||
'u64',
|
||||
'tu16',
|
||||
'tu32',
|
||||
'tu64',
|
||||
'bool',
|
||||
'amount_sat',
|
||||
'amount_msat',
|
||||
# FIXME: omits var_int
|
||||
]
|
||||
|
||||
typedefs = [
|
||||
@@ -168,6 +170,12 @@ class Type(FieldSet):
|
||||
'secp256k1_ecdsa_signature',
|
||||
]
|
||||
|
||||
truncated_typedefs = [
|
||||
'tu16',
|
||||
'tu32',
|
||||
'tu64',
|
||||
]
|
||||
|
||||
# Externally defined variable size types (require a context)
|
||||
varsize_types = [
|
||||
'peer_features',
|
||||
@@ -238,6 +246,8 @@ class Type(FieldSet):
|
||||
def type_name(self):
|
||||
if self.name in self.typedefs:
|
||||
return self.name
|
||||
if self.name in self.truncated_typedefs:
|
||||
return self.name[1:]
|
||||
if self.is_enum:
|
||||
prefix = 'enum '
|
||||
else:
|
||||
|
||||
@@ -96,6 +96,8 @@ subtypedata,test_features,globalfeatures,u8,len_gf
|
||||
|
||||
# TLV's!
|
||||
tlvtype,n1,tlv1,1
|
||||
# a truncated u64
|
||||
tlvdata,n1,tlv1,amount_msat,tu64,
|
||||
tlvtype,n1,tlv2,2
|
||||
# neseted subtype
|
||||
tlvdata,n1,tlv2,scid,test_short_id,
|
||||
@@ -106,7 +108,9 @@ tlvdata,n1,tlv3,amount_msat_2,u64,
|
||||
tlvtype,n1,tlv4,254
|
||||
tlvdata,n1,tlv4,cltv_delta,u16,
|
||||
tlvtype,n2,tlv1,0
|
||||
tlvdata,n2,tlv1,amount_msat,tu64,
|
||||
tlvtype,n2,tlv2,11
|
||||
tlvdata,n2,tlv2,cltv_expiry,tu32,
|
||||
# TLV with all varsized and array structs
|
||||
tlvtype,n3,tlv3,1
|
||||
tlvdata,n3,tlv3,subtype,test_short_id,
|
||||
|
||||
Reference in New Issue
Block a user