mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
tools/generate-wire.py: intuit tlvs field if a tlv type is mentioned.
The modern style is to assert that all messages have tlvs, but many are currently empty. In particular, c4c5a8e5fb30b1b99fa5bb0aba7d0b6b4c831ee5 added "update_add_htlc_tlvs" without adding an explicit field of that type to "update_add_htlc". Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
53566c47bd
commit
244217f921
@ -583,6 +583,19 @@ def main(options, args=None, output=sys.stdout, lines=None):
|
||||
optional=optional)
|
||||
comment_set = []
|
||||
elif token_type == 'tlvtype':
|
||||
# Hack: modern spec assumes tlvs, so if there's a type to
|
||||
# attach this to, do it now, by assuming it's the same name
|
||||
# with _tlvs appended.
|
||||
if tokens[1].endswith("_tlvs"):
|
||||
container_name = tokens[1][:-5]
|
||||
msg = master.find_message(container_name)
|
||||
|
||||
if msg is not None:
|
||||
if tokens[1] not in master.types:
|
||||
# Adding: msgdata,update_add_htlc,tlvs,update_add_htlc_tlvs,
|
||||
type_obj, _, _ = master.add_type(tokens[1], "tlvs", container_name)
|
||||
msg.add_data_field(container_name, type_obj)
|
||||
|
||||
tlv = master.add_tlv(tokens[1])
|
||||
tlv.add_message(tokens[2:], comments=list(comment_set))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user