Use struct instead of enum for SpliceContribution
What changed, and why it matters
This commit is a straightforward internal code cleanup. It changes how a data structure called SpliceContribution is represented in the code—from a choice between two fixed shapes (an enum) to a more flexible container (a struct) with helper constructors. This prepares the code for a future feature (mixed splice-in/splice-out) but does not change any security-sensitive behavior, fix a bug, or alter how user funds are handled.
No security action required. Treat as a normal refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors SpliceContribution from an enum with SpliceIn and SpliceOut variants into a struct holding value (SignedAmount), inputs, outputs, and change_script. It adds splice_in() and splice_out() constructors that preserve the previous semantics, updates all call sites in tests and fuzz targets, and keeps the existing pub(super) accessor methods returning the same values. No validation logic, protocol handling, or cryptographic operations are modified.
Changed components
lightning/src/ln/funding.rs (SpliceContribution definition and constructors)lightning/src/ln/splicing_tests.rs (test call sites)lightning-tests/src/upgrade_downgrade_tests.rs (test call site)fuzz/src/chanmon_consistency.rs (fuzz target call sites)Inspect captured patch +153 / −205
diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs
index aca2324..ba3fc90 100644
--- a/fuzz/src/chanmon_consistency.rs
+++ b/fuzz/src/chanmon_consistency.rs
@@ -1860,11 +1860,8 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
0xa0 => {
let input = FundingTxInput::new_p2wpkh(coinbase_tx.clone(), 0).unwrap();
- let contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(10_000),
- inputs: vec![input],
- change_script: None,
- };
+ let contribution =
+ SpliceContribution::splice_in(Amount::from_sat(10_000), vec![input], None);
let funding_feerate_sat_per_kw = fee_est_a.ret_val.load(atomic::Ordering::Acquire);
if let Err(e) = nodes[0].splice_channel(
&chan_a_id,
@@ -1882,11 +1879,8 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
},
0xa1 => {
let input = FundingTxInput::new_p2wpkh(coinbase_tx.clone(), 1).unwrap();
- let contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(10_000),
- inputs: vec![input],
- change_script: None,
- };
+ let contribution =
+ SpliceContribution::splice_in(Amount::from_sat(10_000), vec![input], None);
let funding_feerate_sat_per_kw = fee_est_b.ret_val.load(atomic::Ordering::Acquire);
if let Err(e) = nodes[1].splice_channel(
&chan_a_id,
@@ -1904,11 +1898,8 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
},
0xa2 => {
let input = FundingTxInput::new_p2wpkh(coinbase_tx.clone(), 0).unwrap();
- let contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(10_000),
- inputs: vec![input],
- change_script: None,
- };
+ let contribution =
+ SpliceContribution::splice_in(Amount::from_sat(10_000), vec![input], None);
let funding_feerate_sat_per_kw = fee_est_b.ret_val.load(atomic::Ordering::Acquire);
if let Err(e) = nodes[1].splice_channel(
&chan_b_id,
@@ -1926,11 +1917,8 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
},
0xa3 => {
let input = FundingTxInput::new_p2wpkh(coinbase_tx.clone(), 1).unwrap();
- let contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(10_000),
- inputs: vec![input],
- change_script: None,
- };
+ let contribution =
+ SpliceContribution::splice_in(Amount::from_sat(10_000), vec![input], None);
let funding_feerate_sat_per_kw = fee_est_c.ret_val.load(atomic::Ordering::Acquire);
if let Err(e) = nodes[2].splice_channel(
&chan_b_id,
@@ -1958,12 +1946,10 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
.map(|chan| chan.outbound_capacity_msat)
.unwrap();
if outbound_capacity_msat >= 20_000_000 {
- let contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS),
- script_pubkey: coinbase_tx.output[0].script_pubkey.clone(),
- }],
- };
+ let contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS),
+ script_pubkey: coinbase_tx.output[0].script_pubkey.clone(),
+ }]);
let funding_feerate_sat_per_kw =
fee_est_a.ret_val.load(atomic::Ordering::Acquire);
if let Err(e) = nodes[0].splice_channel(
@@ -1989,12 +1975,10 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
.map(|chan| chan.outbound_capacity_msat)
.unwrap();
if outbound_capacity_msat >= 20_000_000 {
- let contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS),
- script_pubkey: coinbase_tx.output[1].script_pubkey.clone(),
- }],
- };
+ let contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS),
+ script_pubkey: coinbase_tx.output[1].script_pubkey.clone(),
+ }]);
let funding_feerate_sat_per_kw =
fee_est_b.ret_val.load(atomic::Ordering::Acquire);
if let Err(e) = nodes[1].splice_channel(
@@ -2020,12 +2004,10 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
.map(|chan| chan.outbound_capacity_msat)
.unwrap();
if outbound_capacity_msat >= 20_000_000 {
- let contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS),
- script_pubkey: coinbase_tx.output[1].script_pubkey.clone(),
- }],
- };
+ let contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS),
+ script_pubkey: coinbase_tx.output[1].script_pubkey.clone(),
+ }]);
let funding_feerate_sat_per_kw =
fee_est_b.ret_val.load(atomic::Ordering::Acquire);
if let Err(e) = nodes[1].splice_channel(
@@ -2051,12 +2033,10 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
.map(|chan| chan.outbound_capacity_msat)
.unwrap();
if outbound_capacity_msat >= 20_000_000 {
- let contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS),
- script_pubkey: coinbase_tx.output[2].script_pubkey.clone(),
- }],
- };
+ let contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS),
+ script_pubkey: coinbase_tx.output[2].script_pubkey.clone(),
+ }]);
let funding_feerate_sat_per_kw =
fee_est_c.ret_val.load(atomic::Ordering::Acquire);
if let Err(e) = nodes[2].splice_channel(
diff --git a/lightning-tests/src/upgrade_downgrade_tests.rs b/lightning-tests/src/upgrade_downgrade_tests.rs
index 19c50e8..8df6703 100644
--- a/lightning-tests/src/upgrade_downgrade_tests.rs
+++ b/lightning-tests/src/upgrade_downgrade_tests.rs
@@ -451,12 +451,10 @@ fn do_test_0_1_htlc_forward_after_splice(fail_htlc: bool) {
reconnect_b_c_args.send_announcement_sigs = (true, true);
reconnect_nodes(reconnect_b_c_args);
- let contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(1_000),
- script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
- }],
- };
+ let contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(1_000),
+ script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
+ }]);
let splice_tx = splice_channel(&nodes[0], &nodes[1], ChannelId(chan_id_bytes_a), contribution);
for node in nodes.iter() {
mine_transaction(node, &splice_tx);
diff --git a/lightning/src/ln/funding.rs b/lightning/src/ln/funding.rs
index f80b2b6..b7f8740 100644
--- a/lightning/src/ln/funding.rs
+++ b/lightning/src/ln/funding.rs
@@ -20,69 +20,62 @@ use crate::sign::{P2TR_KEY_PATH_WITNESS_WEIGHT, P2WPKH_WITNESS_WEIGHT};
/// The components of a splice's funding transaction that are contributed by one party.
#[derive(Debug, Clone)]
-pub enum SpliceContribution {
- /// When funds are added to a channel.
- SpliceIn {
- /// The amount to contribute to the splice.
- value: Amount,
-
- /// The inputs included in the splice's funding transaction to meet the contributed amount
- /// plus fees. Any excess amount will be sent to a change output.
- inputs: Vec<FundingTxInput>,
-
- /// An optional change output script. This will be used if needed or, when not set,
- /// generated using [`SignerProvider::get_destination_script`].
- ///
- /// [`SignerProvider::get_destination_script`]: crate::sign::SignerProvider::get_destination_script
- change_script: Option<ScriptBuf>,
- },
- /// When funds are removed from a channel.
- SpliceOut {
- /// The outputs to include in the splice's funding transaction. The total value of all
- /// outputs plus fees will be the amount that is removed.
- outputs: Vec<TxOut>,
- },
+pub struct SpliceContribution {
+ /// The amount to contribute to the splice.
+ value: SignedAmount,
+
+ /// The inputs included in the splice's funding transaction to meet the contributed amount
+ /// plus fees. Any excess amount will be sent to a change output.
+ inputs: Vec<FundingTxInput>,
+
+ /// The outputs to include in the splice's funding transaction. The total value of all
+ /// outputs plus fees will be the amount that is removed.
+ outputs: Vec<TxOut>,
+
+ /// An optional change output script. This will be used if needed or, when not set,
+ /// generated using [`SignerProvider::get_destination_script`].
+ ///
+ /// [`SignerProvider::get_destination_script`]: crate::sign::SignerProvider::get_destination_script
+ change_script: Option<ScriptBuf>,
}
impl SpliceContribution {
+ /// Creates a contribution for when funds are only added to a channel.
+ pub fn splice_in(
+ value: Amount, inputs: Vec<FundingTxInput>, change_script: Option<ScriptBuf>,
+ ) -> Self {
+ let value_added = value.to_signed().unwrap_or(SignedAmount::MAX);
+
+ Self { value: value_added, inputs, outputs: vec![], change_script }
+ }
+
+ /// Creates a contribution for when funds are only removed from a channel.
+ pub fn splice_out(outputs: Vec<TxOut>) -> Self {
+ let value_removed = outputs
+ .iter()
+ .map(|txout| txout.value)
+ .sum::<Amount>()
+ .to_signed()
+ .unwrap_or(SignedAmount::MAX);
+
+ Self { value: -value_removed, inputs: vec![], outputs, change_script: None }
+ }
+
pub(super) fn value(&self) -> SignedAmount {
- match self {
- SpliceContribution::SpliceIn { value, .. } => {
- value.to_signed().unwrap_or(SignedAmount::MAX)
- },
- SpliceContribution::SpliceOut { outputs } => {
- let value_removed = outputs
- .iter()
- .map(|txout| txout.value)
- .sum::<Amount>()
- .to_signed()
- .unwrap_or(SignedAmount::MAX);
- -value_removed
- },
- }
+ self.value
}
pub(super) fn inputs(&self) -> &[FundingTxInput] {
- match self {
- SpliceContribution::SpliceIn { inputs, .. } => &inputs[..],
- SpliceContribution::SpliceOut { .. } => &[],
- }
+ &self.inputs[..]
}
pub(super) fn outputs(&self) -> &[TxOut] {
- match self {
- SpliceContribution::SpliceIn { .. } => &[],
- SpliceContribution::SpliceOut { outputs } => &outputs[..],
- }
+ &self.outputs[..]
}
pub(super) fn into_tx_parts(self) -> (Vec<FundingTxInput>, Vec<TxOut>, Option<ScriptBuf>) {
- match self {
- SpliceContribution::SpliceIn { inputs, change_script, .. } => {
- (inputs, vec![], change_script)
- },
- SpliceContribution::SpliceOut { outputs } => (vec![], outputs, None),
- }
+ let SpliceContribution { value: _, inputs, outputs, change_script } = self;
+ (inputs, outputs, change_script)
}
}
diff --git a/lightning/src/ln/splicing_tests.rs b/lightning/src/ln/splicing_tests.rs
index a05c0bd..5ffdafd 100644
--- a/lightning/src/ln/splicing_tests.rs
+++ b/lightning/src/ln/splicing_tests.rs
@@ -47,11 +47,7 @@ fn test_splicing_not_supported_api_error() {
let (_, _, channel_id, _) = create_announced_chan_between_nodes(&nodes, 0, 1);
- let bs_contribution = SpliceContribution::SpliceIn {
- value: Amount::ZERO,
- inputs: Vec::new(),
- change_script: None,
- };
+ let bs_contribution = SpliceContribution::splice_in(Amount::ZERO, Vec::new(), None);
let res = nodes[1].node.splice_channel(
&channel_id,
@@ -113,11 +109,8 @@ fn test_v1_splice_in_negative_insufficient_inputs() {
let funding_inputs =
create_dual_funding_utxos_with_prev_txs(&nodes[0], &[extra_splice_funding_input_sats]);
- let contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(splice_in_sats),
- inputs: funding_inputs,
- change_script: None,
- };
+ let contribution =
+ SpliceContribution::splice_in(Amount::from_sat(splice_in_sats), funding_inputs, None);
// Initiate splice-in, with insufficient input contribution
let res = nodes[0].node.splice_channel(
@@ -490,12 +483,10 @@ fn do_test_splice_state_reset_on_disconnect(reload: bool) {
let (_, _, channel_id, _) =
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100_000, 50_000_000);
- let contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(1_000),
- script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
- }],
- };
+ let contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(1_000),
+ script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
+ }]);
nodes[0]
.node
.splice_channel(
@@ -748,12 +739,10 @@ fn test_config_reject_inbound_splices() {
let (_, _, channel_id, _) =
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100_000, 50_000_000);
- let contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(1_000),
- script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
- }],
- };
+ let contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(1_000),
+ script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
+ }]);
nodes[0]
.node
.splice_channel(
@@ -811,14 +800,14 @@ fn test_splice_in() {
let coinbase_tx1 = provide_anchor_reserves(&nodes);
let coinbase_tx2 = provide_anchor_reserves(&nodes);
- let initiator_contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(initial_channel_value_sat * 2),
- inputs: vec![
+ let initiator_contribution = SpliceContribution::splice_in(
+ Amount::from_sat(initial_channel_value_sat * 2),
+ vec![
FundingTxInput::new_p2wpkh(coinbase_tx1, 0).unwrap(),
FundingTxInput::new_p2wpkh(coinbase_tx2, 0).unwrap(),
],
- change_script: Some(nodes[0].wallet_source.get_change_script().unwrap()),
- };
+ Some(nodes[0].wallet_source.get_change_script().unwrap()),
+ );
let splice_tx = splice_channel(&nodes[0], &nodes[1], channel_id, initiator_contribution);
mine_transaction(&nodes[0], &splice_tx);
@@ -850,18 +839,16 @@ fn test_splice_out() {
let _ = send_payment(&nodes[0], &[&nodes[1]], 100_000);
- let initiator_contribution = SpliceContribution::SpliceOut {
- outputs: vec![
- TxOut {
- value: Amount::from_sat(initial_channel_value_sat / 4),
- script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
- },
- TxOut {
- value: Amount::from_sat(initial_channel_value_sat / 4),
- script_pubkey: nodes[1].wallet_source.get_change_script().unwrap(),
- },
- ],
- };
+ let initiator_contribution = SpliceContribution::splice_out(vec![
+ TxOut {
+ value: Amount::from_sat(initial_channel_value_sat / 4),
+ script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
+ },
+ TxOut {
+ value: Amount::from_sat(initial_channel_value_sat / 4),
+ script_pubkey: nodes[1].wallet_source.get_change_script().unwrap(),
+ },
+ ]);
let splice_tx = splice_channel(&nodes[0], &nodes[1], channel_id, initiator_contribution);
mine_transaction(&nodes[0], &splice_tx);
@@ -919,11 +906,11 @@ fn do_test_splice_commitment_broadcast(splice_status: SpliceStatus, claim_htlcs:
let payment_amount = 1_000_000;
let (preimage1, payment_hash1, ..) = route_payment(&nodes[0], &[&nodes[1]], payment_amount);
let splice_in_amount = initial_channel_capacity / 2;
- let initiator_contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(splice_in_amount),
- inputs: vec![FundingTxInput::new_p2wpkh(coinbase_tx.clone(), 0).unwrap()],
- change_script: Some(nodes[0].wallet_source.get_change_script().unwrap()),
- };
+ let initiator_contribution = SpliceContribution::splice_in(
+ Amount::from_sat(splice_in_amount),
+ vec![FundingTxInput::new_p2wpkh(coinbase_tx.clone(), 0).unwrap()],
+ Some(nodes[0].wallet_source.get_change_script().unwrap()),
+ );
let splice_tx = splice_channel(&nodes[0], &nodes[1], channel_id, initiator_contribution);
let (preimage2, payment_hash2, ..) = route_payment(&nodes[0], &[&nodes[1]], payment_amount);
let htlc_expiry = nodes[0].best_block_info().1 + TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS;
@@ -1117,18 +1104,16 @@ fn do_test_splice_reestablish(reload: bool, async_monitor_update: bool) {
route_payment(&nodes[0], &[&nodes[1]], 1_000_000);
// Negotiate the splice up until the nodes exchange `tx_complete`.
- let initiator_contribution = SpliceContribution::SpliceOut {
- outputs: vec![
- TxOut {
- value: Amount::from_sat(initial_channel_value_sat / 4),
- script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
- },
- TxOut {
- value: Amount::from_sat(initial_channel_value_sat / 4),
- script_pubkey: nodes[1].wallet_source.get_change_script().unwrap(),
- },
- ],
- };
+ let initiator_contribution = SpliceContribution::splice_out(vec![
+ TxOut {
+ value: Amount::from_sat(initial_channel_value_sat / 4),
+ script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
+ },
+ TxOut {
+ value: Amount::from_sat(initial_channel_value_sat / 4),
+ script_pubkey: nodes[1].wallet_source.get_change_script().unwrap(),
+ },
+ ]);
let initial_commit_sig_for_acceptor =
negotiate_splice_tx(&nodes[0], &nodes[1], channel_id, initiator_contribution);
assert_eq!(initial_commit_sig_for_acceptor.htlc_signatures.len(), 1);
@@ -1405,12 +1390,10 @@ fn do_test_propose_splice_while_disconnected(reload: bool, use_0conf: bool) {
nodes[1].node.peer_disconnected(node_id_0);
let splice_out_sat = initial_channel_value_sat / 4;
- let node_0_contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(splice_out_sat),
- script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
- }],
- };
+ let node_0_contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(splice_out_sat),
+ script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
+ }]);
nodes[0]
.node
.splice_channel(
@@ -1423,12 +1406,10 @@ fn do_test_propose_splice_while_disconnected(reload: bool, use_0conf: bool) {
.unwrap();
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
- let node_1_contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(splice_out_sat),
- script_pubkey: nodes[1].wallet_source.get_change_script().unwrap(),
- }],
- };
+ let node_1_contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(splice_out_sat),
+ script_pubkey: nodes[1].wallet_source.get_change_script().unwrap(),
+ }]);
nodes[1]
.node
.splice_channel(
@@ -1681,11 +1662,11 @@ fn disconnect_on_unexpected_interactive_tx_message() {
let coinbase_tx = provide_anchor_reserves(&nodes);
let splice_in_amount = initial_channel_capacity / 2;
- let contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(splice_in_amount),
- inputs: vec![FundingTxInput::new_p2wpkh(coinbase_tx, 0).unwrap()],
- change_script: Some(nodes[0].wallet_source.get_change_script().unwrap()),
- };
+ let contribution = SpliceContribution::splice_in(
+ Amount::from_sat(splice_in_amount),
+ vec![FundingTxInput::new_p2wpkh(coinbase_tx, 0).unwrap()],
+ Some(nodes[0].wallet_source.get_change_script().unwrap()),
+ );
// Complete interactive-tx construction, but fail by having the acceptor send a duplicate
// tx_complete instead of commitment_signed.
@@ -1721,11 +1702,11 @@ fn fail_splice_on_interactive_tx_error() {
let coinbase_tx = provide_anchor_reserves(&nodes);
let splice_in_amount = initial_channel_capacity / 2;
- let contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(splice_in_amount),
- inputs: vec![FundingTxInput::new_p2wpkh(coinbase_tx, 0).unwrap()],
- change_script: Some(nodes[0].wallet_source.get_change_script().unwrap()),
- };
+ let contribution = SpliceContribution::splice_in(
+ Amount::from_sat(splice_in_amount),
+ vec![FundingTxInput::new_p2wpkh(coinbase_tx, 0).unwrap()],
+ Some(nodes[0].wallet_source.get_change_script().unwrap()),
+ );
// Fail during interactive-tx construction by having the acceptor echo back tx_add_input instead
// of sending tx_complete. The failure occurs because the serial id will have the wrong parity.
@@ -1827,11 +1808,11 @@ fn fail_splice_on_tx_abort() {
let coinbase_tx = provide_anchor_reserves(&nodes);
let splice_in_amount = initial_channel_capacity / 2;
- let contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(splice_in_amount),
- inputs: vec![FundingTxInput::new_p2wpkh(coinbase_tx, 0).unwrap()],
- change_script: Some(nodes[0].wallet_source.get_change_script().unwrap()),
- };
+ let contribution = SpliceContribution::splice_in(
+ Amount::from_sat(splice_in_amount),
+ vec![FundingTxInput::new_p2wpkh(coinbase_tx, 0).unwrap()],
+ Some(nodes[0].wallet_source.get_change_script().unwrap()),
+ );
// Fail during interactive-tx construction by having the acceptor send tx_abort instead of
// tx_complete.
@@ -1881,11 +1862,11 @@ fn fail_splice_on_channel_close() {
let coinbase_tx = provide_anchor_reserves(&nodes);
let splice_in_amount = initial_channel_capacity / 2;
- let contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(splice_in_amount),
- inputs: vec![FundingTxInput::new_p2wpkh(coinbase_tx, 0).unwrap()],
- change_script: Some(nodes[0].wallet_source.get_change_script().unwrap()),
- };
+ let contribution = SpliceContribution::splice_in(
+ Amount::from_sat(splice_in_amount),
+ vec![FundingTxInput::new_p2wpkh(coinbase_tx, 0).unwrap()],
+ Some(nodes[0].wallet_source.get_change_script().unwrap()),
+ );
// Close the channel before completion of interactive-tx construction.
let _ = complete_splice_handshake(initiator, acceptor, channel_id, contribution.clone());
@@ -1932,11 +1913,11 @@ fn fail_quiescent_action_on_channel_close() {
let coinbase_tx = provide_anchor_reserves(&nodes);
let splice_in_amount = initial_channel_capacity / 2;
- let contribution = SpliceContribution::SpliceIn {
- value: Amount::from_sat(splice_in_amount),
- inputs: vec![FundingTxInput::new_p2wpkh(coinbase_tx, 0).unwrap()],
- change_script: Some(nodes[0].wallet_source.get_change_script().unwrap()),
- };
+ let contribution = SpliceContribution::splice_in(
+ Amount::from_sat(splice_in_amount),
+ vec![FundingTxInput::new_p2wpkh(coinbase_tx, 0).unwrap()],
+ Some(nodes[0].wallet_source.get_change_script().unwrap()),
+ );
// Close the channel before completion of STFU handshake.
initiator
@@ -2025,23 +2006,19 @@ fn do_test_splice_with_inflight_htlc_forward_and_resolution(expire_scid_pre_forw
// Splice both channels, lock them, and connect enough blocks to trigger the legacy SCID pruning
// logic while the HTLC is still pending.
- let contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(1_000),
- script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
- }],
- };
+ let contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(1_000),
+ script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
+ }]);
let splice_tx_0_1 = splice_channel(&nodes[0], &nodes[1], channel_id_0_1, contribution);
for node in &nodes {
mine_transaction(node, &splice_tx_0_1);
}
- let contribution = SpliceContribution::SpliceOut {
- outputs: vec![TxOut {
- value: Amount::from_sat(1_000),
- script_pubkey: nodes[1].wallet_source.get_change_script().unwrap(),
- }],
- };
+ let contribution = SpliceContribution::splice_out(vec![TxOut {
+ value: Amount::from_sat(1_000),
+ script_pubkey: nodes[1].wallet_source.get_change_script().unwrap(),
+ }]);
let splice_tx_1_2 = splice_channel(&nodes[1], &nodes[2], channel_id_1_2, contribution);
for node in &nodes {
mine_transaction(node, &splice_tx_1_2);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.