core-lightning/lightningd/peer_state.h
Rusty Russell d04b7af56e onchain: add initial onchain state.
We have a race where we start onchaind, but state is unchanged, so checks
like peer_control.c's:

	peer_ready = (peer->owner && peer->state == CHANNELD_AWAITING_LOCKIN);
	if (!peer_ready) {
		log_unusual(peer->log,
			    "Funding tx confirmed, but peer state %s %s",
			    peer_state_name(peer->state),
			    peer->owner ? peer->owner->name : "unowned");
	} else {
		subd_send_msg(peer->owner,
			      take(towire_channel_funding_locked(peer,
								 peer->scid)));
	}

Can send to the wrong daemon.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-09-28 13:07:05 +09:30

40 lines
822 B
C

#ifndef LIGHTNING_LIGHTNINGD_PEER_STATE_H
#define LIGHTNING_LIGHTNINGD_PEER_STATE_H
#include "config.h"
enum peer_state {
UNINITIALIZED,
/* In gossip daemon. */
GOSSIPD,
/* Negotiating channel opening: in opening daemon */
OPENINGD,
/* In channeld, still waiting for lockin. */
CHANNELD_AWAITING_LOCKIN,
/* Normal operating state. */
CHANNELD_NORMAL,
/* We are closing, pending HTLC resolution. */
CHANNELD_SHUTTING_DOWN,
/* Exchanging signatures on closing tx. */
CLOSINGD_SIGEXCHANGE,
/* Waiting for onchain event. */
CLOSINGD_COMPLETE,
/* We've seen the funding spent, we're waiting for onchaind. */
FUNDING_SPEND_SEEN,
/* Various onchain states. */
ONCHAIND_CHEATED,
ONCHAIND_THEIR_UNILATERAL,
ONCHAIND_OUR_UNILATERAL,
ONCHAIND_MUTUAL
};
#endif /* LIGHTNING_LIGHTNINGD_PEER_STATE_H */