diff --git a/daemon/peer.c b/daemon/peer.c index 8bc63e619..0c21fc05c 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -2960,8 +2960,8 @@ static enum watch_result anchor_depthchange(struct peer *peer, void *unused) { /* Still waiting for it to reach depth? */ - if (state_is_opening(peer->state)) { - if ((int)depth >= peer->anchor.ok_depth) { + if (state_is_waiting_for_anchor(peer->state)) { + if ((int)depth == peer->anchor.ok_depth) { state_event(peer, BITCOIN_ANCHOR_DEPTHOK, NULL); peer->anchor.ok_depth = -1; } diff --git a/state.h b/state.h index f7aff9d0b..80ebbdad5 100644 --- a/state.h +++ b/state.h @@ -40,6 +40,14 @@ static inline bool state_is_opening(enum state s) return s < STATE_NORMAL; } +static inline bool state_is_waiting_for_anchor(enum state s) +{ + return s == STATE_OPEN_WAITING_OURANCHOR + || s == STATE_OPEN_WAITING_OURANCHOR_THEYCOMPLETED + || s == STATE_OPEN_WAITING_THEIRANCHOR + || s == STATE_OPEN_WAITING_THEIRANCHOR_THEYCOMPLETED; +} + static inline bool state_can_io(enum state s) { if (state_is_error(s))