Skip to content

Commit 25dc13a

Browse files
committed
f - move SpliceContribution
1 parent ea94abe commit 25dc13a

File tree

4 files changed

+47
-47
lines changed

4 files changed

+47
-47
lines changed

lightning/src/ln/channel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ use crate::ln::channel_state::{
5252
ChannelShutdownState, CounterpartyForwardingInfo, InboundHTLCDetails, InboundHTLCStateDetails,
5353
OutboundHTLCDetails, OutboundHTLCStateDetails,
5454
};
55-
#[cfg(splicing)]
56-
use crate::ln::channelmanager::SpliceContribution;
5755
use crate::ln::channelmanager::{
5856
self, FundingConfirmedMessage, HTLCFailureMsg, HTLCSource, OpenChannelMessage,
5957
PaymentClaimDetails, PendingHTLCInfo, PendingHTLCStatus, RAACommitmentOrder, SentHTLCId,
6058
BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
6159
};
6260
use crate::ln::funding::FundingTxInput;
6361
#[cfg(splicing)]
62+
use crate::ln::funding::SpliceContribution;
63+
#[cfg(splicing)]
6464
use crate::ln::interactivetxs::{
6565
calculate_change_output_value, AbortReason, InteractiveTxMessageSend,
6666
};

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ use bitcoin::hashes::{Hash, HashEngine, HmacEngine};
3131
use bitcoin::secp256k1::Secp256k1;
3232
use bitcoin::secp256k1::{PublicKey, SecretKey};
3333
use bitcoin::{secp256k1, Sequence, SignedAmount};
34-
#[cfg(splicing)]
35-
use bitcoin::{Amount, ScriptBuf};
3634

3735
use crate::blinded_path::message::MessageForwardNode;
3836
use crate::blinded_path::message::{AsyncPaymentsContext, OffersContext};
@@ -66,7 +64,7 @@ use crate::ln::channel::{
6664
};
6765
use crate::ln::channel_state::ChannelDetails;
6866
#[cfg(splicing)]
69-
use crate::ln::funding::FundingTxInput;
67+
use crate::ln::funding::SpliceContribution;
7068
use crate::ln::inbound_payment;
7169
use crate::ln::interactivetxs::{HandleTxCompleteResult, InteractiveTxMessageSendResult};
7270
use crate::ln::msgs;
@@ -202,47 +200,6 @@ pub use crate::ln::outbound_payment::{
202200
};
203201
use crate::ln::script::ShutdownScript;
204202

205-
/// The components of a splice's funding transaction that are contributed by one party.
206-
#[cfg(splicing)]
207-
pub enum SpliceContribution {
208-
/// When funds are added to a channel.
209-
SpliceIn {
210-
/// The amount to contribute to the splice.
211-
value: Amount,
212-
213-
/// The inputs included in the splice's funding transaction to meet the contributed amount.
214-
/// Any excess amount will be sent to a change output.
215-
inputs: Vec<FundingTxInput>,
216-
217-
/// An optional change output script. This will be used if needed or, when not set,
218-
/// generated using [`SignerProvider::get_destination_script`].
219-
change_script: Option<ScriptBuf>,
220-
},
221-
}
222-
223-
#[cfg(splicing)]
224-
impl SpliceContribution {
225-
pub(super) fn value(&self) -> SignedAmount {
226-
match self {
227-
SpliceContribution::SpliceIn { value, .. } => {
228-
value.to_signed().unwrap_or(SignedAmount::MAX)
229-
},
230-
}
231-
}
232-
233-
pub(super) fn inputs(&self) -> &[FundingTxInput] {
234-
match self {
235-
SpliceContribution::SpliceIn { inputs, .. } => &inputs[..],
236-
}
237-
}
238-
239-
pub(super) fn into_tx_parts(self) -> (Vec<FundingTxInput>, Option<ScriptBuf>) {
240-
match self {
241-
SpliceContribution::SpliceIn { inputs, change_script, .. } => (inputs, change_script),
242-
}
243-
}
244-
}
245-
246203
// We hold various information about HTLC relay in the HTLC objects in Channel itself:
247204
//
248205
// Upon receipt of an HTLC from a peer, we'll give it a PendingHTLCStatus indicating if it should

lightning/src/ln/funding.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,54 @@
99

1010
//! Types pertaining to funding channels.
1111
12+
#[cfg(splicing)]
13+
use bitcoin::{Amount, ScriptBuf, SignedAmount};
1214
use bitcoin::{Script, Sequence, Transaction, Weight};
1315

1416
use crate::events::bump_transaction::{Utxo, EMPTY_SCRIPT_SIG_WEIGHT};
1517
use crate::sign::{P2TR_KEY_PATH_WITNESS_WEIGHT, P2WPKH_WITNESS_WEIGHT};
1618

19+
/// The components of a splice's funding transaction that are contributed by one party.
20+
#[cfg(splicing)]
21+
pub enum SpliceContribution {
22+
/// When funds are added to a channel.
23+
SpliceIn {
24+
/// The amount to contribute to the splice.
25+
value: Amount,
26+
27+
/// The inputs included in the splice's funding transaction to meet the contributed amount.
28+
/// Any excess amount will be sent to a change output.
29+
inputs: Vec<FundingTxInput>,
30+
31+
/// An optional change output script. This will be used if needed or, when not set,
32+
/// generated using [`SignerProvider::get_destination_script`].
33+
change_script: Option<ScriptBuf>,
34+
},
35+
}
36+
37+
#[cfg(splicing)]
38+
impl SpliceContribution {
39+
pub(super) fn value(&self) -> SignedAmount {
40+
match self {
41+
SpliceContribution::SpliceIn { value, .. } => {
42+
value.to_signed().unwrap_or(SignedAmount::MAX)
43+
},
44+
}
45+
}
46+
47+
pub(super) fn inputs(&self) -> &[FundingTxInput] {
48+
match self {
49+
SpliceContribution::SpliceIn { inputs, .. } => &inputs[..],
50+
}
51+
}
52+
53+
pub(super) fn into_tx_parts(self) -> (Vec<FundingTxInput>, Option<ScriptBuf>) {
54+
match self {
55+
SpliceContribution::SpliceIn { inputs, change_script, .. } => (inputs, change_script),
56+
}
57+
}
58+
}
59+
1760
/// An input to contribute to a channel's funding transaction either when using the v2 channel
1861
/// establishment protocol or when splicing.
1962
#[derive(Clone)]

lightning/src/ln/splicing_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// You may not use this file except in accordance with one or both of these
88
// licenses.
99

10-
use crate::ln::channelmanager::SpliceContribution;
1110
use crate::ln::functional_test_utils::*;
11+
use crate::ln::funding::SpliceContribution;
1212
use crate::ln::msgs::{BaseMessageHandler, ChannelMessageHandler, MessageSendEvent};
1313
use crate::util::errors::APIError;
1414

0 commit comments

Comments
 (0)