From a6b08dc39340ade22c1b48382b3a77f51995097e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 5 Jun 2015 10:36:05 +0930 Subject: [PATCH] protocol: add revocation hash to update_accept for other commit tx. And clarify that we're going to be closing the anchor tx directly. Signed-off-by: Rusty Russell --- lightning.pb-c.c | 23 ++++++++++++++++++----- lightning.pb-c.h | 16 ++++++++++------ lightning.proto | 14 ++++++++------ 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/lightning.pb-c.c b/lightning.pb-c.c index 5cc29d894..f5909c94d 100644 --- a/lightning.pb-c.c +++ b/lightning.pb-c.c @@ -1820,7 +1820,7 @@ const ProtobufCMessageDescriptor update__descriptor = (ProtobufCMessageInit) update__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor update_accept__field_descriptors[3] = +static const ProtobufCFieldDescriptor update_accept__field_descriptors[4] = { { "sig", @@ -1847,11 +1847,23 @@ static const ProtobufCFieldDescriptor update_accept__field_descriptors[3] = 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "revocation_preimage", + "revocation_hash", 3, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ + offsetof(UpdateAccept, revocation_hash), + &sha256_hash__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "revocation_preimage", + 4, + PROTOBUF_C_LABEL_REQUIRED, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ offsetof(UpdateAccept, revocation_preimage), &sha256_hash__descriptor, NULL, @@ -1861,13 +1873,14 @@ static const ProtobufCFieldDescriptor update_accept__field_descriptors[3] = }; static const unsigned update_accept__field_indices_by_name[] = { 1, /* field[1] = old_anchor_sig */ - 2, /* field[2] = revocation_preimage */ + 2, /* field[2] = revocation_hash */ + 3, /* field[3] = revocation_preimage */ 0, /* field[0] = sig */ }; static const ProtobufCIntRange update_accept__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 3 } + { 0, 4 } }; const ProtobufCMessageDescriptor update_accept__descriptor = { @@ -1877,7 +1890,7 @@ const ProtobufCMessageDescriptor update_accept__descriptor = "UpdateAccept", "", sizeof(UpdateAccept), - 3, + 4, update_accept__field_descriptors, update_accept__field_indices_by_name, 1, update_accept__number_ranges, diff --git a/lightning.pb-c.h b/lightning.pb-c.h index a02aa4fb8..de1ce7118 100644 --- a/lightning.pb-c.h +++ b/lightning.pb-c.h @@ -323,6 +323,10 @@ struct _UpdateAccept * Signature for old anchor (if any) */ Signature *old_anchor_sig; + /* + * Hash for which I will supply preimage to revoke this new commit tx. + */ + Sha256Hash *revocation_hash; /* * Hash preimage which revokes old commitment tx. */ @@ -330,7 +334,7 @@ struct _UpdateAccept }; #define UPDATE_ACCEPT__INIT \ { PROTOBUF_C_MESSAGE_INIT (&update_accept__descriptor) \ - , NULL, NULL, NULL } + , NULL, NULL, NULL, NULL } /* @@ -426,8 +430,9 @@ struct _CloseChannel { ProtobufCMessage base; /* - * This is our signature a new transaction which spends my current - * commitment tx output 0 (which is 2/2) to script_to_me. + * This is our signature a new transaction which spends the anchor + * output to my open->script_to_me and your open->script_to_me, + * as per the last commit tx. */ Signature *sig; }; @@ -437,14 +442,13 @@ struct _CloseChannel /* - * OK, here's my sig so you can broadcast it too. + * OK, here's my sig so you can broadcast it too. We're done. */ struct _CloseChannelComplete { ProtobufCMessage base; /* - * This is our signature a new transaction which spends your current - * commitment tx output 0 (which is 2/2) to your script_to_me. + * This is my signature for that same tx. */ Signature *sig; }; diff --git a/lightning.proto b/lightning.proto index 8f6f374d8..9b448613f 100644 --- a/lightning.proto +++ b/lightning.proto @@ -134,8 +134,10 @@ message update_accept { required signature sig = 1; // Signature for old anchor (if any) optional signature old_anchor_sig = 2; + // Hash for which I will supply preimage to revoke this new commit tx. + required sha256_hash revocation_hash = 3; // Hash preimage which revokes old commitment tx. - required sha256_hash revocation_preimage = 3; + required sha256_hash revocation_preimage = 4; } // Complete the update. @@ -173,15 +175,15 @@ message new_anchor_complete { // Begin cooperative close of channel. message close_channel { - // This is our signature a new transaction which spends my current - // commitment tx output 0 (which is 2/2) to script_to_me. + // This is our signature a new transaction which spends the anchor + // output to my open->script_to_me and your open->script_to_me, + // as per the last commit tx. required signature sig = 1; } -// OK, here's my sig so you can broadcast it too. +// OK, here's my sig so you can broadcast it too. We're done. message close_channel_complete { - // This is our signature a new transaction which spends your current - // commitment tx output 0 (which is 2/2) to your script_to_me. + // This is my signature for that same tx. required signature sig = 1; }