From 7db8680530c34385898829d16163f388e96a3190 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 17 Sep 2020 11:30:33 +0930 Subject: [PATCH] lightningd: don't hand around partially-assembled channel_info. wallet_commit_channel would fill in the old_remote_per_commit and fee_states, which is weird since the caller doesn't care. Make the caller set all the channel_info fields, so wallet_commit_channel is a simple consumer. Signed-off-by: Rusty Russell --- lightningd/dual_open_control.c | 8 ++++---- lightningd/opening_control.c | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 52e9bfb74..25a6a575c 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -654,7 +654,7 @@ wallet_commit_channel(struct lightningd *ld, struct amount_sat total_funding, struct amount_sat our_funding, u8 channel_flags, - struct channel_info *channel_info, + const struct channel_info *channel_info, u32 feerate, enum side opener, const u8 *our_upfront_shutdown_script, @@ -678,9 +678,6 @@ wallet_commit_channel(struct lightningd *ld, return NULL; } - /* old_remote_per_commit not valid yet, copy valid one. */ - channel_info->old_remote_per_commit = channel_info->remote_per_commit; - /* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9 * | 222/223 | `option_dual_fund` * | Use v2 of channel open, enables dual funding @@ -816,6 +813,9 @@ static void accepter_commit_received(struct subd *dualopend, goto failed; } + /* old_remote_per_commit not valid yet, copy valid one. */ + channel_info.old_remote_per_commit = channel_info.remote_per_commit; + payload->rcvd->channel = wallet_commit_channel(ld, uc, &cid, diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 7e42741ac..fcf124664 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -376,6 +376,9 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp, /* Saved with channel to disk */ derive_channel_id(&cid, &funding_txid, funding_txout); + /* old_remote_per_commit not valid yet, copy valid one. */ + channel_info.old_remote_per_commit = channel_info.remote_per_commit; + /* Steals fields from uc */ channel = wallet_commit_channel(ld, fc->uc, &cid, @@ -481,6 +484,9 @@ static void opening_fundee_finished(struct subd *openingd, derive_channel_id(&cid, &funding_txid, funding_outnum); + /* old_remote_per_commit not valid yet, copy valid one. */ + channel_info.old_remote_per_commit = channel_info.remote_per_commit; + /* Consumes uc */ channel = wallet_commit_channel(ld, uc, &cid,