state: explicit callback to check pkt_open_complete.

For now, this always succeeds, but include the hook for completeness.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-03-08 10:39:15 +10:30
parent a2f4000d22
commit 40361e3dd8
4 changed files with 37 additions and 0 deletions

View File

@ -405,6 +405,12 @@ Pkt *accept_pkt_open_commit_sig(const tal_t *ctx,
return NULL;
}
Pkt *accept_pkt_open_complete(const tal_t *ctx,
struct peer *peer, const Pkt *pkt)
{
return NULL;
}
static Pkt *decline_htlc(const tal_t *ctx, const char *why)
{
UpdateDeclineHtlc *d = tal(ctx, UpdateDeclineHtlc);

18
state.c
View File

@ -233,6 +233,15 @@ enum command_status state(const tal_t *ctx,
break;
case STATE_OPEN_WAITING_OURANCHOR:
if (input_is(input, PKT_OPEN_COMPLETE)) {
err = accept_pkt_open_complete(ctx, peer, idata->pkt);
if (err) {
complete_cmd(peer, &cstatus, CMD_FAIL);
/* We no longer care about anchor depth. */
peer_unwatch_anchor_depth(peer,
BITCOIN_ANCHOR_DEPTHOK,
INPUT_NONE);
goto err_start_unilateral_close;
}
return next_state(peer, cstatus,
STATE_OPEN_WAITING_OURANCHOR_THEYCOMPLETED);
}
@ -286,6 +295,15 @@ enum command_status state(const tal_t *ctx,
break;
case STATE_OPEN_WAITING_THEIRANCHOR:
if (input_is(input, PKT_OPEN_COMPLETE)) {
err = accept_pkt_open_complete(ctx, peer, idata->pkt);
if (err) {
complete_cmd(peer, &cstatus, CMD_FAIL);
/* We no longer care about anchor depth. */
peer_unwatch_anchor_depth(peer,
BITCOIN_ANCHOR_DEPTHOK,
BITCOIN_ANCHOR_TIMEOUT);
goto err_start_unilateral_close;
}
return next_state(peer, cstatus,
STATE_OPEN_WAITING_THEIRANCHOR_THEYCOMPLETED);
}

View File

@ -132,6 +132,9 @@ Pkt *accept_pkt_anchor(const tal_t *ctx,
Pkt *accept_pkt_open_commit_sig(const tal_t *ctx,
struct peer *peer, const Pkt *pkt);
Pkt *accept_pkt_open_complete(const tal_t *ctx,
struct peer *peer, const Pkt *pkt);
Pkt *accept_pkt_htlc_update(const tal_t *ctx,
struct peer *peer, const Pkt *pkt,
Pkt **decline);

View File

@ -35,6 +35,7 @@ enum failure {
FAIL_ACCEPT_OPEN,
FAIL_ACCEPT_ANCHOR,
FAIL_ACCEPT_OPEN_COMMIT_SIG,
FAIL_ACCEPT_OPEN_COMPLETE,
FAIL_ACCEPT_HTLC_UPDATE,
FAIL_ACCEPT_HTLC_ROUTEFAIL,
FAIL_ACCEPT_HTLC_TIMEDOUT,
@ -716,6 +717,15 @@ Pkt *accept_pkt_open_commit_sig(const tal_t *ctx,
return NULL;
}
Pkt *accept_pkt_open_complete(const tal_t *ctx,
struct peer *peer,
const Pkt *pkt)
{
if (fail(peer, FAIL_ACCEPT_OPEN_COMPLETE))
return pkt_err(ctx, "Error inject");
return NULL;
}
Pkt *accept_pkt_htlc_update(const tal_t *ctx,
struct peer *peer, const Pkt *pkt,
Pkt **decline)