Skip to content

Commit ba7a6b0

Browse files
committed
Sort out PendingSplicePre and -Post, new_spliced for ChannelContext and OutboundV2Channel
1 parent 40d4960 commit ba7a6b0

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4736,7 +4736,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
47364736
latest_monitor_update_id: self.latest_monitor_update_id,
47374737
shutdown_scriptpubkey: self.shutdown_scriptpubkey.clone(),
47384738
destination_script: self.destination_script.clone(),
4739-
// holder_commitment_point: self.holder_commitment_point,
47404739
cur_counterparty_commitment_transaction_number: self.cur_counterparty_commitment_transaction_number,
47414740
value_to_self_msat: self.value_to_self_msat,
47424741
pending_inbound_htlcs: self.pending_inbound_htlcs.clone(),
@@ -4904,7 +4903,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
49044903
// self.channel_state = ChannelState::NegotiatingFunding(
49054904
// NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT
49064905
// );
4907-
log_info!(logger, "Splicing process started, old channel value {}, outgoing {}, channel_id {}",
4906+
log_info!(logger, "Splicing process started, new channel value {}, outgoing {}, channel_id {}",
49084907
self.channel_value_satoshis, is_outgoing, self.channel_id);
49094908
}
49104909

@@ -9909,6 +9908,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
99099908
our_funding_inputs: funding_inputs,
99109909
},
99119910
interactive_tx_constructor: None,
9911+
#[cfg(splicing)]
99129912
pending_splice_post: None,
99139913
};
99149914
Ok(chan)
@@ -9918,7 +9918,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
99189918
#[cfg(splicing)]
99199919
pub fn new_spliced<L: Deref>(
99209920
is_outbound: bool,
9921-
pre_splice_channel: &mut FundedChannel<SP>,
9921+
pre_splice_channel: &FundedChannel<SP>,
99229922
signer_provider: &SP,
99239923
counterparty_funding_pubkey: &PublicKey,
99249924
our_funding_contribution: i64,
@@ -9951,7 +9951,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
99519951

99529952
let context = ChannelContext::new_for_splice(
99539953
&pre_splice_channel.context,
9954-
true,
9954+
is_outbound,
99559955
counterparty_funding_pubkey,
99569956
our_funding_contribution,
99579957
their_funding_contribution,

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)