Skip to content

Commit 25ae6d8

Browse files
committed
splice_channel: Make locktime optional
1 parent 51fb099 commit 25ae6d8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4286,11 +4286,12 @@ where
42864286
/// - our_funding_contribution_satoshis: the amount contributed by us to the channel. This will increase our channel balance.
42874287
/// - our_funding_inputs: the funding inputs provided by us. If our contribution is positive, our funding inputs must cover at least that amount.
42884288
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
4289+
/// - locktime: Optional locktime for the new funding transaction. If None, set to the current block height.
42894290
#[cfg(splicing)]
42904291
pub fn splice_channel(
42914292
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, our_funding_contribution_satoshis: i64,
42924293
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
4293-
funding_feerate_per_kw: u32, locktime: u32,
4294+
funding_feerate_per_kw: u32, locktime: Option<u32>,
42944295
) -> Result<(), APIError> {
42954296
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
42964297
let per_peer_state = self.per_peer_state.read().unwrap();
@@ -4304,6 +4305,7 @@ where
43044305
// Look for the channel
43054306
match peer_state.channel_by_id.entry(*channel_id) {
43064307
hash_map::Entry::Occupied(mut chan_phase_entry) => {
4308+
let locktime = locktime.unwrap_or(self.current_best_block().height);
43074309
if let Some(chan) = chan_phase_entry.get_mut().as_funded_mut() {
43084310
let msg = chan.splice_channel(our_funding_contribution_satoshis, our_funding_inputs, funding_feerate_per_kw, locktime)
43094311
.map_err(|err| APIError::APIMisuseError {

lightning/src/ln/functional_tests_splice.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ fn test_v1_splice_in() {
227227
// Amount being added to the channel through the splice-in
228228
let splice_in_sats: u64 = 20000;
229229
let funding_feerate_per_kw = 1024; // TODO
230-
let locktime = 0; // TODO
231230

232231
// Create additional inputs
233232
let extra_splice_funding_input_sats = 35_000;
@@ -244,7 +243,7 @@ fn test_v1_splice_in() {
244243
splice_in_sats as i64,
245244
funding_inputs,
246245
funding_feerate_per_kw,
247-
locktime,
246+
None, // locktime
248247
)
249248
.unwrap();
250249
// Extract the splice message from node0 to node1

0 commit comments

Comments
 (0)