lightningd: initialize channel_type field on dualopend channel creation.

Otherwise a badly-timed listpeerchannels will crash.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-06-26 08:26:21 +09:30
parent 336dcef541
commit 5c6e706026
2 changed files with 6 additions and 0 deletions

View file

@ -246,6 +246,11 @@ struct channel *new_unsaved_channel(struct peer *peer,
/* closer not yet known */
channel->closer = NUM_SIDES;
channel->close_blockheight = NULL;
/* In case someone looks at channels before open negotiation,
* initialize this with default */
channel->type = default_channel_type(channel,
ld->our_features,
peer->their_features);
/* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9
* | 222/223 | `option_dual_fund`

View file

@ -1273,6 +1273,7 @@ wallet_commit_channel(struct lightningd *ld,
} else
channel->scb = NULL;
tal_free(channel->type);
channel->type = channel_type_dup(channel, type);
channel->scb->type = channel_type_dup(channel->scb, type);