Browse Source

protocol: rename update_complete_htlc to update_fulfill_htlc.

Complete was an overloaded word.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
31459d6cd2
  1. 74
      lightning.pb-c.c
  2. 44
      lightning.pb-c.h
  3. 4
      lightning.proto
  4. 4
      pkt.c
  5. 18
      state.c
  6. 6
      state.h
  7. 33
      state_types.h
  8. 6
      test-cli/gather_updates.c
  9. 12
      test/test_state_coverage.c

74
lightning.pb-c.c

@ -523,47 +523,47 @@ void update_decline_htlc__free_unpacked
assert(message->base.descriptor == &update_decline_htlc__descriptor); assert(message->base.descriptor == &update_decline_htlc__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
} }
void update_complete_htlc__init void update_fulfill_htlc__init
(UpdateCompleteHtlc *message) (UpdateFulfillHtlc *message)
{ {
static UpdateCompleteHtlc init_value = UPDATE_COMPLETE_HTLC__INIT; static UpdateFulfillHtlc init_value = UPDATE_FULFILL_HTLC__INIT;
*message = init_value; *message = init_value;
} }
size_t update_complete_htlc__get_packed_size size_t update_fulfill_htlc__get_packed_size
(const UpdateCompleteHtlc *message) (const UpdateFulfillHtlc *message)
{ {
assert(message->base.descriptor == &update_complete_htlc__descriptor); assert(message->base.descriptor == &update_fulfill_htlc__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
} }
size_t update_complete_htlc__pack size_t update_fulfill_htlc__pack
(const UpdateCompleteHtlc *message, (const UpdateFulfillHtlc *message,
uint8_t *out) uint8_t *out)
{ {
assert(message->base.descriptor == &update_complete_htlc__descriptor); assert(message->base.descriptor == &update_fulfill_htlc__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
} }
size_t update_complete_htlc__pack_to_buffer size_t update_fulfill_htlc__pack_to_buffer
(const UpdateCompleteHtlc *message, (const UpdateFulfillHtlc *message,
ProtobufCBuffer *buffer) ProtobufCBuffer *buffer)
{ {
assert(message->base.descriptor == &update_complete_htlc__descriptor); assert(message->base.descriptor == &update_fulfill_htlc__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
} }
UpdateCompleteHtlc * UpdateFulfillHtlc *
update_complete_htlc__unpack update_fulfill_htlc__unpack
(ProtobufCAllocator *allocator, (ProtobufCAllocator *allocator,
size_t len, size_t len,
const uint8_t *data) const uint8_t *data)
{ {
return (UpdateCompleteHtlc *) return (UpdateFulfillHtlc *)
protobuf_c_message_unpack (&update_complete_htlc__descriptor, protobuf_c_message_unpack (&update_fulfill_htlc__descriptor,
allocator, len, data); allocator, len, data);
} }
void update_complete_htlc__free_unpacked void update_fulfill_htlc__free_unpacked
(UpdateCompleteHtlc *message, (UpdateFulfillHtlc *message,
ProtobufCAllocator *allocator) ProtobufCAllocator *allocator)
{ {
assert(message->base.descriptor == &update_complete_htlc__descriptor); assert(message->base.descriptor == &update_fulfill_htlc__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
} }
void update_timedout_htlc__init void update_timedout_htlc__init
@ -1821,7 +1821,7 @@ const ProtobufCMessageDescriptor update_decline_htlc__descriptor =
(ProtobufCMessageInit) update_decline_htlc__init, (ProtobufCMessageInit) update_decline_htlc__init,
NULL,NULL,NULL /* reserved[123] */ NULL,NULL,NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor update_complete_htlc__field_descriptors[2] = static const ProtobufCFieldDescriptor update_fulfill_htlc__field_descriptors[2] =
{ {
{ {
"revocation_hash", "revocation_hash",
@ -1829,7 +1829,7 @@ static const ProtobufCFieldDescriptor update_complete_htlc__field_descriptors[2]
PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE, PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */ 0, /* quantifier_offset */
offsetof(UpdateCompleteHtlc, revocation_hash), offsetof(UpdateFulfillHtlc, revocation_hash),
&sha256_hash__descriptor, &sha256_hash__descriptor,
NULL, NULL,
0, /* flags */ 0, /* flags */
@ -1841,35 +1841,35 @@ static const ProtobufCFieldDescriptor update_complete_htlc__field_descriptors[2]
PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE, PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */ 0, /* quantifier_offset */
offsetof(UpdateCompleteHtlc, r), offsetof(UpdateFulfillHtlc, r),
&sha256_hash__descriptor, &sha256_hash__descriptor,
NULL, NULL,
0, /* flags */ 0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */ 0,NULL,NULL /* reserved1,reserved2, etc */
}, },
}; };
static const unsigned update_complete_htlc__field_indices_by_name[] = { static const unsigned update_fulfill_htlc__field_indices_by_name[] = {
1, /* field[1] = r */ 1, /* field[1] = r */
0, /* field[0] = revocation_hash */ 0, /* field[0] = revocation_hash */
}; };
static const ProtobufCIntRange update_complete_htlc__number_ranges[1 + 1] = static const ProtobufCIntRange update_fulfill_htlc__number_ranges[1 + 1] =
{ {
{ 1, 0 }, { 1, 0 },
{ 0, 2 } { 0, 2 }
}; };
const ProtobufCMessageDescriptor update_complete_htlc__descriptor = const ProtobufCMessageDescriptor update_fulfill_htlc__descriptor =
{ {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"update_complete_htlc", "update_fulfill_htlc",
"UpdateCompleteHtlc", "UpdateFulfillHtlc",
"UpdateCompleteHtlc", "UpdateFulfillHtlc",
"", "",
sizeof(UpdateCompleteHtlc), sizeof(UpdateFulfillHtlc),
2, 2,
update_complete_htlc__field_descriptors, update_fulfill_htlc__field_descriptors,
update_complete_htlc__field_indices_by_name, update_fulfill_htlc__field_indices_by_name,
1, update_complete_htlc__number_ranges, 1, update_fulfill_htlc__number_ranges,
(ProtobufCMessageInit) update_complete_htlc__init, (ProtobufCMessageInit) update_fulfill_htlc__init,
NULL,NULL,NULL /* reserved[123] */ NULL,NULL,NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor update_timedout_htlc__field_descriptors[2] = static const ProtobufCFieldDescriptor update_timedout_htlc__field_descriptors[2] =
@ -2334,13 +2334,13 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[17] =
0,NULL,NULL /* reserved1,reserved2, etc */ 0,NULL,NULL /* reserved1,reserved2, etc */
}, },
{ {
"update_complete_htlc", "update_fulfill_htlc",
7, 7,
PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE, PROTOBUF_C_TYPE_MESSAGE,
offsetof(Pkt, pkt_case), offsetof(Pkt, pkt_case),
offsetof(Pkt, update_complete_htlc), offsetof(Pkt, update_fulfill_htlc),
&update_complete_htlc__descriptor, &update_fulfill_htlc__descriptor,
NULL, NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */ 0,NULL,NULL /* reserved1,reserved2, etc */
@ -2479,8 +2479,8 @@ static const unsigned pkt__field_indices_by_name[] = {
2, /* field[2] = update_accept */ 2, /* field[2] = update_accept */
1, /* field[1] = update_add_htlc */ 1, /* field[1] = update_add_htlc */
4, /* field[4] = update_complete */ 4, /* field[4] = update_complete */
6, /* field[6] = update_complete_htlc */
5, /* field[5] = update_decline_htlc */ 5, /* field[5] = update_decline_htlc */
6, /* field[6] = update_fulfill_htlc */
8, /* field[8] = update_routefail_htlc */ 8, /* field[8] = update_routefail_htlc */
3, /* field[3] = update_signature */ 3, /* field[3] = update_signature */
7, /* field[7] = update_timedout_htlc */ 7, /* field[7] = update_timedout_htlc */

44
lightning.pb-c.h

@ -27,7 +27,7 @@ typedef struct _OpenComplete OpenComplete;
typedef struct _Update Update; typedef struct _Update Update;
typedef struct _UpdateAddHtlc UpdateAddHtlc; typedef struct _UpdateAddHtlc UpdateAddHtlc;
typedef struct _UpdateDeclineHtlc UpdateDeclineHtlc; typedef struct _UpdateDeclineHtlc UpdateDeclineHtlc;
typedef struct _UpdateCompleteHtlc UpdateCompleteHtlc; typedef struct _UpdateFulfillHtlc UpdateFulfillHtlc;
typedef struct _UpdateTimedoutHtlc UpdateTimedoutHtlc; typedef struct _UpdateTimedoutHtlc UpdateTimedoutHtlc;
typedef struct _UpdateRoutefailHtlc UpdateRoutefailHtlc; typedef struct _UpdateRoutefailHtlc UpdateRoutefailHtlc;
typedef struct _UpdateAccept UpdateAccept; typedef struct _UpdateAccept UpdateAccept;
@ -322,7 +322,7 @@ struct _UpdateDeclineHtlc
/* /*
* Complete your HTLC: I have the R value, pay me! * Complete your HTLC: I have the R value, pay me!
*/ */
struct _UpdateCompleteHtlc struct _UpdateFulfillHtlc
{ {
ProtobufCMessage base; ProtobufCMessage base;
/* /*
@ -334,8 +334,8 @@ struct _UpdateCompleteHtlc
*/ */
Sha256Hash *r; Sha256Hash *r;
}; };
#define UPDATE_COMPLETE_HTLC__INIT \ #define UPDATE_FULFILL_HTLC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&update_complete_htlc__descriptor) \ { PROTOBUF_C_MESSAGE_INIT (&update_fulfill_htlc__descriptor) \
, NULL, NULL } , NULL, NULL }
@ -510,7 +510,7 @@ typedef enum {
PKT__PKT_UPDATE_SIGNATURE = 4, PKT__PKT_UPDATE_SIGNATURE = 4,
PKT__PKT_UPDATE_COMPLETE = 5, PKT__PKT_UPDATE_COMPLETE = 5,
PKT__PKT_UPDATE_DECLINE_HTLC = 6, PKT__PKT_UPDATE_DECLINE_HTLC = 6,
PKT__PKT_UPDATE_COMPLETE_HTLC = 7, PKT__PKT_UPDATE_FULFILL_HTLC = 7,
PKT__PKT_UPDATE_TIMEDOUT_HTLC = 8, PKT__PKT_UPDATE_TIMEDOUT_HTLC = 8,
PKT__PKT_UPDATE_ROUTEFAIL_HTLC = 9, PKT__PKT_UPDATE_ROUTEFAIL_HTLC = 9,
PKT__PKT_CLOSE = 30, PKT__PKT_CLOSE = 30,
@ -543,7 +543,7 @@ struct _Pkt
UpdateSignature *update_signature; UpdateSignature *update_signature;
UpdateComplete *update_complete; UpdateComplete *update_complete;
UpdateDeclineHtlc *update_decline_htlc; UpdateDeclineHtlc *update_decline_htlc;
UpdateCompleteHtlc *update_complete_htlc; UpdateFulfillHtlc *update_fulfill_htlc;
UpdateTimedoutHtlc *update_timedout_htlc; UpdateTimedoutHtlc *update_timedout_htlc;
UpdateRoutefailHtlc *update_routefail_htlc; UpdateRoutefailHtlc *update_routefail_htlc;
/* /*
@ -791,24 +791,24 @@ UpdateDeclineHtlc *
void update_decline_htlc__free_unpacked void update_decline_htlc__free_unpacked
(UpdateDeclineHtlc *message, (UpdateDeclineHtlc *message,
ProtobufCAllocator *allocator); ProtobufCAllocator *allocator);
/* UpdateCompleteHtlc methods */ /* UpdateFulfillHtlc methods */
void update_complete_htlc__init void update_fulfill_htlc__init
(UpdateCompleteHtlc *message); (UpdateFulfillHtlc *message);
size_t update_complete_htlc__get_packed_size size_t update_fulfill_htlc__get_packed_size
(const UpdateCompleteHtlc *message); (const UpdateFulfillHtlc *message);
size_t update_complete_htlc__pack size_t update_fulfill_htlc__pack
(const UpdateCompleteHtlc *message, (const UpdateFulfillHtlc *message,
uint8_t *out); uint8_t *out);
size_t update_complete_htlc__pack_to_buffer size_t update_fulfill_htlc__pack_to_buffer
(const UpdateCompleteHtlc *message, (const UpdateFulfillHtlc *message,
ProtobufCBuffer *buffer); ProtobufCBuffer *buffer);
UpdateCompleteHtlc * UpdateFulfillHtlc *
update_complete_htlc__unpack update_fulfill_htlc__unpack
(ProtobufCAllocator *allocator, (ProtobufCAllocator *allocator,
size_t len, size_t len,
const uint8_t *data); const uint8_t *data);
void update_complete_htlc__free_unpacked void update_fulfill_htlc__free_unpacked
(UpdateCompleteHtlc *message, (UpdateFulfillHtlc *message,
ProtobufCAllocator *allocator); ProtobufCAllocator *allocator);
/* UpdateTimedoutHtlc methods */ /* UpdateTimedoutHtlc methods */
void update_timedout_htlc__init void update_timedout_htlc__init
@ -1038,8 +1038,8 @@ typedef void (*UpdateAddHtlc_Closure)
typedef void (*UpdateDeclineHtlc_Closure) typedef void (*UpdateDeclineHtlc_Closure)
(const UpdateDeclineHtlc *message, (const UpdateDeclineHtlc *message,
void *closure_data); void *closure_data);
typedef void (*UpdateCompleteHtlc_Closure) typedef void (*UpdateFulfillHtlc_Closure)
(const UpdateCompleteHtlc *message, (const UpdateFulfillHtlc *message,
void *closure_data); void *closure_data);
typedef void (*UpdateTimedoutHtlc_Closure) typedef void (*UpdateTimedoutHtlc_Closure)
(const UpdateTimedoutHtlc *message, (const UpdateTimedoutHtlc *message,
@ -1090,7 +1090,7 @@ extern const ProtobufCMessageDescriptor open_complete__descriptor;
extern const ProtobufCMessageDescriptor update__descriptor; extern const ProtobufCMessageDescriptor update__descriptor;
extern const ProtobufCMessageDescriptor update_add_htlc__descriptor; extern const ProtobufCMessageDescriptor update_add_htlc__descriptor;
extern const ProtobufCMessageDescriptor update_decline_htlc__descriptor; extern const ProtobufCMessageDescriptor update_decline_htlc__descriptor;
extern const ProtobufCMessageDescriptor update_complete_htlc__descriptor; extern const ProtobufCMessageDescriptor update_fulfill_htlc__descriptor;
extern const ProtobufCMessageDescriptor update_timedout_htlc__descriptor; extern const ProtobufCMessageDescriptor update_timedout_htlc__descriptor;
extern const ProtobufCMessageDescriptor update_routefail_htlc__descriptor; extern const ProtobufCMessageDescriptor update_routefail_htlc__descriptor;
extern const ProtobufCMessageDescriptor update_accept__descriptor; extern const ProtobufCMessageDescriptor update_accept__descriptor;

4
lightning.proto

@ -132,7 +132,7 @@ message update_decline_htlc {
} }
// Complete your HTLC: I have the R value, pay me! // Complete your HTLC: I have the R value, pay me!
message update_complete_htlc { message update_fulfill_htlc {
// Hash for which I will supply preimage to revoke this commitment tx. // Hash for which I will supply preimage to revoke this commitment tx.
required sha256_hash revocation_hash = 1; required sha256_hash revocation_hash = 1;
// HTLC R value. // HTLC R value.
@ -217,7 +217,7 @@ message pkt {
update_signature update_signature = 4; update_signature update_signature = 4;
update_complete update_complete = 5; update_complete update_complete = 5;
update_decline_htlc update_decline_htlc = 6; update_decline_htlc update_decline_htlc = 6;
update_complete_htlc update_complete_htlc = 7; update_fulfill_htlc update_fulfill_htlc = 7;
update_timedout_htlc update_timedout_htlc = 8; update_timedout_htlc update_timedout_htlc = 8;
update_routefail_htlc update_routefail_htlc = 9; update_routefail_htlc update_routefail_htlc = 9;
// Closing // Closing

4
pkt.c

@ -167,12 +167,12 @@ struct pkt *update_htlc_complete_pkt(const tal_t *ctx,
const struct sha256 *revocation_hash, const struct sha256 *revocation_hash,
const struct sha256 *rval) const struct sha256 *rval)
{ {
UpdateCompleteHtlc u = UPDATE_COMPLETE_HTLC__INIT; UpdateFulfillHtlc u = UPDATE_FULFILL_HTLC__INIT;
u.revocation_hash = sha256_to_proto(ctx, revocation_hash); u.revocation_hash = sha256_to_proto(ctx, revocation_hash);
u.r = sha256_to_proto(ctx, rval); u.r = sha256_to_proto(ctx, rval);
return to_pkt(ctx, PKT__PKT_UPDATE_COMPLETE_HTLC, &u); return to_pkt(ctx, PKT__PKT_UPDATE_FULFILL_HTLC, &u);
} }
struct pkt *update_htlc_timedout_pkt(const tal_t *ctx, struct pkt *update_htlc_timedout_pkt(const tal_t *ctx,

18
state.c

@ -312,10 +312,10 @@ enum state state(const enum state state, const struct state_data *sdata,
set_effect(effect, send, set_effect(effect, send,
pkt_htlc_update(effect, sdata, idata->cmd)); pkt_htlc_update(effect, sdata, idata->cmd));
return prio(state, STATE_WAIT_FOR_HTLC_ACCEPT); return prio(state, STATE_WAIT_FOR_HTLC_ACCEPT);
} else if (input_is(input, CMD_SEND_HTLC_COMPLETE)) { } else if (input_is(input, CMD_SEND_HTLC_FULFILL)) {
/* We are to send an HTLC complete. */ /* We are to send an HTLC fulfill. */
set_effect(effect, send, set_effect(effect, send,
pkt_htlc_complete(effect, sdata, idata->cmd)); pkt_htlc_fulfill(effect, sdata, idata->cmd));
return prio(state, STATE_WAIT_FOR_HTLC_ACCEPT); return prio(state, STATE_WAIT_FOR_HTLC_ACCEPT);
} else if (input_is(input, CMD_SEND_HTLC_TIMEDOUT)) { } else if (input_is(input, CMD_SEND_HTLC_TIMEDOUT)) {
/* We are to send an HTLC timedout. */ /* We are to send an HTLC timedout. */
@ -332,8 +332,8 @@ enum state state(const enum state state, const struct state_data *sdata,
goto start_closing; goto start_closing;
} else if (input_is(input, PKT_UPDATE_ADD_HTLC)) { } else if (input_is(input, PKT_UPDATE_ADD_HTLC)) {
goto accept_htlc_update; goto accept_htlc_update;
} else if (input_is(input, PKT_UPDATE_COMPLETE_HTLC)) { } else if (input_is(input, PKT_UPDATE_FULFILL_HTLC)) {
goto accept_htlc_complete; goto accept_htlc_fulfill;
} else if (input_is(input, PKT_UPDATE_TIMEDOUT_HTLC)) { } else if (input_is(input, PKT_UPDATE_TIMEDOUT_HTLC)) {
goto accept_htlc_timedout; goto accept_htlc_timedout;
} else if (input_is(input, PKT_UPDATE_ROUTEFAIL_HTLC)) { } else if (input_is(input, PKT_UPDATE_ROUTEFAIL_HTLC)) {
@ -365,14 +365,14 @@ enum state state(const enum state state, const struct state_data *sdata,
/* Otherwise, process their request first: defer ours */ /* Otherwise, process their request first: defer ours */
requeue_cmd(effect, CMD_SEND_UPDATE_ANY); requeue_cmd(effect, CMD_SEND_UPDATE_ANY);
goto accept_htlc_update; goto accept_htlc_update;
} else if (input_is(input, PKT_UPDATE_COMPLETE_HTLC)) { } else if (input_is(input, PKT_UPDATE_FULFILL_HTLC)) {
/* If we're high priority, ignore their packet */ /* If we're high priority, ignore their packet */
if (high_priority(state)) if (high_priority(state))
return state; return state;
/* Otherwise, process their request first: defer ours */ /* Otherwise, process their request first: defer ours */
requeue_cmd(effect, CMD_SEND_UPDATE_ANY); requeue_cmd(effect, CMD_SEND_UPDATE_ANY);
goto accept_htlc_complete; goto accept_htlc_fulfill;
} else if (input_is(input, PKT_UPDATE_TIMEDOUT_HTLC)) { } else if (input_is(input, PKT_UPDATE_TIMEDOUT_HTLC)) {
/* If we're high priority, ignore their packet */ /* If we're high priority, ignore their packet */
if (high_priority(state)) if (high_priority(state))
@ -743,8 +743,8 @@ accept_htlc_timedout:
set_effect(effect, send, pkt_update_accept(effect, sdata)); set_effect(effect, send, pkt_update_accept(effect, sdata));
return prio(state, STATE_WAIT_FOR_UPDATE_SIG); return prio(state, STATE_WAIT_FOR_UPDATE_SIG);
accept_htlc_complete: accept_htlc_fulfill:
err = accept_pkt_htlc_complete(effect, sdata, idata->pkt); err = accept_pkt_htlc_fulfill(effect, sdata, idata->pkt);
if (err) if (err)
goto err_start_unilateral_close; goto err_start_unilateral_close;
set_effect(effect, send, pkt_update_accept(effect, sdata)); set_effect(effect, send, pkt_update_accept(effect, sdata));

6
state.h

@ -80,7 +80,7 @@ static inline bool input_is(enum state_input a, enum state_input b)
if (b == CMD_SEND_UPDATE_ANY) { if (b == CMD_SEND_UPDATE_ANY) {
/* Single | here, we want to record all. */ /* Single | here, we want to record all. */
return input_is(a, CMD_SEND_HTLC_UPDATE) return input_is(a, CMD_SEND_HTLC_UPDATE)
| input_is(a, CMD_SEND_HTLC_COMPLETE) | input_is(a, CMD_SEND_HTLC_FULFILL)
| input_is(a, CMD_SEND_HTLC_TIMEDOUT) | input_is(a, CMD_SEND_HTLC_TIMEDOUT)
| input_is(a, CMD_SEND_HTLC_ROUTEFAIL); | input_is(a, CMD_SEND_HTLC_ROUTEFAIL);
} }
@ -98,7 +98,7 @@ Pkt *pkt_anchor(const tal_t *ctx, const struct state_data *sdata);
Pkt *pkt_open_commit_sig(const tal_t *ctx, const struct state_data *sdata); Pkt *pkt_open_commit_sig(const tal_t *ctx, const struct state_data *sdata);
Pkt *pkt_open_complete(const tal_t *ctx, const struct state_data *sdata); Pkt *pkt_open_complete(const tal_t *ctx, const struct state_data *sdata);
Pkt *pkt_htlc_update(const tal_t *ctx, const struct state_data *sdata, void *data); Pkt *pkt_htlc_update(const tal_t *ctx, const struct state_data *sdata, void *data);
Pkt *pkt_htlc_complete(const tal_t *ctx, const struct state_data *sdata, void *data); Pkt *pkt_htlc_fulfill(const tal_t *ctx, const struct state_data *sdata, void *data);
Pkt *pkt_htlc_timedout(const tal_t *ctx, const struct state_data *sdata, void *data); Pkt *pkt_htlc_timedout(const tal_t *ctx, const struct state_data *sdata, void *data);
Pkt *pkt_htlc_routefail(const tal_t *ctx, const struct state_data *sdata, void *data); Pkt *pkt_htlc_routefail(const tal_t *ctx, const struct state_data *sdata, void *data);
Pkt *pkt_update_accept(const tal_t *ctx, const struct state_data *sdata); Pkt *pkt_update_accept(const tal_t *ctx, const struct state_data *sdata);
@ -132,7 +132,7 @@ Pkt *accept_pkt_htlc_routefail(struct state_effect *effect,
Pkt *accept_pkt_htlc_timedout(struct state_effect *effect, Pkt *accept_pkt_htlc_timedout(struct state_effect *effect,
const struct state_data *sdata, const Pkt *pkt); const struct state_data *sdata, const Pkt *pkt);
Pkt *accept_pkt_htlc_complete(struct state_effect *effect, Pkt *accept_pkt_htlc_fulfill(struct state_effect *effect,
const struct state_data *sdata, const Pkt *pkt); const struct state_data *sdata, const Pkt *pkt);
Pkt *accept_pkt_update_accept(struct state_effect *effect, Pkt *accept_pkt_update_accept(struct state_effect *effect,

33
state_types.h

@ -134,25 +134,44 @@ enum state {
}; };
enum state_input { enum state_input {
/* Packet inputs. */ /*
* Packet inputs.
*/
PKT_OPEN = PKT__PKT_OPEN, PKT_OPEN = PKT__PKT_OPEN,
PKT_OPEN_ANCHOR = PKT__PKT_OPEN_ANCHOR, PKT_OPEN_ANCHOR = PKT__PKT_OPEN_ANCHOR,
PKT_OPEN_COMMIT_SIG = PKT__PKT_OPEN_COMMIT_SIG, PKT_OPEN_COMMIT_SIG = PKT__PKT_OPEN_COMMIT_SIG,
PKT_OPEN_COMPLETE = PKT__PKT_OPEN_COMPLETE, PKT_OPEN_COMPLETE = PKT__PKT_OPEN_COMPLETE,
/* Updating the commit transaction: new HTLC */
PKT_UPDATE_ADD_HTLC = PKT__PKT_UPDATE_ADD_HTLC, PKT_UPDATE_ADD_HTLC = PKT__PKT_UPDATE_ADD_HTLC,
PKT_UPDATE_ACCEPT = PKT__PKT_UPDATE_ACCEPT, /* Updating the commit transaction: I have your R value! */
PKT_UPDATE_SIGNATURE = PKT__PKT_UPDATE_SIGNATURE, PKT_UPDATE_FULFILL_HTLC = PKT__PKT_UPDATE_FULFILL_HTLC,
PKT_UPDATE_COMPLETE = PKT__PKT_UPDATE_COMPLETE, /* Updating the commit transaction: my HTLC timed out! */
PKT_UPDATE_COMPLETE_HTLC = PKT__PKT_UPDATE_COMPLETE_HTLC,
PKT_UPDATE_TIMEDOUT_HTLC = PKT__PKT_UPDATE_TIMEDOUT_HTLC, PKT_UPDATE_TIMEDOUT_HTLC = PKT__PKT_UPDATE_TIMEDOUT_HTLC,
/* Updating the commit transaction: your HTLC failed upstream */
PKT_UPDATE_ROUTEFAIL_HTLC = PKT__PKT_UPDATE_ROUTEFAIL_HTLC, PKT_UPDATE_ROUTEFAIL_HTLC = PKT__PKT_UPDATE_ROUTEFAIL_HTLC,
/* Update replies: */
PKT_UPDATE_ACCEPT = PKT__PKT_UPDATE_ACCEPT,
/* Only for PKT_UPDATE_ADD_HTLC. */
PKT_UPDATE_DECLINE_HTLC = PKT__PKT_UPDATE_DECLINE_HTLC, PKT_UPDATE_DECLINE_HTLC = PKT__PKT_UPDATE_DECLINE_HTLC,
/* Reply to PKT_UPDATE_ACCEPT */
PKT_UPDATE_SIGNATURE = PKT__PKT_UPDATE_SIGNATURE,
/* Reply to PKT_UPDATE_SIGNATURE */
PKT_UPDATE_COMPLETE = PKT__PKT_UPDATE_COMPLETE,
/* Mutual close sequence. */
PKT_CLOSE = PKT__PKT_CLOSE, PKT_CLOSE = PKT__PKT_CLOSE,
PKT_CLOSE_COMPLETE = PKT__PKT_CLOSE_COMPLETE, PKT_CLOSE_COMPLETE = PKT__PKT_CLOSE_COMPLETE,
PKT_CLOSE_ACK = PKT__PKT_CLOSE_ACK, PKT_CLOSE_ACK = PKT__PKT_CLOSE_ACK,
/* Something unexpected went wrong. */
PKT_ERROR = PKT__PKT_ERROR, PKT_ERROR = PKT__PKT_ERROR,
/* Non-packet inputs. */ /*
* Non-packet inputs.
*/
INPUT_NONE, INPUT_NONE,
/* /*
@ -187,7 +206,7 @@ enum state_input {
/* Commands */ /* Commands */
CMD_SEND_HTLC_UPDATE, CMD_SEND_HTLC_UPDATE,
CMD_SEND_HTLC_COMPLETE, CMD_SEND_HTLC_FULFILL,
CMD_SEND_HTLC_TIMEDOUT, CMD_SEND_HTLC_TIMEDOUT,
CMD_SEND_HTLC_ROUTEFAIL, CMD_SEND_HTLC_ROUTEFAIL,
CMD_CLOSE, CMD_CLOSE,

6
test-cli/gather_updates.c

@ -228,12 +228,12 @@ struct channel_state *gather_updates(const tal_t *ctx,
our_rhash, their_rhash); our_rhash, their_rhash);
break; break;
case PKT__PKT_UPDATE_COMPLETE_HTLC: { case PKT__PKT_UPDATE_FULFILL_HTLC: {
struct sha256 r_hash, r_val; struct sha256 r_hash, r_val;
Sha256Hash *rh; Sha256Hash *rh;
/* Get hash, to find the HTLC. */ /* Get hash, to find the HTLC. */
proto_to_sha256(pkt->update_complete_htlc->r, &r_val); proto_to_sha256(pkt->update_fulfill_htlc->r, &r_val);
sha256(&r_hash, &r_val, sizeof(r_val)); sha256(&r_hash, &r_val, sizeof(r_val));
rh = sha256_to_proto(ctx, &r_hash); rh = sha256_to_proto(ctx, &r_hash);
@ -260,7 +260,7 @@ struct channel_state *gather_updates(const tal_t *ctx,
(long long)amount, *argv); (long long)amount, *argv);
remove_htlc(&cstate->b, n); remove_htlc(&cstate->b, n);
} }
update_rhash(pkt->update_complete_htlc->revocation_hash, update_rhash(pkt->update_fulfill_htlc->revocation_hash,
received, num_updates, received, num_updates,
&old_our_rhash, &old_their_rhash, &old_our_rhash, &old_their_rhash,
our_rhash, their_rhash); our_rhash, their_rhash);

12
test/test_state_coverage.c

@ -232,9 +232,9 @@ Pkt *pkt_htlc_update(const tal_t *ctx, const struct state_data *sdata, void *dat
return new_pkt(ctx, PKT_UPDATE_ADD_HTLC); return new_pkt(ctx, PKT_UPDATE_ADD_HTLC);
} }
Pkt *pkt_htlc_complete(const tal_t *ctx, const struct state_data *sdata, void *data) Pkt *pkt_htlc_fulfill(const tal_t *ctx, const struct state_data *sdata, void *data)
{ {
return new_pkt(ctx, PKT_UPDATE_COMPLETE_HTLC); return new_pkt(ctx, PKT_UPDATE_FULFILL_HTLC);
} }
Pkt *pkt_htlc_timedout(const tal_t *ctx, const struct state_data *sdata, void *data) Pkt *pkt_htlc_timedout(const tal_t *ctx, const struct state_data *sdata, void *data)
@ -323,7 +323,7 @@ Pkt *accept_pkt_htlc_timedout(struct state_effect *effect, const struct state_da
return NULL; return NULL;
} }
Pkt *accept_pkt_htlc_complete(struct state_effect *effect, const struct state_data *sdata, const Pkt *pkt) Pkt *accept_pkt_htlc_fulfill(struct state_effect *effect, const struct state_data *sdata, const Pkt *pkt)
{ {
return NULL; return NULL;
} }
@ -633,7 +633,7 @@ static bool is_current_command(const struct state_data *sdata,
{ {
if (cmd == CMD_SEND_UPDATE_ANY) { if (cmd == CMD_SEND_UPDATE_ANY) {
return is_current_command(sdata, CMD_SEND_HTLC_UPDATE) return is_current_command(sdata, CMD_SEND_HTLC_UPDATE)
|| is_current_command(sdata, CMD_SEND_HTLC_COMPLETE) || is_current_command(sdata, CMD_SEND_HTLC_FULFILL)
|| is_current_command(sdata, CMD_SEND_HTLC_TIMEDOUT) || is_current_command(sdata, CMD_SEND_HTLC_TIMEDOUT)
|| is_current_command(sdata, CMD_SEND_HTLC_ROUTEFAIL); || is_current_command(sdata, CMD_SEND_HTLC_ROUTEFAIL);
} }
@ -827,7 +827,7 @@ static bool normal_path(enum state_input i, enum state src, enum state dst)
/* These clutter the graph, so only handle from normal state. */ /* These clutter the graph, so only handle from normal state. */
static bool too_cluttered(enum state_input i, enum state src) static bool too_cluttered(enum state_input i, enum state src)
{ {
if (i == CMD_CLOSE || i == PKT_CLOSE || i == PKT_UPDATE_ADD_HTLC || i == PKT_UPDATE_COMPLETE_HTLC) if (i == CMD_CLOSE || i == PKT_CLOSE || i == PKT_UPDATE_ADD_HTLC || i == PKT_UPDATE_FULFILL_HTLC)
return src != STATE_NORMAL_LOWPRIO return src != STATE_NORMAL_LOWPRIO
&& src != STATE_NORMAL_HIGHPRIO; && src != STATE_NORMAL_HIGHPRIO;
return false; return false;
@ -1105,7 +1105,7 @@ static struct trail *run_peer(const struct state_data *sdata,
size_t i; size_t i;
static const enum state_input cmds[] static const enum state_input cmds[]
= { CMD_SEND_HTLC_UPDATE, = { CMD_SEND_HTLC_UPDATE,
CMD_SEND_HTLC_COMPLETE, CMD_SEND_HTLC_FULFILL,
CMD_SEND_HTLC_TIMEDOUT, CMD_SEND_HTLC_TIMEDOUT,
CMD_SEND_HTLC_ROUTEFAIL, CMD_SEND_HTLC_ROUTEFAIL,
CMD_CLOSE }; CMD_CLOSE };

Loading…
Cancel
Save