Browse Source

onchaind: Move preimage transfer into onchaind startup

We used to queue the preimages to be sent to onchaind only after receiving the
onchaind_init_reply. Once we start replaying we might end up in a situation in
which we queue the tx that onchaind should react to before providing it with the
preimages. This commit just moves the preimages being sent, making it atomic
with the init, and without changing the order.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
4547afba33
  1. 10
      lightningd/onchain_control.c

10
lightningd/onchain_control.c

@ -47,13 +47,10 @@ static void onchaind_tell_fulfill(struct channel *channel)
}
}
static void handle_onchain_init_reply(struct channel *channel, const u8 *msg)
static void handle_onchain_init_reply(struct channel *channel, const u8 *msg UNUSED)
{
/* FIXME: We may already be ONCHAIN state when we implement restart! */
channel_set_state(channel, FUNDING_SPEND_SEEN, ONCHAIN);
/* Tell it about any preimages we know. */
onchaind_tell_fulfill(channel);
}
static enum watch_result onchain_tx_watched(struct channel *channel,
@ -201,7 +198,7 @@ static void handle_onchain_htlc_timeout(struct channel *channel, const u8 *msg)
onchain_failed_our_htlc(channel, &htlc, "timed out");
}
static void handle_irrevocably_resolved(struct channel *channel, const u8 *msg)
static void handle_irrevocably_resolved(struct channel *channel, const u8 *msg UNUSED)
{
/* FIXME: Implement check_htlcs to ensure no dangling hout->in ptrs! */
free_htlcs(channel->peer->ld, channel);
@ -429,6 +426,9 @@ enum watch_result funding_spent(struct channel *channel,
subd_send_msg(channel->owner, take(msg));
}
/* Tell it about any preimages we know. */
onchaind_tell_fulfill(channel);
watch_tx_and_outputs(channel, tx);
/* We keep watching until peer finally deleted, for reorgs. */

Loading…
Cancel
Save