@@ -53,7 +53,7 @@ use crate::ln::channel_state::{
53
53
OutboundHTLCDetails, OutboundHTLCStateDetails,
54
54
};
55
55
use crate::ln::channelmanager::{
56
- self, FundingConfirmedMessage, HTLCFailureMsg, HTLCSource, OpenChannelMessage,
56
+ self, FundingConfirmedMessage, FundingTxInput, HTLCFailureMsg, HTLCSource, OpenChannelMessage,
57
57
PaymentClaimDetails, PendingHTLCInfo, PendingHTLCStatus, RAACommitmentOrder, SentHTLCId,
58
58
BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
59
59
};
@@ -5916,10 +5916,11 @@ fn estimate_v2_funding_transaction_fee(
5916
5916
#[cfg(splicing)]
5917
5917
#[rustfmt::skip]
5918
5918
fn check_v2_funding_inputs_sufficient(
5919
- contribution_amount: i64, funding_inputs: &[(TxIn, Transaction, Weight) ], is_initiator: bool,
5919
+ contribution_amount: i64, funding_inputs: &[FundingTxInput ], is_initiator: bool,
5920
5920
is_splice: bool, funding_feerate_sat_per_1000_weight: u32,
5921
5921
) -> Result<u64, ChannelError> {
5922
- let mut total_input_witness_weight = Weight::from_wu(funding_inputs.iter().map(|(_, _, w)| w.to_wu()).sum());
5922
+ let mut total_input_witness_weight =
5923
+ funding_inputs.iter().map(|FundingTxInput { witness_weight, .. }| witness_weight).sum();
5923
5924
let mut funding_inputs_len = funding_inputs.len();
5924
5925
if is_initiator && is_splice {
5925
5926
// consider the weight of the input and witness needed for spending the old funding transaction
@@ -5929,13 +5930,13 @@ fn check_v2_funding_inputs_sufficient(
5929
5930
let estimated_fee = estimate_v2_funding_transaction_fee(is_initiator, funding_inputs_len, total_input_witness_weight, funding_feerate_sat_per_1000_weight);
5930
5931
5931
5932
let mut total_input_sats = 0u64;
5932
- for (idx, input ) in funding_inputs.iter().enumerate() {
5933
- if let Some(output) = input.1. output.get(input.0 .previous_output.vout as usize) {
5933
+ for (idx, FundingTxInput { txin, prevtx, .. } ) in funding_inputs.iter().enumerate() {
5934
+ if let Some(output) = prevtx. output.get(txin .previous_output.vout as usize) {
5934
5935
total_input_sats = total_input_sats.saturating_add(output.value.to_sat());
5935
5936
} else {
5936
5937
return Err(ChannelError::Warn(format!(
5937
5938
"Transaction with txid {} does not have an output with vout of {} corresponding to TxIn at funding_inputs[{}]",
5938
- input.1. compute_txid(), input.0 .previous_output.vout, idx
5939
+ prevtx. compute_txid(), txin .previous_output.vout, idx
5939
5940
)));
5940
5941
}
5941
5942
}
@@ -5979,7 +5980,7 @@ pub(super) struct FundingNegotiationContext {
5979
5980
pub shared_funding_input: Option<SharedOwnedInput>,
5980
5981
/// The funding inputs we will be contributing to the channel.
5981
5982
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
5982
- pub our_funding_inputs: Vec<(TxIn, Transaction, Weight) >,
5983
+ pub our_funding_inputs: Vec<FundingTxInput >,
5983
5984
/// The change output script. This will be used if needed or -- if not set -- generated using
5984
5985
/// `SignerProvider::get_destination_script`.
5985
5986
#[allow(dead_code)] // TODO(splicing): Remove once splicing is enabled.
@@ -6051,8 +6052,11 @@ impl FundingNegotiationContext {
6051
6052
}
6052
6053
}
6053
6054
6054
- let funding_inputs =
6055
- self.our_funding_inputs.into_iter().map(|(txin, tx, _)| (txin, tx)).collect();
6055
+ let funding_inputs = self
6056
+ .our_funding_inputs
6057
+ .into_iter()
6058
+ .map(|FundingTxInput { txin, prevtx, .. }| (txin, prevtx))
6059
+ .collect();
6056
6060
6057
6061
let constructor_args = InteractiveTxConstructorArgs {
6058
6062
entropy_source,
@@ -10612,9 +10616,8 @@ where
10612
10616
/// generated by `SignerProvider::get_destination_script`.
10613
10617
#[cfg(splicing)]
10614
10618
pub fn splice_channel(
10615
- &mut self, our_funding_contribution_satoshis: i64,
10616
- our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, change_script: Option<ScriptBuf>,
10617
- funding_feerate_per_kw: u32, locktime: u32,
10619
+ &mut self, our_funding_contribution_satoshis: i64, our_funding_inputs: Vec<FundingTxInput>,
10620
+ change_script: Option<ScriptBuf>, funding_feerate_per_kw: u32, locktime: u32,
10618
10621
) -> Result<msgs::SpliceInit, APIError> {
10619
10622
// Check if a splice has been initiated already.
10620
10623
// Note: only a single outstanding splice is supported (per spec)
@@ -10680,7 +10683,7 @@ where
10680
10683
),
10681
10684
})?;
10682
10685
10683
- for (_, tx, _) in our_funding_inputs.iter() {
10686
+ for FundingTxInput { txin, prevtx, .. } in our_funding_inputs.iter() {
10684
10687
const MESSAGE_TEMPLATE: msgs::TxAddInput = msgs::TxAddInput {
10685
10688
channel_id: ChannelId([0; 32]),
10686
10689
serial_id: 0,
@@ -10689,7 +10692,7 @@ where
10689
10692
sequence: 0,
10690
10693
shared_input_txid: None,
10691
10694
};
10692
- let message_len = MESSAGE_TEMPLATE.serialized_length() + tx .serialized_length();
10695
+ let message_len = MESSAGE_TEMPLATE.serialized_length() + prevtx .serialized_length();
10693
10696
if message_len > LN_MAX_MSG_LEN {
10694
10697
return Err(APIError::APIMisuseError {
10695
10698
err: format!(
@@ -12474,7 +12477,7 @@ where
12474
12477
pub fn new_outbound<ES: Deref, F: Deref, L: Deref>(
12475
12478
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
12476
12479
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
12477
- funding_inputs: Vec<(TxIn, Transaction, Weight) >, user_id: u128, config: &UserConfig,
12480
+ funding_inputs: Vec<FundingTxInput >, user_id: u128, config: &UserConfig,
12478
12481
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
12479
12482
logger: L,
12480
12483
) -> Result<Self, APIError>
@@ -12688,8 +12691,10 @@ where
12688
12691
value: Amount::from_sat(funding.get_value_satoshis()),
12689
12692
script_pubkey: funding.get_funding_redeemscript().to_p2wsh(),
12690
12693
};
12691
- let inputs_to_contribute =
12692
- our_funding_inputs.into_iter().map(|(txin, tx, _)| (txin, tx)).collect();
12694
+ let inputs_to_contribute = our_funding_inputs
12695
+ .into_iter()
12696
+ .map(|FundingTxInput { txin, prevtx, .. }| (txin, prevtx))
12697
+ .collect();
12693
12698
12694
12699
let interactive_tx_constructor = Some(InteractiveTxConstructor::new(
12695
12700
InteractiveTxConstructorArgs {
@@ -14125,7 +14130,7 @@ mod tests {
14125
14130
TOTAL_BITCOIN_SUPPLY_SATOSHIS,
14126
14131
};
14127
14132
use crate::ln::channel_keys::{RevocationBasepoint, RevocationKey};
14128
- use crate::ln::channelmanager::{self, HTLCSource, PaymentId};
14133
+ use crate::ln::channelmanager::{self, FundingTxInput, HTLCSource, PaymentId};
14129
14134
use crate::ln::msgs;
14130
14135
use crate::ln::msgs::{ChannelUpdate, UnsignedChannelUpdate, MAX_VALUE_MSAT};
14131
14136
use crate::ln::onion_utils::{AttributionData, LocalHTLCFailureReason};
@@ -15898,19 +15903,21 @@ mod tests {
15898
15903
15899
15904
#[cfg(splicing)]
15900
15905
#[rustfmt::skip]
15901
- fn funding_input_sats(input_value_sats: u64) -> (TxIn, Transaction, Weight) {
15906
+ fn funding_input_sats(input_value_sats: u64) -> FundingTxInput {
15902
15907
use crate::sign::P2WPKH_WITNESS_WEIGHT;
15903
15908
15904
- let input_1_prev_out = TxOut { value: Amount::from_sat(input_value_sats), script_pubkey: ScriptBuf::default() };
15905
- let input_1_prev_tx = Transaction {
15906
- input: vec![], output: vec![input_1_prev_out ],
15909
+ let prevout = TxOut { value: Amount::from_sat(input_value_sats), script_pubkey: ScriptBuf::default() };
15910
+ let prevtx = Transaction {
15911
+ input: vec![], output: vec![prevout ],
15907
15912
version: Version::TWO, lock_time: bitcoin::absolute::LockTime::ZERO,
15908
15913
};
15909
- let input_1_txin = TxIn {
15910
- previous_output: bitcoin::OutPoint { txid: input_1_prev_tx .compute_txid(), vout: 0 },
15914
+ let txin = TxIn {
15915
+ previous_output: bitcoin::OutPoint { txid: prevtx .compute_txid(), vout: 0 },
15911
15916
..Default::default()
15912
15917
};
15913
- (input_1_txin, input_1_prev_tx, Weight::from_wu(P2WPKH_WITNESS_WEIGHT))
15918
+ let witness_weight = Weight::from_wu(P2WPKH_WITNESS_WEIGHT);
15919
+
15920
+ FundingTxInput { txin, prevtx, witness_weight }
15914
15921
}
15915
15922
15916
15923
#[cfg(splicing)]
0 commit comments