Skip to content

Commit 547ea2f

Browse files
committed
Pass whole sats to new_inflight function
This is an alternative to what we discussed on Friday to fix the interop test where we splice-out funds from cln that were received via an htlc payment. ElementsProject#8021 (comment) It should be safer to use `amount_msat_to_sat_round_down` instead of `amount_msat_to_sat` because we can drop sub-sat amounts for splices. Also if `amount_msat_to_sat` fails it won't set `local_funds` and create UB.
1 parent 8681b7b commit 547ea2f

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

lightningd/channel_control.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -855,23 +855,25 @@ static void handle_add_inflight(struct lightningd *ld,
855855
return;
856856
}
857857

858-
inflight = new_inflight(channel,
859-
remote_funding,
860-
&outpoint,
861-
feerate,
862-
satoshis,
863-
channel->our_funds,
864-
psbt,
865-
channel->lease_expiry,
866-
channel->lease_commit_sig,
867-
channel->lease_chan_max_msat,
868-
channel->lease_chan_max_ppt,
869-
0,
870-
AMOUNT_MSAT(0),
871-
AMOUNT_SAT(0),
872-
splice_amnt,
873-
i_am_initiator,
874-
force_sign_first);
858+
struct amount_sat local_funds = amount_msat_to_sat_round_down(channel->our_msat);
859+
860+
inflight = new_inflight(channel,
861+
remote_funding,
862+
&outpoint,
863+
feerate,
864+
satoshis,
865+
local_funds,
866+
psbt,
867+
channel->lease_expiry,
868+
channel->lease_commit_sig,
869+
channel->lease_chan_max_msat,
870+
channel->lease_chan_max_ppt,
871+
0,
872+
AMOUNT_MSAT(0),
873+
AMOUNT_SAT(0),
874+
splice_amnt,
875+
i_am_initiator,
876+
force_sign_first);
875877

876878
log_debug(channel->log, "lightningd adding inflight with txid %s",
877879
fmt_bitcoin_txid(tmpctx,

0 commit comments

Comments
 (0)