Browse Source

protocol: add a third leg to the close operation.

This gives us a neat way to know the other end has received our sig.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
fefe2deea2
  1. 84
      lightning.pb-c.c
  2. 38
      lightning.pb-c.h
  3. 5
      lightning.proto

84
lightning.pb-c.c

@ -867,6 +867,49 @@ void close_channel_complete__free_unpacked
assert(message->base.descriptor == &close_channel_complete__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void close_channel_ack__init
(CloseChannelAck *message)
{
static CloseChannelAck init_value = CLOSE_CHANNEL_ACK__INIT;
*message = init_value;
}
size_t close_channel_ack__get_packed_size
(const CloseChannelAck *message)
{
assert(message->base.descriptor == &close_channel_ack__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t close_channel_ack__pack
(const CloseChannelAck *message,
uint8_t *out)
{
assert(message->base.descriptor == &close_channel_ack__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t close_channel_ack__pack_to_buffer
(const CloseChannelAck *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &close_channel_ack__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
CloseChannelAck *
close_channel_ack__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (CloseChannelAck *)
protobuf_c_message_unpack (&close_channel_ack__descriptor,
allocator, len, data);
}
void close_channel_ack__free_unpacked
(CloseChannelAck *message,
ProtobufCAllocator *allocator)
{
assert(message->base.descriptor == &close_channel_ack__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void error__init
(Error *message)
{
@ -2165,6 +2208,24 @@ const ProtobufCMessageDescriptor close_channel_complete__descriptor =
(ProtobufCMessageInit) close_channel_complete__init,
NULL,NULL,NULL /* reserved[123] */
};
#define close_channel_ack__field_descriptors NULL
#define close_channel_ack__field_indices_by_name NULL
#define close_channel_ack__number_ranges NULL
const ProtobufCMessageDescriptor close_channel_ack__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"close_channel_ack",
"CloseChannelAck",
"CloseChannelAck",
"",
sizeof(CloseChannelAck),
0,
close_channel_ack__field_descriptors,
close_channel_ack__field_indices_by_name,
0, close_channel_ack__number_ranges,
(ProtobufCMessageInit) close_channel_ack__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor error__field_descriptors[1] =
{
{
@ -2203,7 +2264,7 @@ const ProtobufCMessageDescriptor error__descriptor =
(ProtobufCMessageInit) error__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor pkt__field_descriptors[16] =
static const ProtobufCFieldDescriptor pkt__field_descriptors[17] =
{
{
"update",
@ -2385,6 +2446,18 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[16] =
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"close_ack",
403,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Pkt, pkt_case),
offsetof(Pkt, close_ack),
&close_channel_ack__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"error",
1000,
@ -2400,8 +2473,9 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[16] =
};
static const unsigned pkt__field_indices_by_name[] = {
13, /* field[13] = close */
15, /* field[15] = close_ack */
14, /* field[14] = close_complete */
15, /* field[15] = error */
16, /* field[16] = error */
9, /* field[9] = open */
10, /* field[10] = open_anchor */
11, /* field[11] = open_commit_sig */
@ -2421,8 +2495,8 @@ static const ProtobufCIntRange pkt__number_ranges[4 + 1] =
{ 1, 0 },
{ 201, 9 },
{ 401, 13 },
{ 1000, 15 },
{ 0, 16 }
{ 1000, 16 },
{ 0, 17 }
};
const ProtobufCMessageDescriptor pkt__descriptor =
{
@ -2432,7 +2506,7 @@ const ProtobufCMessageDescriptor pkt__descriptor =
"Pkt",
"",
sizeof(Pkt),
16,
17,
pkt__field_descriptors,
pkt__field_indices_by_name,
4, pkt__number_ranges,

38
lightning.pb-c.h

@ -35,6 +35,7 @@ typedef struct _UpdateSignature UpdateSignature;
typedef struct _UpdateComplete UpdateComplete;
typedef struct _CloseChannel CloseChannel;
typedef struct _CloseChannelComplete CloseChannelComplete;
typedef struct _CloseChannelAck CloseChannelAck;
typedef struct _Error Error;
typedef struct _Pkt Pkt;
@ -472,6 +473,18 @@ struct _CloseChannelComplete
, NULL }
/*
* Received close_channel_complete, you can close now.
*/
struct _CloseChannelAck
{
ProtobufCMessage base;
};
#define CLOSE_CHANNEL_ACK__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&close_channel_ack__descriptor) \
}
/*
* This means we're going to hang up; it's to help diagnose only!
*/
@ -502,6 +515,7 @@ typedef enum {
PKT__PKT_UPDATE_ROUTEFAIL_HTLC = 9,
PKT__PKT_CLOSE = 401,
PKT__PKT_CLOSE_COMPLETE = 402,
PKT__PKT_CLOSE_ACK = 403,
PKT__PKT_ERROR = 1000,
} Pkt__PktCase;
@ -537,6 +551,7 @@ struct _Pkt
*/
CloseChannel *close;
CloseChannelComplete *close_complete;
CloseChannelAck *close_ack;
/*
* Unexpected issue.
*/
@ -928,6 +943,25 @@ CloseChannelComplete *
void close_channel_complete__free_unpacked
(CloseChannelComplete *message,
ProtobufCAllocator *allocator);
/* CloseChannelAck methods */
void close_channel_ack__init
(CloseChannelAck *message);
size_t close_channel_ack__get_packed_size
(const CloseChannelAck *message);
size_t close_channel_ack__pack
(const CloseChannelAck *message,
uint8_t *out);
size_t close_channel_ack__pack_to_buffer
(const CloseChannelAck *message,
ProtobufCBuffer *buffer);
CloseChannelAck *
close_channel_ack__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void close_channel_ack__free_unpacked
(CloseChannelAck *message,
ProtobufCAllocator *allocator);
/* Error methods */
void error__init
(Error *message);
@ -1028,6 +1062,9 @@ typedef void (*CloseChannel_Closure)
typedef void (*CloseChannelComplete_Closure)
(const CloseChannelComplete *message,
void *closure_data);
typedef void (*CloseChannelAck_Closure)
(const CloseChannelAck *message,
void *closure_data);
typedef void (*Error_Closure)
(const Error *message,
void *closure_data);
@ -1061,6 +1098,7 @@ extern const ProtobufCMessageDescriptor update_signature__descriptor;
extern const ProtobufCMessageDescriptor update_complete__descriptor;
extern const ProtobufCMessageDescriptor close_channel__descriptor;
extern const ProtobufCMessageDescriptor close_channel_complete__descriptor;
extern const ProtobufCMessageDescriptor close_channel_ack__descriptor;
extern const ProtobufCMessageDescriptor error__descriptor;
extern const ProtobufCMessageDescriptor pkt__descriptor;

5
lightning.proto

@ -193,6 +193,10 @@ message close_channel_complete {
required signature sig = 1;
}
// Received close_channel_complete, you can close now.
message close_channel_ack {
}
// This means we're going to hang up; it's to help diagnose only!
message error {
optional string problem = 1;
@ -219,6 +223,7 @@ message pkt {
// Closing
close_channel close = 401;
close_channel_complete close_complete = 402;
close_channel_ack close_ack = 403;
// Unexpected issue.
error error = 1000;

Loading…
Cancel
Save