diff --git a/lightningd/channel.c b/lightningd/channel.c index b98c9ec12..5f6990b25 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -248,6 +248,7 @@ struct channel *new_unsaved_channel(struct peer *peer, channel->old_feerate_timeout.ts.tv_nsec = 0; /* closer not yet known */ channel->closer = NUM_SIDES; + channel->close_blockheight = NULL; /* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9 * | 222/223 | `option_dual_fund` @@ -523,6 +524,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid, list_head_init(&channel->inflights); channel->closer = closer; + channel->close_blockheight = NULL; channel->state_change_cause = reason; /* Make sure we see any spends using this key */ diff --git a/lightningd/channel.h b/lightningd/channel.h index 10c1d7970..4f6a21330 100644 --- a/lightningd/channel.h +++ b/lightningd/channel.h @@ -242,6 +242,9 @@ struct channel { /* the one that initiated a bilateral close, NUM_SIDES if unknown. */ enum side closer; + /* Block height we saw closing tx at */ + u32 *close_blockheight; + /* Last known state_change cause */ enum state_change state_change_cause; diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c index f8a9ad7d5..1551a743d 100644 --- a/lightningd/onchain_control.c +++ b/lightningd/onchain_control.c @@ -909,6 +909,8 @@ enum watch_result onchaind_funding_spent(struct channel *channel, channel_record_open(channel, blkh, true); } + tal_free(channel->close_blockheight); + channel->close_blockheight = tal_dup(channel, u32, &blockheight); /* We could come from almost any state. */ /* NOTE(mschmoock) above comment is wrong, since we failed above! */