From 244217f921da4440eccfc7524cc8ba7d925921fc Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 22 May 2023 10:21:44 +0930 Subject: [PATCH] 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 --- tools/generate-wire.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/generate-wire.py b/tools/generate-wire.py index 92492d39d..a174985aa 100755 --- a/tools/generate-wire.py +++ b/tools/generate-wire.py @@ -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))