Browse Source

protocol: add HTLC

Proposing an HTLC follows the same sequence as proposing a normal
update.  There's also requests to complete and remove HTLCs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 10 years ago
parent
commit
3325c7320d
  1. 481
      lightning.pb-c.c
  2. 201
      lightning.pb-c.h
  3. 51
      lightning.proto

481
lightning.pb-c.c

@ -394,6 +394,178 @@ void update__free_unpacked
assert(message->base.descriptor == &update__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void update_add_htlc__init
(UpdateAddHtlc *message)
{
static UpdateAddHtlc init_value = UPDATE_ADD_HTLC__INIT;
*message = init_value;
}
size_t update_add_htlc__get_packed_size
(const UpdateAddHtlc *message)
{
assert(message->base.descriptor == &update_add_htlc__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t update_add_htlc__pack
(const UpdateAddHtlc *message,
uint8_t *out)
{
assert(message->base.descriptor == &update_add_htlc__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t update_add_htlc__pack_to_buffer
(const UpdateAddHtlc *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &update_add_htlc__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
UpdateAddHtlc *
update_add_htlc__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (UpdateAddHtlc *)
protobuf_c_message_unpack (&update_add_htlc__descriptor,
allocator, len, data);
}
void update_add_htlc__free_unpacked
(UpdateAddHtlc *message,
ProtobufCAllocator *allocator)
{
assert(message->base.descriptor == &update_add_htlc__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void update_complete_htlc__init
(UpdateCompleteHtlc *message)
{
static UpdateCompleteHtlc init_value = UPDATE_COMPLETE_HTLC__INIT;
*message = init_value;
}
size_t update_complete_htlc__get_packed_size
(const UpdateCompleteHtlc *message)
{
assert(message->base.descriptor == &update_complete_htlc__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t update_complete_htlc__pack
(const UpdateCompleteHtlc *message,
uint8_t *out)
{
assert(message->base.descriptor == &update_complete_htlc__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t update_complete_htlc__pack_to_buffer
(const UpdateCompleteHtlc *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &update_complete_htlc__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
UpdateCompleteHtlc *
update_complete_htlc__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (UpdateCompleteHtlc *)
protobuf_c_message_unpack (&update_complete_htlc__descriptor,
allocator, len, data);
}
void update_complete_htlc__free_unpacked
(UpdateCompleteHtlc *message,
ProtobufCAllocator *allocator)
{
assert(message->base.descriptor == &update_complete_htlc__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void update_remove_htlc__init
(UpdateRemoveHtlc *message)
{
static UpdateRemoveHtlc init_value = UPDATE_REMOVE_HTLC__INIT;
*message = init_value;
}
size_t update_remove_htlc__get_packed_size
(const UpdateRemoveHtlc *message)
{
assert(message->base.descriptor == &update_remove_htlc__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t update_remove_htlc__pack
(const UpdateRemoveHtlc *message,
uint8_t *out)
{
assert(message->base.descriptor == &update_remove_htlc__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t update_remove_htlc__pack_to_buffer
(const UpdateRemoveHtlc *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &update_remove_htlc__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
UpdateRemoveHtlc *
update_remove_htlc__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (UpdateRemoveHtlc *)
protobuf_c_message_unpack (&update_remove_htlc__descriptor,
allocator, len, data);
}
void update_remove_htlc__free_unpacked
(UpdateRemoveHtlc *message,
ProtobufCAllocator *allocator)
{
assert(message->base.descriptor == &update_remove_htlc__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void update_remove_htlc_delay__init
(UpdateRemoveHtlcDelay *message)
{
static UpdateRemoveHtlcDelay init_value = UPDATE_REMOVE_HTLC_DELAY__INIT;
*message = init_value;
}
size_t update_remove_htlc_delay__get_packed_size
(const UpdateRemoveHtlcDelay *message)
{
assert(message->base.descriptor == &update_remove_htlc_delay__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t update_remove_htlc_delay__pack
(const UpdateRemoveHtlcDelay *message,
uint8_t *out)
{
assert(message->base.descriptor == &update_remove_htlc_delay__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t update_remove_htlc_delay__pack_to_buffer
(const UpdateRemoveHtlcDelay *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &update_remove_htlc_delay__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
UpdateRemoveHtlcDelay *
update_remove_htlc_delay__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (UpdateRemoveHtlcDelay *)
protobuf_c_message_unpack (&update_remove_htlc_delay__descriptor,
allocator, len, data);
}
void update_remove_htlc_delay__free_unpacked
(UpdateRemoveHtlcDelay *message,
ProtobufCAllocator *allocator)
{
assert(message->base.descriptor == &update_remove_htlc_delay__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void update_accept__init
(UpdateAccept *message)
{
@ -1340,6 +1512,225 @@ const ProtobufCMessageDescriptor update__descriptor =
(ProtobufCMessageInit) update__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor update_add_htlc__field_descriptors[4] =
{
{
"revocation_hash",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(UpdateAddHtlc, revocation_hash),
&sha256_hash__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"amount",
2,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_UINT64,
0, /* quantifier_offset */
offsetof(UpdateAddHtlc, amount),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"r_hash",
3,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(UpdateAddHtlc, r_hash),
&sha256_hash__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"locktime",
4,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(UpdateAddHtlc, locktime),
&locktime__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned update_add_htlc__field_indices_by_name[] = {
1, /* field[1] = amount */
3, /* field[3] = locktime */
2, /* field[2] = r_hash */
0, /* field[0] = revocation_hash */
};
static const ProtobufCIntRange update_add_htlc__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 4 }
};
const ProtobufCMessageDescriptor update_add_htlc__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"update_add_htlc",
"UpdateAddHtlc",
"UpdateAddHtlc",
"",
sizeof(UpdateAddHtlc),
4,
update_add_htlc__field_descriptors,
update_add_htlc__field_indices_by_name,
1, update_add_htlc__number_ranges,
(ProtobufCMessageInit) update_add_htlc__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor update_complete_htlc__field_descriptors[2] =
{
{
"revocation_hash",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(UpdateCompleteHtlc, revocation_hash),
&sha256_hash__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"r",
3,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(UpdateCompleteHtlc, r),
&sha256_hash__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned update_complete_htlc__field_indices_by_name[] = {
1, /* field[1] = r */
0, /* field[0] = revocation_hash */
};
static const ProtobufCIntRange update_complete_htlc__number_ranges[2 + 1] =
{
{ 1, 0 },
{ 3, 1 },
{ 0, 2 }
};
const ProtobufCMessageDescriptor update_complete_htlc__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"update_complete_htlc",
"UpdateCompleteHtlc",
"UpdateCompleteHtlc",
"",
sizeof(UpdateCompleteHtlc),
2,
update_complete_htlc__field_descriptors,
update_complete_htlc__field_indices_by_name,
2, update_complete_htlc__number_ranges,
(ProtobufCMessageInit) update_complete_htlc__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor update_remove_htlc__field_descriptors[2] =
{
{
"revocation_hash",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(UpdateRemoveHtlc, revocation_hash),
&sha256_hash__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"r_hash",
3,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(UpdateRemoveHtlc, r_hash),
&sha256_hash__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned update_remove_htlc__field_indices_by_name[] = {
1, /* field[1] = r_hash */
0, /* field[0] = revocation_hash */
};
static const ProtobufCIntRange update_remove_htlc__number_ranges[2 + 1] =
{
{ 1, 0 },
{ 3, 1 },
{ 0, 2 }
};
const ProtobufCMessageDescriptor update_remove_htlc__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"update_remove_htlc",
"UpdateRemoveHtlc",
"UpdateRemoveHtlc",
"",
sizeof(UpdateRemoveHtlc),
2,
update_remove_htlc__field_descriptors,
update_remove_htlc__field_indices_by_name,
2, update_remove_htlc__number_ranges,
(ProtobufCMessageInit) update_remove_htlc__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor update_remove_htlc_delay__field_descriptors[1] =
{
{
"r_hash",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(UpdateRemoveHtlcDelay, r_hash),
&sha256_hash__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned update_remove_htlc_delay__field_indices_by_name[] = {
0, /* field[0] = r_hash */
};
static const ProtobufCIntRange update_remove_htlc_delay__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor update_remove_htlc_delay__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"update_remove_htlc_delay",
"UpdateRemoveHtlcDelay",
"UpdateRemoveHtlcDelay",
"",
sizeof(UpdateRemoveHtlcDelay),
1,
update_remove_htlc_delay__field_descriptors,
update_remove_htlc_delay__field_indices_by_name,
1, update_remove_htlc_delay__number_ranges,
(ProtobufCMessageInit) update_remove_htlc_delay__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor update_accept__field_descriptors[2] =
{
{
@ -1608,7 +1999,7 @@ const ProtobufCMessageDescriptor error__descriptor =
(ProtobufCMessageInit) error__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor pkt__field_descriptors[11] =
static const ProtobufCFieldDescriptor pkt__field_descriptors[15] =
{
{
"update",
@ -1623,11 +2014,23 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[11] =
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"update_accept",
"update_add_htlc",
2,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Pkt, pkt_case),
offsetof(Pkt, update_add_htlc),
&update_add_htlc__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"update_accept",
3,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Pkt, pkt_case),
offsetof(Pkt, update_accept),
&update_accept__descriptor,
NULL,
@ -1636,7 +2039,7 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[11] =
},
{
"update_signature",
3,
4,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Pkt, pkt_case),
@ -1648,7 +2051,7 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[11] =
},
{
"update_complete",
4,
5,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Pkt, pkt_case),
@ -1658,6 +2061,42 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[11] =
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"update_complete_htlc",
6,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Pkt, pkt_case),
offsetof(Pkt, update_complete_htlc),
&update_complete_htlc__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"update_remove_htlc",
7,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Pkt, pkt_case),
offsetof(Pkt, update_remove_htlc),
&update_remove_htlc__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"update_remove_htlc_delay",
8,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Pkt, pkt_case),
offsetof(Pkt, update_remove_htlc_delay),
&update_remove_htlc_delay__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"open",
201,
@ -1744,25 +2183,29 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[11] =
},
};
static const unsigned pkt__field_indices_by_name[] = {
8, /* field[8] = close */
9, /* field[9] = close_complete */
10, /* field[10] = error */
4, /* field[4] = open */
5, /* field[5] = open_anchor */
6, /* field[6] = open_commit_sig */
7, /* field[7] = open_complete */
12, /* field[12] = close */
13, /* field[13] = close_complete */
14, /* field[14] = error */
8, /* field[8] = open */
9, /* field[9] = open_anchor */
10, /* field[10] = open_commit_sig */
11, /* field[11] = open_complete */
0, /* field[0] = update */
1, /* field[1] = update_accept */
3, /* field[3] = update_complete */
2, /* field[2] = update_signature */
2, /* field[2] = update_accept */
1, /* field[1] = update_add_htlc */
4, /* field[4] = update_complete */
5, /* field[5] = update_complete_htlc */
6, /* field[6] = update_remove_htlc */
7, /* field[7] = update_remove_htlc_delay */
3, /* field[3] = update_signature */
};
static const ProtobufCIntRange pkt__number_ranges[4 + 1] =
{
{ 1, 0 },
{ 201, 4 },
{ 401, 8 },
{ 1000, 10 },
{ 0, 11 }
{ 201, 8 },
{ 401, 12 },
{ 1000, 14 },
{ 0, 15 }
};
const ProtobufCMessageDescriptor pkt__descriptor =
{
@ -1772,7 +2215,7 @@ const ProtobufCMessageDescriptor pkt__descriptor =
"Pkt",
"",
sizeof(Pkt),
11,
15,
pkt__field_descriptors,
pkt__field_indices_by_name,
4, pkt__number_ranges,

201
lightning.pb-c.h

@ -24,6 +24,10 @@ typedef struct _OpenAnchor OpenAnchor;
typedef struct _OpenCommitSig OpenCommitSig;
typedef struct _OpenComplete OpenComplete;
typedef struct _Update Update;
typedef struct _UpdateAddHtlc UpdateAddHtlc;
typedef struct _UpdateCompleteHtlc UpdateCompleteHtlc;
typedef struct _UpdateRemoveHtlc UpdateRemoveHtlc;
typedef struct _UpdateRemoveHtlcDelay UpdateRemoveHtlcDelay;
typedef struct _UpdateAccept UpdateAccept;
typedef struct _UpdateSignature UpdateSignature;
typedef struct _UpdateComplete UpdateComplete;
@ -229,9 +233,6 @@ struct _Update
/*
* Change in current payment to-me (implies reverse to-you).
*/
/*
* FIXME: optional HTLC ops.
*/
int64_t delta;
};
#define UPDATE__INIT \
@ -239,6 +240,94 @@ struct _Update
, NULL, 0 }
/*
* Start a new commitment tx to add an HTLC me -> you.
*/
struct _UpdateAddHtlc
{
ProtobufCMessage base;
/*
* Hash for which I will supply preimage to revoke this commitment tx.
*/
Sha256Hash *revocation_hash;
/*
* Amount for htlc
*/
uint64_t amount;
/*
* Hash for HTLC R value.
*/
Sha256Hash *r_hash;
/*
* Time at which HTLC expires (absolute)
*/
/*
* FIXME: Routing information.
*/
Locktime *locktime;
};
#define UPDATE_ADD_HTLC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&update_add_htlc__descriptor) \
, NULL, 0, NULL, NULL }
/*
* Complete an HTLC
*/
struct _UpdateCompleteHtlc
{
ProtobufCMessage base;
/*
* Hash for which I will supply preimage to revoke this commitment tx.
*/
Sha256Hash *revocation_hash;
/*
* HTLC R value.
*/
Sha256Hash *r;
};
#define UPDATE_COMPLETE_HTLC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&update_complete_htlc__descriptor) \
, NULL, NULL }
/*
* Remove an HTLC
*/
struct _UpdateRemoveHtlc
{
ProtobufCMessage base;
/*
* Hash for which I will supply preimage to revoke this commitment tx.
*/
Sha256Hash *revocation_hash;
/*
* Hash for HTLC R value.
*/
Sha256Hash *r_hash;
};
#define UPDATE_REMOVE_HTLC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&update_remove_htlc__descriptor) \
, NULL, NULL }
/*
* Respond to an HTLC remove request: not yet.
* Expect a remove_htlc later.
*/
struct _UpdateRemoveHtlcDelay
{
ProtobufCMessage base;
/*
* Hash for HTLC R value.
*/
Sha256Hash *r_hash;
};
#define UPDATE_REMOVE_HTLC_DELAY__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&update_remove_htlc_delay__descriptor) \
, NULL }
/*
* OK, I accept that update; here's your signature.
*/
@ -353,9 +442,13 @@ typedef enum {
PKT__PKT_OPEN_COMMIT_SIG = 203,
PKT__PKT_OPEN_COMPLETE = 204,
PKT__PKT_UPDATE = 1,
PKT__PKT_UPDATE_ACCEPT = 2,
PKT__PKT_UPDATE_SIGNATURE = 3,
PKT__PKT_UPDATE_COMPLETE = 4,
PKT__PKT_UPDATE_ADD_HTLC = 2,
PKT__PKT_UPDATE_ACCEPT = 3,
PKT__PKT_UPDATE_SIGNATURE = 4,
PKT__PKT_UPDATE_COMPLETE = 5,
PKT__PKT_UPDATE_COMPLETE_HTLC = 6,
PKT__PKT_UPDATE_REMOVE_HTLC = 7,
PKT__PKT_UPDATE_REMOVE_HTLC_DELAY = 8,
PKT__PKT_CLOSE = 401,
PKT__PKT_CLOSE_COMPLETE = 402,
PKT__PKT_ERROR = 1000,
@ -380,9 +473,13 @@ struct _Pkt
* Updating (most common)
*/
Update *update;
UpdateAddHtlc *update_add_htlc;
UpdateAccept *update_accept;
UpdateSignature *update_signature;
UpdateComplete *update_complete;
UpdateCompleteHtlc *update_complete_htlc;
UpdateRemoveHtlc *update_remove_htlc;
UpdateRemoveHtlcDelay *update_remove_htlc_delay;
/*
* Closing
*/
@ -570,6 +667,82 @@ Update *
void update__free_unpacked
(Update *message,
ProtobufCAllocator *allocator);
/* UpdateAddHtlc methods */
void update_add_htlc__init
(UpdateAddHtlc *message);
size_t update_add_htlc__get_packed_size
(const UpdateAddHtlc *message);
size_t update_add_htlc__pack
(const UpdateAddHtlc *message,
uint8_t *out);
size_t update_add_htlc__pack_to_buffer
(const UpdateAddHtlc *message,
ProtobufCBuffer *buffer);
UpdateAddHtlc *
update_add_htlc__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void update_add_htlc__free_unpacked
(UpdateAddHtlc *message,
ProtobufCAllocator *allocator);
/* UpdateCompleteHtlc methods */
void update_complete_htlc__init
(UpdateCompleteHtlc *message);
size_t update_complete_htlc__get_packed_size
(const UpdateCompleteHtlc *message);
size_t update_complete_htlc__pack
(const UpdateCompleteHtlc *message,
uint8_t *out);
size_t update_complete_htlc__pack_to_buffer
(const UpdateCompleteHtlc *message,
ProtobufCBuffer *buffer);
UpdateCompleteHtlc *
update_complete_htlc__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void update_complete_htlc__free_unpacked
(UpdateCompleteHtlc *message,
ProtobufCAllocator *allocator);
/* UpdateRemoveHtlc methods */
void update_remove_htlc__init
(UpdateRemoveHtlc *message);
size_t update_remove_htlc__get_packed_size
(const UpdateRemoveHtlc *message);
size_t update_remove_htlc__pack
(const UpdateRemoveHtlc *message,
uint8_t *out);
size_t update_remove_htlc__pack_to_buffer
(const UpdateRemoveHtlc *message,
ProtobufCBuffer *buffer);
UpdateRemoveHtlc *
update_remove_htlc__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void update_remove_htlc__free_unpacked
(UpdateRemoveHtlc *message,
ProtobufCAllocator *allocator);
/* UpdateRemoveHtlcDelay methods */
void update_remove_htlc_delay__init
(UpdateRemoveHtlcDelay *message);
size_t update_remove_htlc_delay__get_packed_size
(const UpdateRemoveHtlcDelay *message);
size_t update_remove_htlc_delay__pack
(const UpdateRemoveHtlcDelay *message,
uint8_t *out);
size_t update_remove_htlc_delay__pack_to_buffer
(const UpdateRemoveHtlcDelay *message,
ProtobufCBuffer *buffer);
UpdateRemoveHtlcDelay *
update_remove_htlc_delay__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void update_remove_htlc_delay__free_unpacked
(UpdateRemoveHtlcDelay *message,
ProtobufCAllocator *allocator);
/* UpdateAccept methods */
void update_accept__init
(UpdateAccept *message);
@ -732,6 +905,18 @@ typedef void (*OpenComplete_Closure)
typedef void (*Update_Closure)
(const Update *message,
void *closure_data);
typedef void (*UpdateAddHtlc_Closure)
(const UpdateAddHtlc *message,
void *closure_data);
typedef void (*UpdateCompleteHtlc_Closure)
(const UpdateCompleteHtlc *message,
void *closure_data);
typedef void (*UpdateRemoveHtlc_Closure)
(const UpdateRemoveHtlc *message,
void *closure_data);
typedef void (*UpdateRemoveHtlcDelay_Closure)
(const UpdateRemoveHtlcDelay *message,
void *closure_data);
typedef void (*UpdateAccept_Closure)
(const UpdateAccept *message,
void *closure_data);
@ -769,6 +954,10 @@ extern const ProtobufCMessageDescriptor open_anchor__descriptor;
extern const ProtobufCMessageDescriptor open_commit_sig__descriptor;
extern const ProtobufCMessageDescriptor open_complete__descriptor;
extern const ProtobufCMessageDescriptor update__descriptor;
extern const ProtobufCMessageDescriptor update_add_htlc__descriptor;
extern const ProtobufCMessageDescriptor update_complete_htlc__descriptor;
extern const ProtobufCMessageDescriptor update_remove_htlc__descriptor;
extern const ProtobufCMessageDescriptor update_remove_htlc_delay__descriptor;
extern const ProtobufCMessageDescriptor update_accept__descriptor;
extern const ProtobufCMessageDescriptor update_signature__descriptor;
extern const ProtobufCMessageDescriptor update_complete__descriptor;

51
lightning.proto

@ -35,7 +35,7 @@ message locktime {
message bitcoin_pubkey {
// Either 65 or 33 bytes.
required bytes key = 1;
};
}
//
// Packet Types
@ -98,10 +98,45 @@ message update {
required sha256_hash revocation_hash = 1;
// Change in current payment to-me (implies reverse to-you).
required sint64 delta = 2;
// FIXME: optional HTLC ops.
}
// OK, I accept that update; here's your signature.
// Start a new commitment tx to add an HTLC me -> you.
message update_add_htlc {
// Hash for which I will supply preimage to revoke this commitment tx.
required sha256_hash revocation_hash = 1;
// Amount for htlc
required uint64 amount = 2;
// Hash for HTLC R value.
required sha256_hash r_hash = 3;
// Time at which HTLC expires (absolute)
required locktime locktime = 4;
// FIXME: Routing information.
}
// Complete an HTLC
message update_complete_htlc {
// Hash for which I will supply preimage to revoke this commitment tx.
required sha256_hash revocation_hash = 1;
// HTLC R value.
required sha256_hash r = 3;
}
// Remove an HTLC
message update_remove_htlc {
// Hash for which I will supply preimage to revoke this commitment tx.
required sha256_hash revocation_hash = 1;
// Hash for HTLC R value.
required sha256_hash r_hash = 3;
}
// Respond to an HTLC remove request: not yet.
// Expect a remove_htlc later.
message update_remove_htlc_delay {
// Hash for HTLC R value.
required sha256_hash r_hash = 1;
}
// OK, I accept that update; here's your signature.
message update_accept {
// Signature for your new commitment tx.
required signature sig = 1;
@ -154,9 +189,13 @@ message pkt {
open_complete open_complete = 204;
// Updating (most common)
update update = 1;
update_accept update_accept = 2;
update_signature update_signature = 3;
update_complete update_complete = 4;
update_add_htlc update_add_htlc = 2;
update_accept update_accept = 3;
update_signature update_signature = 4;
update_complete update_complete = 5;
update_complete_htlc update_complete_htlc = 6;
update_remove_htlc update_remove_htlc = 7;
update_remove_htlc_delay update_remove_htlc_delay = 8;
// Closing
close_channel close = 401;
close_channel_complete close_complete = 402;

Loading…
Cancel
Save