Remove splicing rust cfg flag
What changed, and why it matters
This commit removes the 'splicing' feature flag from the rust-lightning project, making splicing-related code always compile instead of being conditionally included. It is a build-system and code-cleanup change, not a security fix. There is no evidence in the commit of a vulnerability being patched.
No security action required. Treat as normal build/CI cleanup. Reviewers may want to confirm that unconditionally enabling splicing does not introduce compilation warnings or test failures in downstream configurations.
Security signals we found
No security signals present: change is a feature-flag removal/cleanup
Evidence from the diff
The commit deletes the splicing Rust cfg flag from Cargo.toml, CI scripts, and all conditional compilation attributes across the codebase. Splicing message handlers, wire parsing, channel state machine logic, and tests are now compiled unconditionally. The diff also includes a minor test variable mutability fix (let mut exp_balance1 -> let exp_balance1) and a doc link addition. No security-relevant behavioral changes or bug fixes are present.
Changed components
Cargo.tomlci/ci-tests.shlightning-net-tokiolightning/src/ln/channel.rslightning/src/ln/channelmanager.rslightning/src/ln/funding.rslightning/src/ln/msgs.rslightning/src/ln/peer_handler.rslightning/src/ln/wire.rslightning/src/ln/splicing_tests.rslightning/src/util/test_utils.rsInspect captured patch +12 / −151
diff --git a/Cargo.toml b/Cargo.toml
index b89127b..f9f7406 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -65,7 +65,6 @@ check-cfg = [
"cfg(ldk_test_vectors)",
"cfg(taproot)",
"cfg(require_route_graph_test)",
- "cfg(splicing)",
"cfg(simple_close)",
"cfg(peer_storage)",
]
diff --git a/ci/ci-tests.sh b/ci/ci-tests.sh
index 1c8a536..d2bd4fa 100755
--- a/ci/ci-tests.sh
+++ b/ci/ci-tests.sh
@@ -151,8 +151,6 @@ fi
echo -e "\n\nTest cfg-flag builds"
RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
-RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
-[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=async_payments" cargo test --verbose --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=simple_close" cargo test --verbose --color always -p lightning
diff --git a/lightning-net-tokio/src/lib.rs b/lightning-net-tokio/src/lib.rs
index 1d1d3c4..f238a7d 100644
--- a/lightning-net-tokio/src/lib.rs
+++ b/lightning-net-tokio/src/lib.rs
@@ -742,11 +742,8 @@ mod tests {
fn handle_open_channel_v2(&self, _their_node_id: PublicKey, _msg: &OpenChannelV2) {}
fn handle_accept_channel_v2(&self, _their_node_id: PublicKey, _msg: &AcceptChannelV2) {}
fn handle_stfu(&self, _their_node_id: PublicKey, _msg: &Stfu) {}
- #[cfg(splicing)]
fn handle_splice_init(&self, _their_node_id: PublicKey, _msg: &SpliceInit) {}
- #[cfg(splicing)]
fn handle_splice_ack(&self, _their_node_id: PublicKey, _msg: &SpliceAck) {}
- #[cfg(splicing)]
fn handle_splice_locked(&self, _their_node_id: PublicKey, _msg: &SpliceLocked) {}
fn handle_tx_add_input(&self, _their_node_id: PublicKey, _msg: &TxAddInput) {}
fn handle_tx_add_output(&self, _their_node_id: PublicKey, _msg: &TxAddOutput) {}
diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs
index 9747be7..5e8545c 100644
--- a/lightning/src/ln/channel.rs
+++ b/lightning/src/ln/channel.rs
@@ -24,9 +24,7 @@ use bitcoin::hashes::Hash;
use bitcoin::secp256k1::constants::PUBLIC_KEY_SIZE;
use bitcoin::secp256k1::{ecdsa::Signature, Secp256k1};
use bitcoin::secp256k1::{PublicKey, SecretKey};
-use bitcoin::{secp256k1, sighash, TxIn};
-#[cfg(splicing)]
-use bitcoin::{FeeRate, Sequence};
+use bitcoin::{secp256k1, sighash, FeeRate, Sequence, TxIn};
use crate::chain::chaininterface::{
fee_for_weight, ConfirmationTarget, FeeEstimator, LowerBoundedFeeEstimator,
@@ -38,9 +36,7 @@ use crate::chain::channelmonitor::{
use crate::chain::transaction::{OutPoint, TransactionData};
use crate::chain::BestBlock;
use crate::events::bump_transaction::{BASE_INPUT_WEIGHT, EMPTY_SCRIPT_SIG_WEIGHT};
-use crate::events::ClosureReason;
-#[cfg(splicing)]
-use crate::events::FundingInfo;
+use crate::events::{ClosureReason, FundingInfo};
use crate::ln::chan_utils;
use crate::ln::chan_utils::{
get_commitment_transaction_number_obscure_factor, max_htlcs, second_stage_tx_fees_sat,
@@ -59,15 +55,11 @@ use crate::ln::channelmanager::{
RAACommitmentOrder, SentHTLCId, BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT,
MIN_CLTV_EXPIRY_DELTA,
};
-use crate::ln::funding::FundingTxInput;
-#[cfg(splicing)]
-use crate::ln::funding::SpliceContribution;
-#[cfg(splicing)]
-use crate::ln::interactivetxs::calculate_change_output_value;
+use crate::ln::funding::{FundingTxInput, SpliceContribution};
use crate::ln::interactivetxs::{
- get_output_weight, AbortReason, HandleTxCompleteValue, InteractiveTxConstructor,
- InteractiveTxConstructorArgs, InteractiveTxMessageSend, InteractiveTxSigningSession,
- SharedOwnedInput, SharedOwnedOutput, TX_COMMON_FIELDS_WEIGHT,
+ calculate_change_output_value, get_output_weight, AbortReason, HandleTxCompleteValue,
+ InteractiveTxConstructor, InteractiveTxConstructorArgs, InteractiveTxMessageSend,
+ InteractiveTxSigningSession, SharedOwnedInput, SharedOwnedOutput, TX_COMMON_FIELDS_WEIGHT,
};
use crate::ln::msgs;
use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError, OnionErrorPacket};
@@ -76,7 +68,6 @@ use crate::ln::onion_utils::{
};
use crate::ln::script::{self, ShutdownScript};
use crate::ln::types::ChannelId;
-#[cfg(splicing)]
use crate::ln::LN_MAX_MSG_LEN;
use crate::routing::gossip::NodeId;
use crate::sign::ecdsa::EcdsaChannelSigner;
@@ -1733,7 +1724,6 @@ where
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
match &mut self.phase {
ChannelPhase::UnfundedV2(chan) => chan.interactive_tx_constructor.as_mut(),
- #[cfg(splicing)]
ChannelPhase::Funded(chan) => chan.interactive_tx_constructor_mut(),
_ => None,
}
@@ -1754,9 +1744,6 @@ where
ChannelPhase::UnfundedV2(pending_v2_channel) => {
pending_v2_channel.interactive_tx_constructor.take()
},
- #[cfg(not(splicing))]
- ChannelPhase::Funded(_) => unreachable!(),
- #[cfg(splicing)]
ChannelPhase::Funded(funded_channel) => funded_channel
.pending_splice
.as_mut()
@@ -1897,12 +1884,6 @@ where
ChannelPhase::UnfundedV2(pending_v2_channel) => {
pending_v2_channel.interactive_tx_constructor.take().is_some()
},
- #[cfg(not(splicing))]
- ChannelPhase::Funded(_) => {
- let err = "Got an unexpected tx_abort message: This is an funded channel and splicing is not supported";
- return Err(ChannelError::Warn(err.into()));
- },
- #[cfg(splicing)]
ChannelPhase::Funded(funded_channel) => funded_channel
.pending_splice
.as_mut()
@@ -1986,7 +1967,6 @@ where
return Ok(commitment_signed);
},
- #[cfg(splicing)]
ChannelPhase::Funded(chan) => {
if let Some(pending_splice) = chan.pending_splice.as_mut() {
if let Some(funding_negotiation) = pending_splice.funding_negotiation.take() {
@@ -2061,7 +2041,6 @@ where
context: chan.context,
interactive_tx_signing_session: chan.interactive_tx_signing_session,
holder_commitment_point,
- #[cfg(splicing)]
pending_splice: None,
quiescent_action: None,
};
@@ -2077,7 +2056,6 @@ where
res
},
ChannelPhase::Funded(mut funded_channel) => {
- #[cfg(splicing)]
let has_negotiated_pending_splice = funded_channel.pending_splice.as_ref()
.and_then(|pending_splice| pending_splice.funding_negotiation.as_ref())
.filter(|funding_negotiation| {
@@ -2085,7 +2063,6 @@ where
})
.map(|funding_negotiation| funding_negotiation.as_funding().is_some())
.unwrap_or(false);
- #[cfg(splicing)]
let session_received_commitment_signed = funded_channel
.interactive_tx_signing_session
.as_ref()
@@ -2093,7 +2070,6 @@ where
// Not having a signing session implies they've already sent `splice_locked`,
// which must always come after the initial commitment signed is sent.
.unwrap_or(true);
- #[cfg(splicing)]
let res = if has_negotiated_pending_splice && !session_received_commitment_signed {
funded_channel
.splice_initial_commitment_signed(msg, logger)
@@ -2103,10 +2079,6 @@ where
.map(|monitor_update_opt| (None, monitor_update_opt))
};
- #[cfg(not(splicing))]
- let res = funded_channel.commitment_signed(msg, logger)
- .map(|monitor_update_opt| (None, monitor_update_opt));
-
self.phase = ChannelPhase::Funded(funded_channel);
res
},
@@ -2391,7 +2363,6 @@ impl FundingScope {
self.channel_transaction_parameters.make_funding_redeemscript()
}
- #[cfg(splicing)]
fn holder_funding_pubkey(&self) -> &PublicKey {
&self.get_holder_pubkeys().funding_pubkey
}
@@ -2433,7 +2404,6 @@ impl FundingScope {
}
/// Constructs a `FundingScope` for splicing a channel.
- #[cfg(splicing)]
fn for_splice<SP: Deref>(
prev_funding: &Self, context: &ChannelContext<SP>, our_funding_contribution: SignedAmount,
their_funding_contribution: SignedAmount, counterparty_funding_pubkey: PublicKey,
@@ -2515,7 +2485,6 @@ impl FundingScope {
}
/// Compute the post-splice channel value from each counterparty's contributions.
- #[cfg(splicing)]
pub(super) fn compute_post_splice_value(
&self, our_funding_contribution: i64, their_funding_contribution: i64,
) -> u64 {
@@ -2526,7 +2495,6 @@ impl FundingScope {
}
/// Returns a `SharedOwnedInput` for using this `FundingScope` as the input to a new splice.
- #[cfg(splicing)]
fn to_splice_funding_input(&self) -> SharedOwnedInput {
let funding_txo = self.get_funding_txo().expect("funding_txo should be set");
let input = TxIn {
@@ -2556,13 +2524,11 @@ impl FundingScope {
}
// TODO: Remove once MSRV is at least 1.66
-#[cfg(splicing)]
trait AddSigned {
fn checked_add_signed(self, rhs: i64) -> Option<u64>;
fn saturating_add_signed(self, rhs: i64) -> u64;
}
-#[cfg(splicing)]
impl AddSigned for u64 {
fn checked_add_signed(self, rhs: i64) -> Option<u64> {
if rhs >= 0 {
@@ -2582,7 +2548,6 @@ impl AddSigned for u64 {
}
/// Info about a pending splice
-#[cfg(splicing)]
struct PendingSplice {
funding_negotiation: Option<FundingNegotiation>,
@@ -2593,14 +2558,12 @@ struct PendingSplice {
received_funding_txid: Option<Txid>,
}
-#[cfg(splicing)]
enum FundingNegotiation {
AwaitingAck(FundingNegotiationContext),
ConstructingTransaction(FundingScope, InteractiveTxConstructor),
AwaitingSignatures(FundingScope),
}
-#[cfg(splicing)]
impl FundingNegotiation {
fn as_funding(&self) -> Option<&FundingScope> {
match self {
@@ -2611,7 +2574,6 @@ impl FundingNegotiation {
}
}
-#[cfg(splicing)]
impl PendingSplice {
fn check_get_splice_locked<SP: Deref>(
&mut self, context: &ChannelContext<SP>, funding: &FundingScope, height: u32,
@@ -2671,7 +2633,6 @@ pub(crate) enum QuiescentAction {
pub(crate) enum StfuResponse {
Stfu(msgs::Stfu),
- #[cfg_attr(not(splicing), allow(unused))]
SpliceInit(msgs::SpliceInit),
}
@@ -4005,7 +3966,6 @@ where
}
/// Returns holder pubkeys to use for the channel.
- #[cfg(splicing)]
fn holder_pubkeys(&self, prev_funding_txid: Option<Txid>) -> ChannelPublicKeys {
match &self.holder_signer {
ChannelSignerType::Ecdsa(ecdsa) => ecdsa.pubkeys(prev_funding_txid, &self.secp_ctx),
@@ -6355,7 +6315,6 @@ fn get_v2_channel_reserve_satoshis(channel_value_satoshis: u64, dust_limit_satos
cmp::min(channel_value_satoshis, cmp::max(q, dust_limit_satoshis))
}
-#[cfg(splicing)]
fn check_splice_contribution_sufficient(
contribution: &SpliceContribution, is_initiator: bool, funding_feerate: FeeRate,
) -> Result<SignedAmount, String> {
@@ -6434,7 +6393,6 @@ fn estimate_v2_funding_transaction_fee(
/// the fees of the inputs, fees of the inputs weight, and for the initiator,
/// the fees of the common fields as well as the output and extra input weights.
/// Returns estimated (partial) fees as additional information
-#[cfg(splicing)]
#[rustfmt::skip]
fn check_v2_funding_inputs_sufficient(
contribution_amount: i64, funding_inputs: &[FundingTxInput], is_initiator: bool,
@@ -6504,7 +6462,6 @@ pub(super) struct FundingNegotiationContext {
impl FundingNegotiationContext {
/// Prepare and start interactive transaction negotiation.
/// If error occurs, it is caused by our side, not the counterparty.
- #[cfg(splicing)]
fn into_interactive_tx_constructor<SP: Deref, ES: Deref>(
self, context: &ChannelContext<SP>, funding: &FundingScope, signer_provider: &SP,
entropy_source: &ES, holder_node_id: PublicKey,
@@ -6614,7 +6571,6 @@ where
pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
holder_commitment_point: HolderCommitmentPoint,
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
- #[cfg(splicing)]
pending_splice: Option<PendingSplice>,
/// Once we become quiescent, if we're the initiator, there's some action we'll want to take.
@@ -6624,7 +6580,6 @@ where
quiescent_action: Option<QuiescentAction>,
}
-#[cfg(splicing)]
macro_rules! promote_splice_funding {
($self: expr, $funding: expr) => {{
let prev_funding_txid = $self.funding.get_funding_txid();
@@ -6733,7 +6688,6 @@ type BestBlockUpdatedRes = (
Option<msgs::AnnouncementSignatures>,
);
-#[cfg(splicing)]
pub struct SpliceFundingPromotion {
pub funding_txo: OutPoint,
pub monitor_update: Option<ChannelMonitorUpdate>,
@@ -6754,7 +6708,6 @@ where
self.context.force_shutdown(&self.funding, closure_reason)
}
- #[cfg(splicing)]
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
self.pending_splice
.as_mut()
@@ -7543,7 +7496,6 @@ where
/// Note that our `commitment_signed` send did not include a monitor update. This is due to:
/// 1. Updates cannot be made since the state machine is paused until `tx_signatures`.
/// 2. We're still able to abort negotiation until `tx_signatures`.
- #[cfg(splicing)]
pub fn splice_initial_commitment_signed<L: Deref>(
&mut self, msg: &msgs::CommitmentSigned, logger: &L,
) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
@@ -8549,7 +8501,6 @@ where
format!("Channel {} already received funding signatures", self.context.channel_id);
return Err(APIError::APIMisuseError { err });
}
- #[cfg(splicing)]
if let Some(pending_splice) = self.pending_splice.as_ref() {
if !pending_splice
.funding_negotiation
@@ -8602,7 +8553,6 @@ where
} else {
None
};
- #[cfg(splicing)]
debug_assert_eq!(self.pending_splice.is_some(), shared_input_signature.is_some());
let tx_signatures = msgs::TxSignatures {
@@ -9415,7 +9365,6 @@ where
// TODO(splicing): Add comment for spec requirements
if next_funding.should_retransmit(msgs::NextFundingFlag::CommitmentSigned) {
- #[cfg(splicing)]
let funding = self
.pending_splice
.as_ref()
@@ -9438,8 +9387,6 @@ where
)
)
})?;
- #[cfg(not(splicing))]
- let funding = &self.funding;
let commitment_signed = self.context.get_initial_commitment_signed_v2(&funding, logger)
// TODO(splicing): Support async signing
@@ -9563,7 +9510,6 @@ where
// those splice transactions, for which it hasn't received `splice_locked` yet:
// - MUST process `my_current_funding_locked` as if it was receiving `splice_locked`
// for this `txid`.
- #[cfg(splicing)]
let inferred_splice_locked = msg.my_current_funding_locked.as_ref().and_then(|funding_locked| {
self.pending_funding
.iter()
@@ -9579,8 +9525,6 @@ where
splice_txid,
})
});
- #[cfg(not(splicing))]
- let inferred_splice_locked = None;
if msg.next_local_commitment_number == next_counterparty_commitment_number {
if required_revoke.is_some() || self.context.signer_pending_revoke_and_ack {
@@ -10625,7 +10569,6 @@ where
}
/// Returns `Some` if a splice [`FundingScope`] was promoted.
- #[cfg(splicing)]
fn maybe_promote_splice_funding<NS: Deref, L: Deref>(
&mut self, node_signer: &NS, chain_hash: ChainHash, user_config: &UserConfig,
block_height: u32, logger: &L,
@@ -10749,11 +10692,8 @@ where
}
}
- #[cfg(splicing)]
let mut confirmed_funding_index = None;
- #[cfg(splicing)]
let mut funding_already_confirmed = false;
- #[cfg(splicing)]
for (index, funding) in self.pending_funding.iter_mut().enumerate() {
if self.context.check_for_funding_tx_confirmed(
funding, block_hash, height, index_in_block, &mut confirmed_tx, logger,
@@ -10769,7 +10709,6 @@ where
}
}
- #[cfg(splicing)]
if let Some(confirmed_funding_index) = confirmed_funding_index {
let pending_splice = match self.pending_splice.as_mut() {
Some(pending_splice) => pending_splice,
@@ -10905,9 +10844,7 @@ where
return Err(ClosureReason::FundingTimedOut);
}
- #[cfg(splicing)]
let mut confirmed_funding_index = None;
- #[cfg(splicing)]
for (index, funding) in self.pending_funding.iter().enumerate() {
if funding.funding_tx_confirmation_height != 0 {
if confirmed_funding_index.is_some() {
@@ -10919,7 +10856,6 @@ where
}
}
- #[cfg(splicing)]
if let Some(confirmed_funding_index) = confirmed_funding_index {
let pending_splice = match self.pending_splice.as_mut() {
Some(pending_splice) => pending_splice,
@@ -11275,7 +11211,6 @@ where
}
}
- #[cfg(splicing)]
fn maybe_get_my_current_funding_locked(&self) -> Option<msgs::FundingLocked> {
self.pending_splice
.as_ref()
@@ -11304,11 +11239,6 @@ where
})
}
- #[cfg(not(splicing))]
- fn maybe_get_my_current_funding_locked(&self) -> Option<msgs::FundingLocked> {
- None
- }
-
/// May panic if called on a channel that wasn't immediately-previously
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
#[rustfmt::skip]
@@ -11369,7 +11299,6 @@ where
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
/// - `change_script`: an option change output script. If `None` and needed, one will be
/// generated by `SignerProvider::get_destination_script`.
- #[cfg(splicing)]
pub fn splice_channel<L: Deref>(
&mut self, contribution: SpliceContribution, funding_feerate_per_kw: u32, locktime: u32,
logger: &L,
@@ -11478,7 +11407,6 @@ where
.map_err(|e| APIError::APIMisuseError { err: e.to_owned() })
}
- #[cfg(splicing)]
fn send_splice_init(
&mut self, instructions: SpliceInstructions,
) -> Result<msgs::SpliceInit, String> {
@@ -11533,7 +11461,6 @@ where
}
/// Checks during handling splice_init
- #[cfg(splicing)]
pub fn validate_splice_init(
&self, msg: &msgs::SpliceInit, our_funding_contribution: SignedAmount,
) -> Result<FundingScope, ChannelError> {
@@ -11589,7 +11516,6 @@ where
))
}
- #[cfg(splicing)]
fn validate_splice_contributions(
&self, our_funding_contribution: SignedAmount, their_funding_contribution: SignedAmount,
) -> Result<(), String> {
@@ -11679,7 +11605,6 @@ where
Ok(())
}
- #[cfg(splicing)]
pub(crate) fn splice_init<ES: Deref, L: Deref>(
&mut self, msg: &msgs::SpliceInit, our_funding_contribution_satoshis: i64,
signer_provider: &SP, entropy_source: &ES, holder_node_id: &PublicKey, logger: &L,
@@ -11751,7 +11676,6 @@ where
})
}
- #[cfg(splicing)]
pub(crate) fn splice_ack<ES: Deref, L: Deref>(
&mut self, msg: &msgs::SpliceAck, signer_provider: &SP, entropy_source: &ES,
holder_node_id: &PublicKey, logger: &L,
@@ -11807,8 +11731,6 @@ where
Ok(tx_msg_opt)
}
- /// Checks during handling splice_ack
- #[cfg(splicing)]
fn validate_splice_ack(&self, msg: &msgs::SpliceAck) -> Result<FundingScope, ChannelError> {
// TODO(splicing): Add check that we are the splice (quiescence) initiator
@@ -11846,7 +11768,6 @@ where
))
}
- #[cfg(splicing)]
fn get_holder_counterparty_balances_floor_incl_fee(
&self, funding: &FundingScope,
) -> Result<(Amount, Amount), String> {
@@ -11908,7 +11829,6 @@ where
Ok((holder_balance_floor, counterparty_balance_floor))
}
- #[cfg(splicing)]
pub fn splice_locked<NS: Deref, L: Deref>(
&mut self, msg: &msgs::SpliceLocked, node_signer: &NS, chain_hash: ChainHash,
user_config: &UserConfig, block_height: u32, logger: &L,
@@ -12543,7 +12463,6 @@ where
);
}
- #[cfg(any(splicing, test, fuzzing))]
#[rustfmt::skip]
pub fn propose_quiescence<L: Deref>(
&mut self, logger: &L, action: QuiescentAction,
@@ -12694,7 +12613,6 @@ where
));
},
Some(QuiescentAction::Splice(_instructions)) => {
- #[cfg(splicing)]
return self.send_splice_init(_instructions)
.map(|splice_init| Some(StfuResponse::SpliceInit(splice_init)))
.map_err(|e| ChannelError::WarnAndDisconnect(e.to_owned()));
@@ -13077,7 +12995,6 @@ where
context: self.context,
interactive_tx_signing_session: None,
holder_commitment_point,
- #[cfg(splicing)]
pending_splice: None,
quiescent_action: None,
};
@@ -13364,7 +13281,6 @@ where
context: self.context,
interactive_tx_signing_session: None,
holder_commitment_point,
- #[cfg(splicing)]
pending_splice: None,
quiescent_action: None,
};
@@ -15052,7 +14968,6 @@ where
},
interactive_tx_signing_session,
holder_commitment_point,
- #[cfg(splicing)]
pending_splice: None,
quiescent_action,
})
@@ -15089,9 +15004,7 @@ mod tests {
use crate::chain::chaininterface::LowerBoundedFeeEstimator;
use crate::chain::transaction::OutPoint;
use crate::chain::BestBlock;
- #[cfg(splicing)]
- use crate::ln::chan_utils::ChannelTransactionParameters;
- use crate::ln::chan_utils::{self, commit_tx_fee_sat};
+ use crate::ln::chan_utils::{self, commit_tx_fee_sat, ChannelTransactionParameters};
use crate::ln::channel::{
AwaitingChannelReadyFlags, ChannelState, FundedChannel, HTLCCandidate, HTLCInitiator,
HTLCUpdateAwaitingACK, InboundHTLCOutput, InboundHTLCState, InboundV1Channel,
@@ -15112,7 +15025,6 @@ mod tests {
use crate::routing::router::{Path, RouteHop};
#[cfg(ldk_test_vectors)]
use crate::sign::{ChannelSigner, EntropySource, InMemorySigner, SignerProvider};
- #[cfg(splicing)]
use crate::sync::Mutex;
#[cfg(ldk_test_vectors)]
use crate::types::features::ChannelTypeFeatures;
@@ -16903,7 +16815,6 @@ mod tests {
FundingTxInput::new_p2wpkh(prevtx, 0).unwrap()
}
- #[cfg(splicing)]
#[test]
#[rustfmt::skip]
fn test_check_v2_funding_inputs_sufficient() {
@@ -16996,7 +16907,6 @@ mod tests {
}
}
- #[cfg(splicing)]
fn get_pre_and_post(
pre_channel_value: u64, our_funding_contribution: i64, their_funding_contribution: i64,
) -> (u64, u64) {
@@ -17031,7 +16941,6 @@ mod tests {
(pre_channel_value, post_channel_value)
}
- #[cfg(splicing)]
#[test]
fn test_compute_post_splice_value() {
{
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index 11f8d86..9a3a036 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -64,7 +64,6 @@ use crate::ln::channel::{
StfuResponse, UpdateFulfillCommitFetch, WithChannelContext,
};
use crate::ln::channel_state::ChannelDetails;
-#[cfg(splicing)]
use crate::ln::funding::SpliceContribution;
use crate::ln::inbound_payment;
use crate::ln::interactivetxs::InteractiveTxMessageSend;
@@ -4496,7 +4495,6 @@ where
/// - `our_funding_inputs`: the funding inputs provided by us. If our contribution is positive, our funding inputs must cover at least that amount.
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
/// - `locktime`: Optional locktime for the new funding transaction. If None, set to the current block height.
- #[cfg(splicing)]
#[rustfmt::skip]
pub fn splice_channel(
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey,
@@ -4516,8 +4514,6 @@ where
res
}
- /// See [`splice_channel`]
- #[cfg(splicing)]
fn internal_splice_channel(
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey,
contribution: SpliceContribution, funding_feerate_per_kw: u32, locktime: Option<u32>,
@@ -11047,9 +11043,6 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
self.internal_channel_ready(counterparty_node_id, &channel_ready_msg)?;
}
- #[cfg(not(splicing))]
- let _ = inferred_splice_locked;
- #[cfg(splicing)]
if let Some(splice_locked) = inferred_splice_locked {
self.internal_splice_locked(counterparty_node_id, &splice_locked)?;
return Ok(NotifyOption::DoPersist);
@@ -11059,7 +11052,6 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
}
/// Handle incoming splice request, transition channel to splice-pending (unless some check fails).
- #[cfg(splicing)]
#[rustfmt::skip]
fn internal_splice_init(&self, counterparty_node_id: &PublicKey, msg: &msgs::SpliceInit) -> Result<(), MsgHandleErrInternal> {
let per_peer_state = self.per_peer_state.read().unwrap();
@@ -11100,7 +11092,6 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
}
/// Handle incoming splice request ack, transition channel to splice-pending (unless some check fails).
- #[cfg(splicing)]
#[rustfmt::skip]
fn internal_splice_ack(&self, counterparty_node_id: &PublicKey, msg: &msgs::SpliceAck) -> Result<(), MsgHandleErrInternal> {
let per_peer_state = self.per_peer_state.read().unwrap();
@@ -11136,7 +11127,6 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
}
}
- #[cfg(splicing)]
fn internal_splice_locked(
&self, counterparty_node_id: &PublicKey, msg: &msgs::SpliceLocked,
) -> Result<(), MsgHandleErrInternal> {
@@ -13384,7 +13374,6 @@ where
pub(super) enum FundingConfirmedMessage {
Establishment(msgs::ChannelReady),
- #[cfg(splicing)]
Splice(msgs::SpliceLocked, Option<OutPoint>, Option<ChannelMonitorUpdate>, Vec<FundingInfo>),
}
@@ -13422,7 +13411,6 @@ where
let mut failed_channels: Vec<(Result<Infallible, _>, _)> = Vec::new();
let mut timed_out_htlcs = Vec::new();
- #[cfg(splicing)]
let mut to_process_monitor_update_actions = Vec::new();
{
let per_peer_state = self.per_peer_state.read().unwrap();
@@ -13460,7 +13448,6 @@ where
log_trace!(logger, "Sending channel_ready WITHOUT channel_update for {}", channel_id);
}
},
- #[cfg(splicing)]
Some(FundingConfirmedMessage::Splice(splice_locked, funding_txo, monitor_update_opt, discarded_funding)) => {
let counterparty_node_id = funded_channel.context.get_counterparty_node_id();
let channel_id = funded_channel.context.channel_id();
@@ -13591,7 +13578,6 @@ where
}
}
- #[cfg(splicing)]
for (counterparty_node_id, channel_id) in to_process_monitor_update_actions {
self.channel_monitor_updated(&channel_id, None, &counterparty_node_id);
}
@@ -13865,7 +13851,6 @@ where
});
}
- #[cfg(splicing)]
fn handle_splice_init(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceInit) {
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
let res = self.internal_splice_init(&counterparty_node_id, msg);
@@ -13879,7 +13864,6 @@ where
});
}
- #[cfg(splicing)]
fn handle_splice_ack(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceAck) {
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
let res = self.internal_splice_ack(&counterparty_node_id, msg);
@@ -13893,7 +13877,6 @@ where
});
}
- #[cfg(splicing)]
#[rustfmt::skip]
fn handle_splice_locked(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceLocked) {
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
diff --git a/lightning/src/ln/funding.rs b/lightning/src/ln/funding.rs
index a87a3cb..b0b8cd4 100644
--- a/lightning/src/ln/funding.rs
+++ b/lightning/src/ln/funding.rs
@@ -9,15 +9,14 @@
//! Types pertaining to funding channels.
-#[cfg(splicing)]
use bitcoin::{Amount, ScriptBuf, SignedAmount, TxOut};
use bitcoin::{Script, Sequence, Transaction, Weight};
use crate::events::bump_transaction::{Utxo, EMPTY_SCRIPT_SIG_WEIGHT};
+use crate::prelude::Vec;
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.
-#[cfg(splicing)]
pub enum SpliceContribution {
/// When funds are added to a channel.
SpliceIn {
@@ -30,6 +29,8 @@ pub enum SpliceContribution {
/// 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.
@@ -40,7 +41,6 @@ pub enum SpliceContribution {
},
}
-#[cfg(splicing)]
impl SpliceContribution {
pub(super) fn value(&self) -> SignedAmount {
match self {
diff --git a/lightning/src/ln/mod.rs b/lightning/src/ln/mod.rs
index 07ef723..873618b 100644
--- a/lightning/src/ln/mod.rs
+++ b/lightning/src/ln/mod.rs
@@ -120,8 +120,7 @@ mod reorg_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod shutdown_tests;
-#[cfg(all(test, splicing))]
-#[allow(unused_mut)]
+#[cfg(test)]
mod splicing_tests;
#[cfg(any(test, feature = "_externalize_tests"))]
#[allow(unused_mut)]
diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs
index 0a6817e..5db1ba7 100644
--- a/lightning/src/ln/msgs.rs
+++ b/lightning/src/ln/msgs.rs
@@ -2058,13 +2058,10 @@ pub trait ChannelMessageHandler: BaseMessageHandler {
// Splicing
/// Handle an incoming `splice_init` message from the given peer.
- #[cfg(splicing)]
fn handle_splice_init(&self, their_node_id: PublicKey, msg: &SpliceInit);
/// Handle an incoming `splice_ack` message from the given peer.
- #[cfg(splicing)]
fn handle_splice_ack(&self, their_node_id: PublicKey, msg: &SpliceAck);
/// Handle an incoming `splice_locked` message from the given peer.
- #[cfg(splicing)]
fn handle_splice_locked(&self, their_node_id: PublicKey, msg: &SpliceLocked);
// Interactive channel construction
diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs
index 98e54ee..71f146a 100644
--- a/lightning/src/ln/peer_handler.rs
+++ b/lightning/src/ln/peer_handler.rs
@@ -448,15 +448,12 @@ impl ChannelMessageHandler for ErroringMessageHandler {
fn handle_stfu(&self, their_node_id: PublicKey, msg: &msgs::Stfu) {
ErroringMessageHandler::push_error(&self, their_node_id, msg.channel_id);
}
- #[cfg(splicing)]
fn handle_splice_init(&self, their_node_id: PublicKey, msg: &msgs::SpliceInit) {
ErroringMessageHandler::push_error(&self, their_node_id, msg.channel_id);
}
- #[cfg(splicing)]
fn handle_splice_ack(&self, their_node_id: PublicKey, msg: &msgs::SpliceAck) {
ErroringMessageHandler::push_error(&self, their_node_id, msg.channel_id);
}
- #[cfg(splicing)]
fn handle_splice_locked(&self, their_node_id: PublicKey, msg: &msgs::SpliceLocked) {
ErroringMessageHandler::push_error(&self, their_node_id, msg.channel_id);
}
@@ -2481,16 +2478,13 @@ where
self.message_handler.chan_handler.handle_stfu(their_node_id, &msg);
},
- #[cfg(splicing)]
// Splicing messages:
wire::Message::SpliceInit(msg) => {
self.message_handler.chan_handler.handle_splice_init(their_node_id, &msg);
},
- #[cfg(splicing)]
wire::Message::SpliceAck(msg) => {
self.message_handler.chan_handler.handle_splice_ack(their_node_id, &msg);
},
- #[cfg(splicing)]
wire::Message::SpliceLocked(msg) => {
self.message_handler.chan_handler.handle_splice_locked(their_node_id, &msg);
},
diff --git a/lightning/src/ln/splicing_tests.rs b/lightning/src/ln/splicing_tests.rs
index e822b8f..3f7d9f2 100644
--- a/lightning/src/ln/splicing_tests.rs
+++ b/lightning/src/ln/splicing_tests.rs
@@ -55,7 +55,7 @@ fn test_v1_splice_in() {
// ==== Channel is now ready for normal operation
// Expected balances
- let mut exp_balance1 = 1000 * channel_value_sat;
+ let exp_balance1 = 1000 * channel_value_sat;
let mut _exp_balance2 = 0;
// === Start of Splicing
diff --git a/lightning/src/ln/wire.rs b/lightning/src/ln/wire.rs
index bd49bdd..bc1d83a 100644
--- a/lightning/src/ln/wire.rs
+++ b/lightning/src/ln/wire.rs
@@ -63,11 +63,8 @@ pub(crate) enum Message<T: core::fmt::Debug + Type + TestEq> {
FundingCreated(msgs::FundingCreated),
FundingSigned(msgs::FundingSigned),
Stfu(msgs::Stfu),
- #[cfg(splicing)]
SpliceInit(msgs::SpliceInit),
- #[cfg(splicing)]
SpliceAck(msgs::SpliceAck),
- #[cfg(splicing)]
SpliceLocked(msgs::SpliceLocked),
TxAddInput(msgs::TxAddInput),
TxAddOutput(msgs::TxAddOutput),
@@ -128,11 +125,8 @@ impl<T: core::fmt::Debug + Type + TestEq> Writeable for Message<T> {
&Message::FundingCreated(ref msg) => msg.write(writer),
&Message::FundingSigned(ref msg) => msg.write(writer),
&Message::Stfu(ref msg) => msg.write(writer),
- #[cfg(splicing)]
&Message::SpliceInit(ref msg) => msg.write(writer),
- #[cfg(splicing)]
&Message::SpliceAck(ref msg) => msg.write(writer),
- #[cfg(splicing)]
&Message::SpliceLocked(ref msg) => msg.write(writer),
&Message::TxAddInput(ref msg) => msg.write(writer),
&Message::TxAddOutput(ref msg) => msg.write(writer),
@@ -193,11 +187,8 @@ impl<T: core::fmt::Debug + Type + TestEq> Type for Message<T> {
&Message::FundingCreated(ref msg) => msg.type_id(),
&Message::FundingSigned(ref msg) => msg.type_id(),
&Message::Stfu(ref msg) => msg.type_id(),
- #[cfg(splicing)]
&Message::SpliceInit(ref msg) => msg.type_id(),
- #[cfg(splicing)]
&Message::SpliceAck(ref msg) => msg.type_id(),
- #[cfg(splicing)]
&Message::SpliceLocked(ref msg) => msg.type_id(),
&Message::TxAddInput(ref msg) => msg.type_id(),
&Message::TxAddOutput(ref msg) => msg.type_id(),
@@ -311,18 +302,15 @@ where
msgs::FundingSigned::TYPE => {
Ok(Message::FundingSigned(LengthReadable::read_from_fixed_length_buffer(buffer)?))
},
- #[cfg(splicing)]
msgs::SpliceInit::TYPE => {
Ok(Message::SpliceInit(LengthReadable::read_from_fixed_length_buffer(buffer)?))
},
msgs::Stfu::TYPE => {
Ok(Message::Stfu(LengthReadable::read_from_fixed_length_buffer(buffer)?))
},
- #[cfg(splicing)]
msgs::SpliceAck::TYPE => {
Ok(Message::SpliceAck(LengthReadable::read_from_fixed_length_buffer(buffer)?))
},
- #[cfg(splicing)]
msgs::SpliceLocked::TYPE => {
Ok(Message::SpliceLocked(LengthReadable::read_from_fixed_length_buffer(buffer)?))
},
diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs
index b61916a..d28d0ab 100644
--- a/lightning/src/util/test_utils.rs
+++ b/lightning/src/util/test_utils.rs
@@ -1129,15 +1129,12 @@ impl msgs::ChannelMessageHandler for TestChannelMessageHandler {
fn handle_stfu(&self, _their_node_id: PublicKey, msg: &msgs::Stfu) {
self.received_msg(wire::Message::Stfu(msg.clone()));
}
- #[cfg(splicing)]
fn handle_splice_init(&self, _their_node_id: PublicKey, msg: &msgs::SpliceInit) {
self.received_msg(wire::Message::SpliceInit(msg.clone()));
}
- #[cfg(splicing)]
fn handle_splice_ack(&self, _their_node_id: PublicKey, msg: &msgs::SpliceAck) {
self.received_msg(wire::Message::SpliceAck(msg.clone()));
}
- #[cfg(splicing)]
fn handle_splice_locked(&self, _their_node_id: PublicKey, msg: &msgs::SpliceLocked) {
self.received_msg(wire::Message::SpliceLocked(msg.clone()));
}
Why this scored 20/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.