Skip to content

Commit ab15331

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 36a5f74 commit ab15331

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
@@ -861,23 +861,25 @@ static void handle_add_inflight(struct lightningd *ld,
861861
return;
862862
}
863863

864-
inflight = new_inflight(channel,
865-
remote_funding,
866-
&outpoint,
867-
feerate,
868-
satoshis,
869-
channel->our_funds,
870-
psbt,
871-
channel->lease_expiry,
872-
channel->lease_commit_sig,
873-
channel->lease_chan_max_msat,
874-
channel->lease_chan_max_ppt,
875-
0,
876-
AMOUNT_MSAT(0),
877-
AMOUNT_SAT(0),
878-
splice_amnt,
879-
i_am_initiator,
880-
force_sign_first);
864+
struct amount_sat local_funds = amount_msat_to_sat_round_down(channel->our_msat);
865+
866+
inflight = new_inflight(channel,
867+
remote_funding,
868+
&outpoint,
869+
feerate,
870+
satoshis,
871+
local_funds,
872+
psbt,
873+
channel->lease_expiry,
874+
channel->lease_commit_sig,
875+
channel->lease_chan_max_msat,
876+
channel->lease_chan_max_ppt,
877+
0,
878+
AMOUNT_MSAT(0),
879+
AMOUNT_SAT(0),
880+
splice_amnt,
881+
i_am_initiator,
882+
force_sign_first);
881883

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

0 commit comments

Comments
 (0)