lightningd: remember depth of closing transaction.

We'll use this later to calculate deadlines for spending txs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-04-06 09:03:24 +09:30
parent 9d5dfa7bdd
commit 80cd6f0afe
3 changed files with 7 additions and 0 deletions

View File

@ -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 */

View File

@ -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;

View File

@ -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! */