Skip to content

Commit ca51224

Browse files
committed
Sort out PendingSplicePre and -Post, new_spliced for ChannelContext and OutboundV2Channel
1 parent 8d767cd commit ca51224

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lightning/src/ln/channel.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4909,7 +4909,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
49094909
latest_monitor_update_id: self.latest_monitor_update_id,
49104910
shutdown_scriptpubkey: self.shutdown_scriptpubkey.clone(),
49114911
destination_script: self.destination_script.clone(),
4912-
// holder_commitment_point: self.holder_commitment_point,
49134912
cur_counterparty_commitment_transaction_number: self.cur_counterparty_commitment_transaction_number,
49144913
// value_to_self_msat: self.value_to_self_msat,
49154914
pending_inbound_htlcs: self.pending_inbound_htlcs.clone(),
@@ -10364,6 +10363,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
1036410363
},
1036510364
interactive_tx_constructor: None,
1036610365
interactive_tx_signing_session: None,
10366+
#[cfg(splicing)]
1036710367
pending_splice_post: None,
1036810368
};
1036910369
Ok(chan)
@@ -10373,7 +10373,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
1037310373
#[cfg(splicing)]
1037410374
pub fn new_spliced<L: Deref>(
1037510375
is_outbound: bool,
10376-
pre_splice_channel: &mut FundedChannel<SP>,
10376+
pre_splice_channel: &FundedChannel<SP>,
1037710377
signer_provider: &SP,
1037810378
// counterparty_funding_pubkey: &PublicKey,
1037910379
our_funding_contribution: i64,
@@ -10407,7 +10407,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
1040710407
let (context, funding) = ChannelContext::new_for_splice(
1040810408
&pre_splice_channel.context,
1040910409
&pre_splice_channel.funding,
10410-
true,
10410+
is_outbound,
1041110411
// counterparty_funding_pubkey,
1041210412
our_funding_contribution,
1041310413
their_funding_contribution,

lightning/src/ln/functional_tests_splice.rs

+8-4
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)