From db448df277928ee550a1454167dc41599f6b6c97 Mon Sep 17 00:00:00 2001 From: niftynei Date: Wed, 19 Oct 2022 11:25:21 -0500 Subject: [PATCH] dual-fund: on re-init, re-populate opener_funding/accepter_funding We use them in the RBF case! --- openingd/dualopend.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/openingd/dualopend.c b/openingd/dualopend.c index 18e0eb620..1b8c5e98c 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -3926,6 +3926,8 @@ int main(int argc, char *argv[]) &state->tx_state->lease_chan_max_ppt, &requested_lease)) { + bool ok; + /*~ We only reconnect on channels that the * saved the the database (exchanged commitment sigs) */ type = default_channel_type(NULL, @@ -3934,6 +3936,8 @@ int main(int argc, char *argv[]) if (requested_lease) state->requested_lease = tal_steal(state, requested_lease); + else + state->requested_lease = NULL; state->channel = new_initial_channel(state, &state->channel_id, @@ -3956,10 +3960,20 @@ int main(int argc, char *argv[]) OPT_LARGE_CHANNELS), opener); - if (opener == LOCAL) + if (opener == LOCAL) { state->our_role = TX_INITIATOR; - else + ok = amount_msat_to_sat(&state->tx_state->opener_funding, our_msat); + ok &= amount_sat_sub(&state->tx_state->accepter_funding, + total_funding, + state->tx_state->opener_funding); + } else { state->our_role = TX_ACCEPTER; + ok = amount_msat_to_sat(&state->tx_state->accepter_funding, our_msat); + ok &= amount_sat_sub(&state->tx_state->opener_funding, + total_funding, + state->tx_state->accepter_funding); + } + assert(ok); /* We can pull the commitment feerate out of the feestates */ state->feerate_per_kw_commitment