Skip to content

Commit b0d96ba

Browse files
committed
Sort out PendingSplicePre and -Post, new spliced for ChannelContext and OutboundV2Channel
1 parent 0037ddf commit b0d96ba

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

lightning/src/ln/channel.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4608,7 +4608,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
46084608
latest_monitor_update_id: self.latest_monitor_update_id,
46094609
shutdown_scriptpubkey: self.shutdown_scriptpubkey.clone(),
46104610
destination_script: self.destination_script.clone(),
4611-
// holder_commitment_point: self.holder_commitment_point,
46124611
cur_counterparty_commitment_transaction_number: self.cur_counterparty_commitment_transaction_number,
46134612
value_to_self_msat: self.value_to_self_msat,
46144613
pending_inbound_htlcs: self.pending_inbound_htlcs.clone(),
@@ -4778,7 +4777,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
47784777
// self.channel_state = ChannelState::NegotiatingFunding(
47794778
// NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT
47804779
// );
4781-
log_info!(logger, "Splicing process started, old channel value {}, outgoing {}, channel_id {}",
4780+
log_info!(logger, "Splicing process started, new channel value {}, outgoing {}, channel_id {}",
47824781
self.channel_value_satoshis, is_outgoing, self.channel_id);
47834782
}
47844783

@@ -9818,6 +9817,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
98189817
our_funding_inputs: funding_inputs,
98199818
},
98209819
interactive_tx_constructor: None,
9820+
#[cfg(splicing)]
98219821
pending_splice_post: None,
98229822
};
98239823
Ok(chan)
@@ -9827,7 +9827,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
98279827
#[cfg(splicing)]
98289828
pub fn new_spliced<L: Deref>(
98299829
is_outbound: bool,
9830-
pre_splice_channel: &mut FundedChannel<SP>,
9830+
pre_splice_channel: &FundedChannel<SP>,
98319831
signer_provider: &SP,
98329832
counterparty_funding_pubkey: &PublicKey,
98339833
our_funding_contribution: i64,
@@ -9860,7 +9860,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
98609860

98619861
let context = ChannelContext::new_for_splice(
98629862
&pre_splice_channel.context,
9863-
true,
9863+
is_outbound,
98649864
counterparty_funding_pubkey,
98659865
our_funding_contribution,
98669866
their_funding_contribution,
@@ -10160,7 +10160,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
1016010160
#[cfg(splicing)]
1016110161
pending_splice_pre: None,
1016210162
#[cfg(splicing)]
10163-
pending_splice_post: None,
10163+
pending_splice_post: self.pending_splice_post,
1016410164
};
1016510165

1016610166
Ok(channel)

lightning/src/ln/functional_tests_splice.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ fn test_v1_splice_in() {
221221

222222
// ==== Channel is now ready for normal operation
223223

224+
// Expected balances
225+
let mut exp_balance1 = 1000 * channel_value_sat;
226+
let mut exp_balance2 = 0;
227+
224228
// === Start of Splicing
225229
println!("Start of Splicing ..., channel_id {}", channel_id2);
226230

@@ -276,8 +280,8 @@ fn test_v1_splice_in() {
276280
assert!(channel.is_usable);
277281
assert!(channel.is_channel_ready);
278282
assert_eq!(channel.channel_value_satoshis, channel_value_sat);
279-
assert_eq!(channel.outbound_capacity_msat, 0);
280-
assert!(channel.funding_txo.is_some());
283+
assert_eq!(channel.outbound_capacity_msat, exp_balance2);
284+
assert_eq!(channel.funding_txo.unwrap().txid, funding_tx.compute_txid());
281285
assert!(channel.confirmations.unwrap() > 0);
282286
}
283287

@@ -295,9 +299,9 @@ fn test_v1_splice_in() {
295299
assert_eq!(channel.channel_value_satoshis, channel_value_sat);
296300
assert_eq!(
297301
channel.outbound_capacity_msat,
298-
1000 * (channel_value_sat - channel_reserve_amnt_sat)
302+
exp_balance1 - 1000 * channel_reserve_amnt_sat
299303
);
300-
assert!(channel.funding_txo.is_some());
304+
assert_eq!(channel.funding_txo.unwrap().txid, funding_tx.compute_txid());
301305
assert!(channel.confirmations.unwrap() > 0);
302306
}
303307

0 commit comments

Comments
 (0)