From dd871d9e2657b3f467ecb9245a109900bcdb338f Mon Sep 17 00:00:00 2001 From: niftynei Date: Thu, 11 May 2023 17:07:32 -0500 Subject: [PATCH] inflights: use ctx for making new ones Also convert everything to an array thingy --- channeld/channeld.c | 6 +++--- lightningd/channel_control.c | 8 ++++++-- tools/generate-wire.py | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/channeld/channeld.c b/channeld/channeld.c index 9b5c27a43..a9cf63299 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -1894,7 +1894,7 @@ static void send_revocation(struct peer *peer, /* Calling `handle_peer_commit_sig` with a `commit_index` of 0 and * `changed_htlcs` of NULL will process the message, then read & process coming - * consecutive commitment messages equal to the number of inflight splices. + * consecutive commitment messages equal to the number of inflight splices. * * Returns the last commitsig received. When splicing this is the * newest splice commit sig. */ @@ -2986,7 +2986,7 @@ static struct amount_sat check_balances(struct peer *peer, if (!amount_msat_sub_sat(&out[TX_ACCEPTER], out[TX_ACCEPTER], amount_sat((u64)-peer->splice->accepter_relative))) peer_failed_warn(peer->pps, &peer->channel_id, - "Unable to sub accepter funding from out amnt."); + "Unable to sub accepter funding from out amnt."); } if (amount_msat_less(in[TX_INITIATOR], out[TX_INITIATOR])) { @@ -3801,7 +3801,7 @@ static void splice_initiator_user_finalized(struct peer *peer) new_inflight->last_tx = tal_steal(peer, their_commit->tx); new_inflight->last_sig = their_commit->commit_signature; - + outmsg = towire_channeld_update_inflight(NULL, ictx->current_psbt, their_commit->tx, &their_commit->commit_signature); diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 5c46be334..f3c6bc633 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -1391,15 +1391,19 @@ bool peer_start_channeld(struct channel *channel, curr_blockheight = last_height; } - inflights = tal_arr(tmpctx, struct inflight*, 0); + inflights = tal_arr(tmpctx, struct inflight *, 0); list_for_each(&channel->inflights, inflight, list) { struct inflight *infcopy = tal(inflights, struct inflight); + infcopy->outpoint = inflight->funding->outpoint; infcopy->amnt = inflight->funding->total_funds; infcopy->splice_amnt = inflight->funding->splice_amnt; - infcopy->last_tx = inflight->last_tx; + infcopy->last_tx = tal_dup(infcopy, struct bitcoin_tx, inflight->last_tx); infcopy->last_sig = inflight->last_sig; infcopy->i_am_initiator = inflight->i_am_initiator; + tal_wally_start(); + wally_psbt_clone_alloc(inflight->funding_psbt, 0, &infcopy->psbt); + tal_wally_end_onto(infcopy, infcopy->psbt, struct wally_psbt); tal_arr_expand(&inflights, infcopy); } diff --git a/tools/generate-wire.py b/tools/generate-wire.py index c23629f97..92ebf7b9d 100755 --- a/tools/generate-wire.py +++ b/tools/generate-wire.py @@ -249,6 +249,7 @@ class Type(FieldSet): 'wally_psbt', 'wally_tx', 'scb_chan', + 'inflight', ] # Some BOLT types are re-typed based on their field name