diff --git a/tools/generate-wire.py b/tools/generate-wire.py index 7d302327d..cd1d6d15c 100755 --- a/tools/generate-wire.py +++ b/tools/generate-wire.py @@ -1496,15 +1496,6 @@ else: towire_decls = [] fromwire_decls = [] - for tlv_field, tlv_messages in tlv_fields.items(): - for m in tlv_messages: - towire_decls.append(m.print_towire(options.header, tlv_field)) - fromwire_decls.append(m.print_fromwire(options.header, tlv_field)) - - if not options.header: - towire_decls += build_tlv_towires(tlv_fields) - fromwire_decls += build_tlv_fromwires(tlv_fields) - if not options.header or (options.header and options.subtypes): subtype_towires = [] subtype_fromwires = [] @@ -1516,6 +1507,15 @@ else: towire_decls += subtype_towires fromwire_decls += subtype_fromwires + for tlv_field, tlv_messages in tlv_fields.items(): + for m in tlv_messages: + towire_decls.append(m.print_towire(options.header, tlv_field)) + fromwire_decls.append(m.print_fromwire(options.header, tlv_field)) + + if not options.header: + towire_decls += build_tlv_towires(tlv_fields) + fromwire_decls += build_tlv_fromwires(tlv_fields) + towire_decls += [m.print_towire(options.header) for m in toplevel_messages + messages_with_option] fromwire_decls += [m.print_fromwire(options.header) for m in toplevel_messages + messages_with_option] decls = fromwire_decls + towire_decls @@ -1528,5 +1528,5 @@ print(template.format( enumname=options.enumname, formatted_hdr_enums=built_hdr_enums, formatted_impl_enums=built_impl_enums, - gen_structs=tlv_structs + subtype_structs, + gen_structs=subtype_structs + tlv_structs, func_decls='\n'.join(decls)))