From 1c9a713dfa4c7b9e9102954214fb6353c09c1ff9 Mon Sep 17 00:00:00 2001 From: niftynei Date: Mon, 23 Nov 2020 19:43:02 -0600 Subject: [PATCH] channel-state: add two new states, for dualopend v2 channel opens are going to happen over in dualopend. In order to make sure that these don't end up in the wrong place/to keep track of the difference between "waiting for sigs" and "have merely initiatlized a channel", we add two new states to the channel state machine. A channel that 'originates' in dualopend will only ever arrive at channeld in the state CHANNELD_NORMAL. --- lightningd/channel_state.h | 12 ++++++++++-- lightningd/peer_control.c | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lightningd/channel_state.h b/lightningd/channel_state.h index 262c0e55d..eead7d32d 100644 --- a/lightningd/channel_state.h +++ b/lightningd/channel_state.h @@ -31,9 +31,17 @@ enum channel_state { ONCHAIN, /* Final state after we have fully settled on-chain */ - CLOSED + CLOSED, + + /* For dual-funded channels, we start at a different state. + * We transition to 'awaiting lockin' after sigs have + * been exchanged */ + DUALOPEND_OPEN_INIT, + + /* Dual-funded channel, waiting for lock-in */ + DUALOPEND_AWAITING_LOCKIN, }; -#define CHANNEL_STATE_MAX CLOSED +#define CHANNEL_STATE_MAX DUALOPEND_AWAITING_LOCKIN enum state_change { /* Anything other than the reasons below. Should not happen. */ diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index d31b2791c..df6775297 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1021,6 +1021,10 @@ peer_connected_hook_cb(struct peer_connected_hook_payload *payload STEALS, "Awaiting unilateral close"); goto send_error; } + case DUALOPEND_OPEN_INIT: + case DUALOPEND_AWAITING_LOCKIN: + /* FIXME: open dualopend */ + abort(); case CHANNELD_AWAITING_LOCKIN: case CHANNELD_NORMAL: