Skip to content
26 changes: 6 additions & 20 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6108,8 +6108,8 @@ where
{
let mut output_index = None;
let expected_spk = funding.get_funding_redeemscript().to_p2wsh();
for (idx, outp) in signing_session.unsigned_tx().outputs().enumerate() {
if outp.script_pubkey() == &expected_spk && outp.value() == funding.get_value_satoshis() {
for (idx, outp) in signing_session.unsigned_tx().tx().output.iter().enumerate() {
if outp.script_pubkey == expected_spk && outp.value.to_sat() == funding.get_value_satoshis() {
if output_index.is_some() {
return Err(AbortReason::DuplicateFundingOutput);
}
Expand Down Expand Up @@ -6617,14 +6617,6 @@ impl FundingNegotiationContext {
}
}

let funding_inputs = self
.our_funding_inputs
.into_iter()
.map(|FundingTxInput { utxo, sequence, prevtx }| {
(TxIn { previous_output: utxo.outpoint, sequence, ..Default::default() }, prevtx)
})
.collect();

let constructor_args = InteractiveTxConstructorArgs {
entropy_source,
holder_node_id,
Expand All @@ -6633,7 +6625,7 @@ impl FundingNegotiationContext {
feerate_sat_per_kw: self.funding_feerate_sat_per_1000_weight,
is_initiator: self.is_initiator,
funding_tx_locktime: self.funding_tx_locktime,
inputs_to_contribute: funding_inputs,
inputs_to_contribute: self.our_funding_inputs,
shared_funding_input: self.shared_funding_input,
shared_funding_output: SharedOwnedOutput::new(
shared_funding_output,
Expand Down Expand Up @@ -8623,7 +8615,7 @@ where
return Err(APIError::APIMisuseError { err });
};

let tx = signing_session.unsigned_tx().build_unsigned_tx();
let tx = signing_session.unsigned_tx().tx();
if funding_txid_signed != tx.compute_txid() {
return Err(APIError::APIMisuseError {
err: "Transaction was malleated prior to signing".to_owned(),
Expand All @@ -8635,7 +8627,7 @@ where
let sig = match &self.context.holder_signer {
ChannelSignerType::Ecdsa(signer) => signer.sign_splice_shared_input(
&self.funding.channel_transaction_parameters,
&tx,
tx,
splice_input_index as usize,
&self.context.secp_ctx,
),
Expand Down Expand Up @@ -13669,12 +13661,6 @@ where
value: Amount::from_sat(funding.get_value_satoshis()),
script_pubkey: funding.get_funding_redeemscript().to_p2wsh(),
};
let inputs_to_contribute = our_funding_inputs
.into_iter()
.map(|FundingTxInput { utxo, sequence, prevtx }| {
(TxIn { previous_output: utxo.outpoint, sequence, ..Default::default() }, prevtx)
})
.collect();

let interactive_tx_constructor = Some(InteractiveTxConstructor::new(
InteractiveTxConstructorArgs {
Expand All @@ -13685,7 +13671,7 @@ where
feerate_sat_per_kw: funding_negotiation_context.funding_feerate_sat_per_1000_weight,
funding_tx_locktime: funding_negotiation_context.funding_tx_locktime,
is_initiator: false,
inputs_to_contribute,
inputs_to_contribute: our_funding_inputs,
shared_funding_input: None,
shared_funding_output: SharedOwnedOutput::new(shared_funding_output, our_funding_contribution_sats),
outputs_to_contribute: funding_negotiation_context.our_funding_outputs.clone(),
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9137,7 +9137,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
{
if signing_session.has_local_contribution() {
let mut pending_events = self.pending_events.lock().unwrap();
let unsigned_transaction = signing_session.unsigned_tx().build_unsigned_tx();
let unsigned_transaction = signing_session.unsigned_tx().tx().clone();
let event_action = (
Event::FundingTransactionReadyForSigning {
unsigned_transaction,
Expand Down
5 changes: 5 additions & 0 deletions lightning/src/ln/funding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ impl FundingTxInput {
FundingTxInput::new(prevtx, vout, witness_weight, Script::is_p2tr)
}

#[cfg(test)]
pub(crate) fn new_p2pkh(prevtx: Transaction, vout: u32) -> Result<Self, ()> {
FundingTxInput::new(prevtx, vout, Weight::ZERO, Script::is_p2pkh)
}

/// The sequence number to use in the [`TxIn`].
///
/// [`TxIn`]: bitcoin::TxIn
Expand Down
Loading
Loading