Skip to content

Commit b9f9022

Browse files
committed
splice_channel: Make locktime optional
1 parent 5d8519b commit b9f9022

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
@@ -4239,11 +4239,12 @@ where
42394239
/// - our_funding_contribution_satoshis: the amount contributed by us to the channel. This will increase our channel balance.
42404240
/// - our_funding_inputs: the funding inputs provided by us. If our contribution is positive, our funding inputs must cover at least that amount.
42414241
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
4242+
/// - locktime: Optional locktime for the new funding transaction. If None, set to the current block height.
42424243
#[cfg(splicing)]
42434244
pub fn splice_channel(
42444245
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, our_funding_contribution_satoshis: i64,
42454246
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
4246-
funding_feerate_per_kw: u32, locktime: u32,
4247+
funding_feerate_per_kw: u32, locktime: Option<u32>,
42474248
) -> Result<(), APIError> {
42484249
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
42494250
let per_peer_state = self.per_peer_state.read().unwrap();
@@ -4257,6 +4258,7 @@ where
42574258
// Look for the channel
42584259
match peer_state.channel_by_id.entry(*channel_id) {
42594260
hash_map::Entry::Occupied(mut chan_phase_entry) => {
4261+
let locktime = locktime.unwrap_or(self.current_best_block().height);
42604262
if let Some(chan) = chan_phase_entry.get_mut().as_funded_mut() {
42614263
let msg = chan.splice_channel(our_funding_contribution_satoshis, our_funding_inputs, funding_feerate_per_kw, locktime)
42624264
.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)