mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
tools/generate-wire.py: accept multiple comma-separated options.
Somehow this change got lost, but it's needed for option_static_remotekey, to quote gen_peer_wire_csv: msgtype,channel_reestablish,136 msgdata,channel_reestablish,channel_id,channel_id, msgdata,channel_reestablish,next_commitment_number,u64, msgdata,channel_reestablish,next_revocation_number,u64, msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32,option_data_loss_protect,option_static_remotekey msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
51d7a1404f
commit
6a293fd135
@ -577,6 +577,11 @@ def main(options, args=None, output=sys.stdout, lines=None):
|
|||||||
raise ValueError('Unknown message type {}. {}:{}'.format(tokens[1], ln, line))
|
raise ValueError('Unknown message type {}. {}:{}'.format(tokens[1], ln, line))
|
||||||
type_obj, collapse, optional = master.add_type(tokens[3], tokens[2], tokens[1])
|
type_obj, collapse, optional = master.add_type(tokens[3], tokens[2], tokens[1])
|
||||||
|
|
||||||
|
if collapse:
|
||||||
|
count = 1
|
||||||
|
else:
|
||||||
|
count = tokens[4]
|
||||||
|
|
||||||
# if this is an 'extension' field*, we want to add a new 'message' type
|
# if this is an 'extension' field*, we want to add a new 'message' type
|
||||||
# in the future, extensions will be handled as TLV's
|
# in the future, extensions will be handled as TLV's
|
||||||
#
|
#
|
||||||
@ -585,18 +590,24 @@ def main(options, args=None, output=sys.stdout, lines=None):
|
|||||||
# differently. for the sake of clarity here, for bolt-wire messages,
|
# differently. for the sake of clarity here, for bolt-wire messages,
|
||||||
# we'll refer to 'optional' message fields as 'extensions')
|
# we'll refer to 'optional' message fields as 'extensions')
|
||||||
#
|
#
|
||||||
if bool(tokens[5:]): # is an extension field
|
if tokens[5:] == []:
|
||||||
|
msg.add_data_field(tokens[2], type_obj, count, comments=list(comment_set),
|
||||||
|
optional=optional)
|
||||||
|
else: # is one or more extension fields
|
||||||
if optional:
|
if optional:
|
||||||
raise ValueError("Extension fields cannot be optional. {}:{}"
|
raise ValueError("Extension fields cannot be optional. {}:{}"
|
||||||
.format(ln, line))
|
.format(ln, line))
|
||||||
extension_name = "{}_{}".format(tokens[1], tokens[5])
|
|
||||||
orig_msg = msg
|
orig_msg = msg
|
||||||
msg = master.find_message(extension_name)
|
for extension in tokens[5:]:
|
||||||
if not msg:
|
extension_name = "{}_{}".format(tokens[1], extension)
|
||||||
msg = copy.deepcopy(orig_msg)
|
msg = master.find_message(extension_name)
|
||||||
msg.enumname = msg.name
|
if not msg:
|
||||||
msg.name = extension_name
|
msg = copy.deepcopy(orig_msg)
|
||||||
master.add_extension_msg(msg.name, msg)
|
msg.enumname = msg.name
|
||||||
|
msg.name = extension_name
|
||||||
|
master.add_extension_msg(msg.name, msg)
|
||||||
|
msg.add_data_field(tokens[2], type_obj, count, comments=list(comment_set), optional=optional)
|
||||||
|
|
||||||
# If this is a print_wire page, add the extension fields to the
|
# If this is a print_wire page, add the extension fields to the
|
||||||
# original message, so we can print them if present.
|
# original message, so we can print them if present.
|
||||||
if options.print_wire:
|
if options.print_wire:
|
||||||
@ -605,14 +616,6 @@ def main(options, args=None, output=sys.stdout, lines=None):
|
|||||||
comments=list(comment_set),
|
comments=list(comment_set),
|
||||||
optional=optional)
|
optional=optional)
|
||||||
|
|
||||||
if collapse:
|
|
||||||
count = 1
|
|
||||||
else:
|
|
||||||
count = tokens[4]
|
|
||||||
|
|
||||||
msg.add_data_field(tokens[2], type_obj, count, comments=list(comment_set),
|
|
||||||
optional=optional)
|
|
||||||
|
|
||||||
comment_set = []
|
comment_set = []
|
||||||
elif token_type.startswith('#include'):
|
elif token_type.startswith('#include'):
|
||||||
master.add_include(token_type)
|
master.add_include(token_type)
|
||||||
|
Loading…
Reference in New Issue
Block a user