channel_control: when we reach depth, for v2 channels, tell dualopend

This commit is contained in:
niftynei 2020-11-23 19:44:02 -06:00 committed by Christian Decker
parent 1c9a713dfa
commit 57348e0470
2 changed files with 29 additions and 9 deletions

View file

@ -56,6 +56,10 @@ LIGHTNINGD_HEADERS := \
lightningd/channel_state.h \
lightningd/channel_state_names_gen.h
ifeq ($(EXPERIMENTAL_FEATURES),1)
LIGHTNINGD_HEADERS += lightningd/dual_open_control.h
endif
LIGHTNINGD_OBJS := $(LIGHTNINGD_SRC:.c=.o) $(LIGHTNINGD_SRC_NOHDR:.c=.o)
$(LIGHTNINGD_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_CONTROL_HEADERS)

View file

@ -31,6 +31,10 @@
#include <wire/common_wiregen.h>
#include <wire/wire_sync.h>
#if EXPERIMENTAL_FEATURES
#include <lightningd/dual_open_control.h>
#endif
static void update_feerates(struct lightningd *ld, struct channel *channel)
{
u8 *msg;
@ -610,15 +614,6 @@ bool channel_tell_depth(struct lightningd *ld,
txidstr = type_to_string(tmpctx, struct bitcoin_txid, txid);
/* If not awaiting lockin/announce, it doesn't care any more */
if (channel->state != CHANNELD_AWAITING_LOCKIN
&& channel->state != CHANNELD_NORMAL) {
log_debug(channel->log,
"Funding tx %s confirmed, but peer in state %s",
txidstr, channel_state_name(channel));
return true;
}
if (!channel->owner) {
log_debug(channel->log,
"Funding tx %s confirmed, but peer disconnected",
@ -626,6 +621,27 @@ bool channel_tell_depth(struct lightningd *ld,
return false;
}
if (streq(channel->owner->name, "dualopend")) {
if (channel->state != DUALOPEND_AWAITING_LOCKIN
&& channel->state != CHANNELD_NORMAL) {
log_debug(channel->log,
"Funding tx %s confirmed, but peer in"
" state %s",
txidstr, channel_state_name(channel));
return true;
}
// FIXME: pass to dualopend here!
} else if (channel->state != CHANNELD_AWAITING_LOCKIN
&& channel->state != CHANNELD_NORMAL) {
/* If not awaiting lockin/announce, it doesn't
* care any more */
log_debug(channel->log,
"Funding tx %s confirmed, but peer in state %s",
txidstr, channel_state_name(channel));
return true;
}
subd_send_msg(channel->owner,
take(towire_channeld_funding_depth(NULL, channel->scid,
depth)));