mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
patch remove-timeout.patch
This commit is contained in:
parent
1f9103c9d3
commit
cb0cc80984
@ -162,19 +162,6 @@ Pkt *pkt_htlc_fulfill(const tal_t *ctx, const struct peer *peer,
|
||||
return make_pkt(ctx, PKT__PKT_UPDATE_FULFILL_HTLC, f);
|
||||
}
|
||||
|
||||
Pkt *pkt_htlc_timedout(const tal_t *ctx, const struct peer *peer,
|
||||
const struct htlc_progress *htlc_prog)
|
||||
{
|
||||
UpdateTimedoutHtlc *t = tal(ctx, UpdateTimedoutHtlc);
|
||||
|
||||
update_timedout_htlc__init(t);
|
||||
|
||||
t->revocation_hash = sha256_to_proto(t, &htlc_prog->our_revocation_hash);
|
||||
t->r_hash = sha256_to_proto(t, &htlc_prog->htlc->rhash);
|
||||
|
||||
return make_pkt(ctx, PKT__PKT_UPDATE_TIMEDOUT_HTLC, t);
|
||||
}
|
||||
|
||||
Pkt *pkt_htlc_fail(const tal_t *ctx, const struct peer *peer,
|
||||
const struct htlc_progress *htlc_prog)
|
||||
{
|
||||
@ -551,62 +538,6 @@ fail:
|
||||
return err;
|
||||
}
|
||||
|
||||
Pkt *accept_pkt_htlc_timedout(const tal_t *ctx,
|
||||
struct peer *peer, const Pkt *pkt)
|
||||
{
|
||||
const UpdateTimedoutHtlc *t = pkt->update_timedout_htlc;
|
||||
struct htlc_progress *cur = tal(peer, struct htlc_progress);
|
||||
Pkt *err;
|
||||
size_t i;
|
||||
struct sha256 rhash;
|
||||
|
||||
proto_to_sha256(t->revocation_hash, &cur->their_revocation_hash);
|
||||
proto_to_sha256(t->r_hash, &rhash);
|
||||
|
||||
i = funding_find_htlc(&peer->cstate->a, &rhash);
|
||||
if (i == tal_count(peer->cstate->a.htlcs)) {
|
||||
err = pkt_err(ctx, "Unknown HTLC");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
cur->htlc = tal_dup(cur, struct channel_htlc, &peer->cstate->a.htlcs[i]);
|
||||
|
||||
/* Do we agree it has timed out? */
|
||||
if (controlled_time().ts.tv_sec < abs_locktime_to_seconds(&cur->htlc->expiry)) {
|
||||
err = pkt_err(ctx, "HTLC has not yet expired!");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Removing it should not fail: we regain HTLC amount */
|
||||
cur->cstate = copy_funding(cur, peer->cstate);
|
||||
if (!funding_delta(peer->us.offer_anchor == CMD_OPEN_WITH_ANCHOR,
|
||||
peer->anchor.satoshis,
|
||||
0, -cur->htlc->msatoshis,
|
||||
&cur->cstate->a, &cur->cstate->b)) {
|
||||
fatal("Unexpected failure fulfilling HTLC of %"PRIu64
|
||||
" milli-satoshis", cur->htlc->msatoshis);
|
||||
}
|
||||
funding_remove_htlc(&cur->cstate->a, i);
|
||||
/* FIXME: Remove timer. */
|
||||
|
||||
peer_get_revocation_hash(peer, peer->commit_tx_counter+1,
|
||||
&cur->our_revocation_hash);
|
||||
|
||||
/* Now we create the commit tx pair. */
|
||||
make_commit_txs(cur, peer, &cur->our_revocation_hash,
|
||||
&cur->their_revocation_hash,
|
||||
cur->cstate,
|
||||
&cur->our_commit, &cur->their_commit);
|
||||
|
||||
assert(!peer->current_htlc);
|
||||
peer->current_htlc = cur;
|
||||
return NULL;
|
||||
|
||||
fail:
|
||||
tal_free(cur);
|
||||
return err;
|
||||
}
|
||||
|
||||
Pkt *accept_pkt_htlc_fulfill(const tal_t *ctx,
|
||||
struct peer *peer, const Pkt *pkt)
|
||||
{
|
||||
|
@ -1334,7 +1334,7 @@ static void check_htlc_expiry(struct peer *peer, void *unused)
|
||||
funding_remove_htlc(&cstate->b, i);
|
||||
|
||||
set_htlc_command(peer, cstate, NULL, htlc,
|
||||
CMD_SEND_HTLC_TIMEDOUT, NULL);
|
||||
CMD_SEND_HTLC_FAIL, NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
146
lightning.pb-c.c
146
lightning.pb-c.c
@ -566,49 +566,6 @@ void update_fulfill_htlc__free_unpacked
|
||||
assert(message->base.descriptor == &update_fulfill_htlc__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void update_timedout_htlc__init
|
||||
(UpdateTimedoutHtlc *message)
|
||||
{
|
||||
static UpdateTimedoutHtlc init_value = UPDATE_TIMEDOUT_HTLC__INIT;
|
||||
*message = init_value;
|
||||
}
|
||||
size_t update_timedout_htlc__get_packed_size
|
||||
(const UpdateTimedoutHtlc *message)
|
||||
{
|
||||
assert(message->base.descriptor == &update_timedout_htlc__descriptor);
|
||||
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
|
||||
}
|
||||
size_t update_timedout_htlc__pack
|
||||
(const UpdateTimedoutHtlc *message,
|
||||
uint8_t *out)
|
||||
{
|
||||
assert(message->base.descriptor == &update_timedout_htlc__descriptor);
|
||||
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
|
||||
}
|
||||
size_t update_timedout_htlc__pack_to_buffer
|
||||
(const UpdateTimedoutHtlc *message,
|
||||
ProtobufCBuffer *buffer)
|
||||
{
|
||||
assert(message->base.descriptor == &update_timedout_htlc__descriptor);
|
||||
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
|
||||
}
|
||||
UpdateTimedoutHtlc *
|
||||
update_timedout_htlc__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data)
|
||||
{
|
||||
return (UpdateTimedoutHtlc *)
|
||||
protobuf_c_message_unpack (&update_timedout_htlc__descriptor,
|
||||
allocator, len, data);
|
||||
}
|
||||
void update_timedout_htlc__free_unpacked
|
||||
(UpdateTimedoutHtlc *message,
|
||||
ProtobufCAllocator *allocator)
|
||||
{
|
||||
assert(message->base.descriptor == &update_timedout_htlc__descriptor);
|
||||
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
|
||||
}
|
||||
void update_fail_htlc__init
|
||||
(UpdateFailHtlc *message)
|
||||
{
|
||||
@ -1872,57 +1829,6 @@ const ProtobufCMessageDescriptor update_fulfill_htlc__descriptor =
|
||||
(ProtobufCMessageInit) update_fulfill_htlc__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor update_timedout_htlc__field_descriptors[2] =
|
||||
{
|
||||
{
|
||||
"revocation_hash",
|
||||
1,
|
||||
PROTOBUF_C_LABEL_REQUIRED,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(UpdateTimedoutHtlc, revocation_hash),
|
||||
&sha256_hash__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"r_hash",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_REQUIRED,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(UpdateTimedoutHtlc, r_hash),
|
||||
&sha256_hash__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned update_timedout_htlc__field_indices_by_name[] = {
|
||||
1, /* field[1] = r_hash */
|
||||
0, /* field[0] = revocation_hash */
|
||||
};
|
||||
static const ProtobufCIntRange update_timedout_htlc__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 2 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor update_timedout_htlc__descriptor =
|
||||
{
|
||||
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
|
||||
"update_timedout_htlc",
|
||||
"UpdateTimedoutHtlc",
|
||||
"UpdateTimedoutHtlc",
|
||||
"",
|
||||
sizeof(UpdateTimedoutHtlc),
|
||||
2,
|
||||
update_timedout_htlc__field_descriptors,
|
||||
update_timedout_htlc__field_indices_by_name,
|
||||
1, update_timedout_htlc__number_ranges,
|
||||
(ProtobufCMessageInit) update_timedout_htlc__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor update_fail_htlc__field_descriptors[2] =
|
||||
{
|
||||
{
|
||||
@ -2259,7 +2165,7 @@ const ProtobufCMessageDescriptor error__descriptor =
|
||||
(ProtobufCMessageInit) error__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor pkt__field_descriptors[17] =
|
||||
static const ProtobufCFieldDescriptor pkt__field_descriptors[16] =
|
||||
{
|
||||
{
|
||||
"update_add_htlc",
|
||||
@ -2333,18 +2239,6 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[17] =
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"update_timedout_htlc",
|
||||
8,
|
||||
PROTOBUF_C_LABEL_OPTIONAL,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
offsetof(Pkt, pkt_case),
|
||||
offsetof(Pkt, update_timedout_htlc),
|
||||
&update_timedout_htlc__descriptor,
|
||||
NULL,
|
||||
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"update_fail_htlc",
|
||||
9,
|
||||
@ -2467,32 +2361,32 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[17] =
|
||||
},
|
||||
};
|
||||
static const unsigned pkt__field_indices_by_name[] = {
|
||||
16, /* field[16] = auth */
|
||||
12, /* field[12] = close */
|
||||
14, /* field[14] = close_ack */
|
||||
13, /* field[13] = close_complete */
|
||||
15, /* field[15] = error */
|
||||
8, /* field[8] = open */
|
||||
9, /* field[9] = open_anchor */
|
||||
10, /* field[10] = open_commit_sig */
|
||||
11, /* field[11] = open_complete */
|
||||
15, /* field[15] = auth */
|
||||
11, /* field[11] = close */
|
||||
13, /* field[13] = close_ack */
|
||||
12, /* field[12] = close_complete */
|
||||
14, /* field[14] = error */
|
||||
7, /* field[7] = open */
|
||||
8, /* field[8] = open_anchor */
|
||||
9, /* field[9] = open_commit_sig */
|
||||
10, /* field[10] = open_complete */
|
||||
1, /* field[1] = update_accept */
|
||||
0, /* field[0] = update_add_htlc */
|
||||
3, /* field[3] = update_complete */
|
||||
4, /* field[4] = update_decline_htlc */
|
||||
7, /* field[7] = update_fail_htlc */
|
||||
6, /* field[6] = update_fail_htlc */
|
||||
5, /* field[5] = update_fulfill_htlc */
|
||||
2, /* field[2] = update_signature */
|
||||
6, /* field[6] = update_timedout_htlc */
|
||||
};
|
||||
static const ProtobufCIntRange pkt__number_ranges[5 + 1] =
|
||||
static const ProtobufCIntRange pkt__number_ranges[6 + 1] =
|
||||
{
|
||||
{ 2, 0 },
|
||||
{ 20, 8 },
|
||||
{ 30, 12 },
|
||||
{ 40, 15 },
|
||||
{ 50, 16 },
|
||||
{ 0, 17 }
|
||||
{ 9, 6 },
|
||||
{ 20, 7 },
|
||||
{ 30, 11 },
|
||||
{ 40, 14 },
|
||||
{ 50, 15 },
|
||||
{ 0, 16 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor pkt__descriptor =
|
||||
{
|
||||
@ -2502,10 +2396,10 @@ const ProtobufCMessageDescriptor pkt__descriptor =
|
||||
"Pkt",
|
||||
"",
|
||||
sizeof(Pkt),
|
||||
17,
|
||||
16,
|
||||
pkt__field_descriptors,
|
||||
pkt__field_indices_by_name,
|
||||
5, pkt__number_ranges,
|
||||
6, pkt__number_ranges,
|
||||
(ProtobufCMessageInit) pkt__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
|
@ -28,7 +28,6 @@ typedef struct _OpenComplete OpenComplete;
|
||||
typedef struct _UpdateAddHtlc UpdateAddHtlc;
|
||||
typedef struct _UpdateDeclineHtlc UpdateDeclineHtlc;
|
||||
typedef struct _UpdateFulfillHtlc UpdateFulfillHtlc;
|
||||
typedef struct _UpdateTimedoutHtlc UpdateTimedoutHtlc;
|
||||
typedef struct _UpdateFailHtlc UpdateFailHtlc;
|
||||
typedef struct _UpdateAccept UpdateAccept;
|
||||
typedef struct _UpdateSignature UpdateSignature;
|
||||
@ -340,27 +339,7 @@ struct _UpdateFulfillHtlc
|
||||
|
||||
|
||||
/*
|
||||
* Remove my HTLC: it has timed out, before you got the R value.
|
||||
*/
|
||||
struct _UpdateTimedoutHtlc
|
||||
{
|
||||
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_TIMEDOUT_HTLC__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&update_timedout_htlc__descriptor) \
|
||||
, NULL, NULL }
|
||||
|
||||
|
||||
/*
|
||||
* Remove your HTLC: routing has failed upstream or we didn't like it.
|
||||
* Remove your HTLC: routing has failed upstream, we didn't like it, or timeout.
|
||||
*/
|
||||
struct _UpdateFailHtlc
|
||||
{
|
||||
@ -511,7 +490,6 @@ typedef enum {
|
||||
PKT__PKT_UPDATE_COMPLETE = 5,
|
||||
PKT__PKT_UPDATE_DECLINE_HTLC = 6,
|
||||
PKT__PKT_UPDATE_FULFILL_HTLC = 7,
|
||||
PKT__PKT_UPDATE_TIMEDOUT_HTLC = 8,
|
||||
PKT__PKT_UPDATE_FAIL_HTLC = 9,
|
||||
PKT__PKT_CLOSE = 30,
|
||||
PKT__PKT_CLOSE_COMPLETE = 31,
|
||||
@ -547,7 +525,6 @@ struct _Pkt
|
||||
UpdateComplete *update_complete;
|
||||
UpdateDeclineHtlc *update_decline_htlc;
|
||||
UpdateFulfillHtlc *update_fulfill_htlc;
|
||||
UpdateTimedoutHtlc *update_timedout_htlc;
|
||||
UpdateFailHtlc *update_fail_htlc;
|
||||
/*
|
||||
* Closing
|
||||
@ -813,25 +790,6 @@ UpdateFulfillHtlc *
|
||||
void update_fulfill_htlc__free_unpacked
|
||||
(UpdateFulfillHtlc *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* UpdateTimedoutHtlc methods */
|
||||
void update_timedout_htlc__init
|
||||
(UpdateTimedoutHtlc *message);
|
||||
size_t update_timedout_htlc__get_packed_size
|
||||
(const UpdateTimedoutHtlc *message);
|
||||
size_t update_timedout_htlc__pack
|
||||
(const UpdateTimedoutHtlc *message,
|
||||
uint8_t *out);
|
||||
size_t update_timedout_htlc__pack_to_buffer
|
||||
(const UpdateTimedoutHtlc *message,
|
||||
ProtobufCBuffer *buffer);
|
||||
UpdateTimedoutHtlc *
|
||||
update_timedout_htlc__unpack
|
||||
(ProtobufCAllocator *allocator,
|
||||
size_t len,
|
||||
const uint8_t *data);
|
||||
void update_timedout_htlc__free_unpacked
|
||||
(UpdateTimedoutHtlc *message,
|
||||
ProtobufCAllocator *allocator);
|
||||
/* UpdateFailHtlc methods */
|
||||
void update_fail_htlc__init
|
||||
(UpdateFailHtlc *message);
|
||||
@ -1044,9 +1002,6 @@ typedef void (*UpdateDeclineHtlc_Closure)
|
||||
typedef void (*UpdateFulfillHtlc_Closure)
|
||||
(const UpdateFulfillHtlc *message,
|
||||
void *closure_data);
|
||||
typedef void (*UpdateTimedoutHtlc_Closure)
|
||||
(const UpdateTimedoutHtlc *message,
|
||||
void *closure_data);
|
||||
typedef void (*UpdateFailHtlc_Closure)
|
||||
(const UpdateFailHtlc *message,
|
||||
void *closure_data);
|
||||
@ -1094,7 +1049,6 @@ extern const ProtobufCMessageDescriptor open_complete__descriptor;
|
||||
extern const ProtobufCMessageDescriptor update_add_htlc__descriptor;
|
||||
extern const ProtobufCMessageDescriptor update_decline_htlc__descriptor;
|
||||
extern const ProtobufCMessageDescriptor update_fulfill_htlc__descriptor;
|
||||
extern const ProtobufCMessageDescriptor update_timedout_htlc__descriptor;
|
||||
extern const ProtobufCMessageDescriptor update_fail_htlc__descriptor;
|
||||
extern const ProtobufCMessageDescriptor update_accept__descriptor;
|
||||
extern const ProtobufCMessageDescriptor update_signature__descriptor;
|
||||
|
@ -139,15 +139,7 @@ message update_fulfill_htlc {
|
||||
required sha256_hash r = 2;
|
||||
}
|
||||
|
||||
// Remove my HTLC: it has timed out, before you got the R value.
|
||||
message update_timedout_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 = 2;
|
||||
}
|
||||
|
||||
// Remove your HTLC: routing has failed upstream or we didn't like it.
|
||||
// Remove your HTLC: routing has failed upstream, we didn't like it, or timeout.
|
||||
message update_fail_htlc {
|
||||
// Hash for which I will supply preimage to revoke this commitment tx.
|
||||
required sha256_hash revocation_hash = 1;
|
||||
@ -219,7 +211,6 @@ message pkt {
|
||||
update_complete update_complete = 5;
|
||||
update_decline_htlc update_decline_htlc = 6;
|
||||
update_fulfill_htlc update_fulfill_htlc = 7;
|
||||
update_timedout_htlc update_timedout_htlc = 8;
|
||||
update_fail_htlc update_fail_htlc = 9;
|
||||
// Closing
|
||||
close_channel close = 30;
|
||||
|
30
state.c
30
state.c
@ -418,14 +418,6 @@ enum command_status state(const tal_t *ctx,
|
||||
change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY);
|
||||
return next_state(peer, cstatus,
|
||||
prio(peer->state, STATE_WAIT_FOR_UPDATE_ACCEPT));
|
||||
} else if (input_is(input, CMD_SEND_HTLC_TIMEDOUT)) {
|
||||
/* We are to send an HTLC timedout. */
|
||||
queue_pkt(out,
|
||||
pkt_htlc_timedout(ctx, peer,
|
||||
idata->htlc_prog));
|
||||
change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY);
|
||||
return next_state(peer, cstatus,
|
||||
prio(peer->state, STATE_WAIT_FOR_UPDATE_ACCEPT));
|
||||
} else if (input_is(input, CMD_SEND_HTLC_FAIL)) {
|
||||
/* We are to send an HTLC fail. */
|
||||
queue_pkt(out,
|
||||
@ -442,9 +434,6 @@ enum command_status state(const tal_t *ctx,
|
||||
} else if (input_is(input, PKT_UPDATE_FULFILL_HTLC)) {
|
||||
change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY);
|
||||
goto accept_htlc_fulfill;
|
||||
} else if (input_is(input, PKT_UPDATE_TIMEDOUT_HTLC)) {
|
||||
change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY);
|
||||
goto accept_htlc_timedout;
|
||||
} else if (input_is(input, PKT_UPDATE_FAIL_HTLC)) {
|
||||
change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY);
|
||||
goto accept_htlc_fail;
|
||||
@ -495,17 +484,6 @@ enum command_status state(const tal_t *ctx,
|
||||
/* Stay busy, since we're processing theirs. */
|
||||
change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY);
|
||||
goto accept_htlc_fulfill;
|
||||
} else if (input_is(input, PKT_UPDATE_TIMEDOUT_HTLC)) {
|
||||
/* If we're high priority, ignore their packet */
|
||||
if (high_priority(peer->state))
|
||||
return cstatus;
|
||||
|
||||
/* Otherwise, process their request first: defer ours */
|
||||
peer_htlc_ours_deferred(peer);
|
||||
complete_cmd(peer, &cstatus, CMD_REQUEUE);
|
||||
/* Stay busy, since we're processing theirs. */
|
||||
change_peer_cond(peer, PEER_CMD_OK, PEER_BUSY);
|
||||
goto accept_htlc_timedout;
|
||||
} else if (input_is(input, PKT_UPDATE_FAIL_HTLC)) {
|
||||
/* If we're high priority, ignore their packet */
|
||||
if (high_priority(peer->state))
|
||||
@ -1059,14 +1037,6 @@ accept_htlc_fail:
|
||||
return next_state(peer, cstatus,
|
||||
prio(peer->state, STATE_WAIT_FOR_UPDATE_SIG));
|
||||
|
||||
accept_htlc_timedout:
|
||||
err = accept_pkt_htlc_timedout(ctx, peer, idata->pkt);
|
||||
if (err)
|
||||
goto err_start_unilateral_close;
|
||||
queue_pkt(out, pkt_update_accept(ctx, peer));
|
||||
return next_state(peer, cstatus,
|
||||
prio(peer->state, STATE_WAIT_FOR_UPDATE_SIG));
|
||||
|
||||
accept_htlc_fulfill:
|
||||
err = accept_pkt_htlc_fulfill(ctx, peer, idata->pkt);
|
||||
if (err)
|
||||
|
9
state.h
9
state.h
@ -52,7 +52,6 @@ static inline bool input_is(enum state_input a, enum state_input b)
|
||||
/* Single | here, we want to record all. */
|
||||
return input_is(a, CMD_SEND_HTLC_ADD)
|
||||
| input_is(a, CMD_SEND_HTLC_FULFILL)
|
||||
| input_is(a, CMD_SEND_HTLC_TIMEDOUT)
|
||||
| input_is(a, CMD_SEND_HTLC_FAIL);
|
||||
}
|
||||
|
||||
@ -79,8 +78,7 @@ void peer_unexpected_pkt(struct peer *peer, const Pkt *pkt);
|
||||
* - peer_htlc_ours_deferred: their update was higher priority, retry later.
|
||||
* - peer_htlc_added: a new HTLC was added successfully.
|
||||
* - peer_htlc_fulfilled: an existing HTLC was fulfilled successfully.
|
||||
* - peer_htlc_timedout: an existing HTLC was timed out successfully.
|
||||
* - peer_htlc_fail: an existing HTLC failed to route.
|
||||
* - peer_htlc_fail: an existing HTLC failed to route/timedout/etc.
|
||||
* - peer_htlc_aborted: eg. comms error
|
||||
*/
|
||||
|
||||
@ -107,8 +105,6 @@ Pkt *pkt_htlc_add(const tal_t *ctx, const struct peer *peer,
|
||||
const struct htlc_progress *htlc_prog);
|
||||
Pkt *pkt_htlc_fulfill(const tal_t *ctx, const struct peer *peer,
|
||||
const struct htlc_progress *htlc_prog);
|
||||
Pkt *pkt_htlc_timedout(const tal_t *ctx, const struct peer *peer,
|
||||
const struct htlc_progress *htlc_prog);
|
||||
Pkt *pkt_htlc_fail(const tal_t *ctx, const struct peer *peer,
|
||||
const struct htlc_progress *htlc_prog);
|
||||
Pkt *pkt_update_accept(const tal_t *ctx, const struct peer *peer);
|
||||
@ -142,9 +138,6 @@ Pkt *accept_pkt_htlc_add(const tal_t *ctx,
|
||||
Pkt *accept_pkt_htlc_fail(const tal_t *ctx,
|
||||
struct peer *peer, const Pkt *pkt);
|
||||
|
||||
Pkt *accept_pkt_htlc_timedout(const tal_t *ctx,
|
||||
struct peer *peer, const Pkt *pkt);
|
||||
|
||||
Pkt *accept_pkt_htlc_fulfill(const tal_t *ctx,
|
||||
struct peer *peer, const Pkt *pkt);
|
||||
|
||||
|
@ -190,8 +190,6 @@ enum state_input {
|
||||
PKT_UPDATE_ADD_HTLC = PKT__PKT_UPDATE_ADD_HTLC,
|
||||
/* Updating the commit transaction: I have your R value! */
|
||||
PKT_UPDATE_FULFILL_HTLC = PKT__PKT_UPDATE_FULFILL_HTLC,
|
||||
/* Updating the commit transaction: my HTLC timed out! */
|
||||
PKT_UPDATE_TIMEDOUT_HTLC = PKT__PKT_UPDATE_TIMEDOUT_HTLC,
|
||||
/* Updating the commit transaction: your HTLC failed upstream */
|
||||
PKT_UPDATE_FAIL_HTLC = PKT__PKT_UPDATE_FAIL_HTLC,
|
||||
|
||||
@ -276,7 +274,6 @@ enum state_input {
|
||||
CMD_OPEN_WITHOUT_ANCHOR,
|
||||
CMD_SEND_HTLC_ADD,
|
||||
CMD_SEND_HTLC_FULFILL,
|
||||
CMD_SEND_HTLC_TIMEDOUT,
|
||||
CMD_SEND_HTLC_FAIL,
|
||||
CMD_CLOSE,
|
||||
|
||||
|
@ -38,7 +38,6 @@ enum failure {
|
||||
FAIL_ACCEPT_OPEN_COMPLETE,
|
||||
FAIL_ACCEPT_HTLC_ADD,
|
||||
FAIL_ACCEPT_HTLC_FAIL,
|
||||
FAIL_ACCEPT_HTLC_TIMEDOUT,
|
||||
FAIL_ACCEPT_HTLC_FULFILL,
|
||||
FAIL_ACCEPT_UPDATE_ACCEPT,
|
||||
FAIL_ACCEPT_UPDATE_COMPLETE,
|
||||
@ -418,8 +417,7 @@ static const union input dup_idata(const tal_t *ctx,
|
||||
i.pkt = (Pkt *)tal_strdup(ctx, (const char *)idata->pkt);
|
||||
else if (input == CMD_SEND_HTLC_ADD
|
||||
|| input == CMD_SEND_HTLC_FULFILL
|
||||
|| input == CMD_SEND_HTLC_FAIL
|
||||
|| input == CMD_SEND_HTLC_TIMEDOUT) {
|
||||
|| input == CMD_SEND_HTLC_FAIL) {
|
||||
i.htlc_prog = tal_dup(ctx, struct htlc_progress,
|
||||
idata->htlc_prog);
|
||||
} else {
|
||||
@ -630,12 +628,6 @@ Pkt *pkt_htlc_fulfill(const tal_t *ctx, const struct peer *peer,
|
||||
return htlc_pkt(ctx, "PKT_UPDATE_FULFILL_HTLC", htlc_prog->htlc.id);
|
||||
}
|
||||
|
||||
Pkt *pkt_htlc_timedout(const tal_t *ctx, const struct peer *peer,
|
||||
const struct htlc_progress *htlc_prog)
|
||||
{
|
||||
return htlc_pkt(ctx, "PKT_UPDATE_TIMEDOUT_HTLC", htlc_prog->htlc.id);
|
||||
}
|
||||
|
||||
Pkt *pkt_htlc_fail(const tal_t *ctx, const struct peer *peer,
|
||||
const struct htlc_progress *htlc_prog)
|
||||
{
|
||||
@ -761,23 +753,6 @@ Pkt *accept_pkt_htlc_fail(const tal_t *ctx,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Pkt *accept_pkt_htlc_timedout(const tal_t *ctx,
|
||||
struct peer *peer, const Pkt *pkt)
|
||||
{
|
||||
unsigned int id = htlc_id_from_pkt(pkt);
|
||||
const struct htlc *h = find_htlc(peer, id);
|
||||
|
||||
if (fail(peer, FAIL_ACCEPT_HTLC_TIMEDOUT))
|
||||
return pkt_err(ctx, "Error inject");
|
||||
|
||||
/* The shouldn't timeout unless it's to us */
|
||||
assert(!h->to_them);
|
||||
|
||||
/* This is the current htlc */
|
||||
set_current_htlc(peer, h->id, h->to_them, false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Pkt *accept_pkt_htlc_fulfill(const tal_t *ctx,
|
||||
struct peer *peer, const Pkt *pkt)
|
||||
{
|
||||
@ -1725,7 +1700,6 @@ static bool normal_path(enum state_input i, enum state src, enum state dst)
|
||||
|| i == BITCOIN_STEAL_DONE
|
||||
|| i == PKT_UPDATE_DECLINE_HTLC
|
||||
|| i == PKT_UPDATE_FAIL_HTLC
|
||||
|| i == PKT_UPDATE_TIMEDOUT_HTLC
|
||||
|| i == INPUT_CLOSE_COMPLETE_TIMEOUT)
|
||||
return false;
|
||||
|
||||
@ -2155,24 +2129,6 @@ static void run_peer(const struct peer *peer,
|
||||
copy.current_htlc.htlc.id = -1;
|
||||
}
|
||||
|
||||
/* We can timeout an HTLC we offered. */
|
||||
for (i = 0; i < peer->num_htlcs_to_them; i++) {
|
||||
idata->htlc_prog = tal(idata, struct htlc_progress);
|
||||
idata->htlc_prog->htlc = peer->htlcs_to_them[i];
|
||||
idata->htlc_prog->adding = false;
|
||||
|
||||
set_current_htlc(©,
|
||||
idata->htlc_prog->htlc.id,
|
||||
idata->htlc_prog->htlc.to_them,
|
||||
idata->htlc_prog->adding);
|
||||
copy.core.current_command = CMD_SEND_HTLC_TIMEDOUT;
|
||||
try_input(©, copy.core.current_command,
|
||||
idata, normalpath, errorpath,
|
||||
prev_trail, hist);
|
||||
/* If it was requeued, may already be reset. */
|
||||
copy.current_htlc.htlc.id = -1;
|
||||
}
|
||||
|
||||
/* Restore current_command */
|
||||
copy.core.current_command = INPUT_NONE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user