@@ -30,7 +30,7 @@ use crate::ln::types::ChannelId;
3030use crate::types::payment::{PaymentPreimage, PaymentHash};
3131use crate::types::features::{ChannelTypeFeatures, InitFeatures};
3232use crate::ln::interactivetxs::{
33- calculate_change_output_value, get_output_weight, HandleTxCompleteValue, HandleTxCompleteResult, InteractiveTxConstructor,
33+ calculate_change_output_value, get_output_weight, AbortReason, HandleTxCompleteValue, HandleTxCompleteResult, InteractiveTxConstructor,
3434 InteractiveTxConstructorArgs, InteractiveTxMessageSend, InteractiveTxSigningSession, InteractiveTxMessageSendResult,
3535 OutputOwned, SharedOwnedOutput, TX_COMMON_FIELDS_WEIGHT,
3636};
@@ -2223,13 +2223,15 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for FundedChannel<SP> where
22232223
22242224impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22252225 /// Prepare and start interactive transaction negotiation.
2226- /// `change_destination_opt` - Optional destination for optional change; if None, default destination address is used.
2226+ /// `change_destination_opt` - Optional destination for optional change; if None,
2227+ /// default destination address is used.
2228+ /// If error occurs, it is caused by our side, not the counterparty.
22272229 #[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled
22282230 fn begin_interactive_funding_tx_construction<ES: Deref>(
22292231 &mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey,
22302232 change_destination_opt: Option<ScriptBuf>,
22312233 prev_funding_input: Option<(TxIn, TransactionU16LenLimited)>,
2232- ) -> Result<Option<InteractiveTxMessageSend>, ChannelError >
2234+ ) -> Result<Option<InteractiveTxMessageSend>, AbortReason >
22332235 where ES::Target: EntropySource
22342236 {
22352237 debug_assert!(self.interactive_tx_constructor.is_none());
@@ -2273,19 +2275,14 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22732275 script
22742276 } else {
22752277 signer_provider.get_destination_script(self.context.channel_keys_id)
2276- .map_err(|err| ChannelError::Warn(format!(
2277- "Failed to get change script as new destination script, {:?}", err,
2278- )))?
2278+ .map_err(|_err| AbortReason::InternalErrorGettingDestinationScript)?
22792279 };
22802280 let change_value_opt = calculate_change_output_value(
22812281 self.funding.is_outbound(), self.dual_funding_context.our_funding_satoshis,
22822282 &funding_inputs_prev_outputs, &funding_outputs,
22832283 self.dual_funding_context.funding_feerate_sat_per_1000_weight,
22842284 change_script.minimal_non_dust().to_sat(),
2285- ).map_err(|err| ChannelError::Warn(format!(
2286- "Insufficient inputs, cannot cover intended contribution of {} and fees; {}",
2287- self.dual_funding_context.our_funding_satoshis, err
2288- )))?;
2285+ )?;
22892286 if let Some(change_value) = change_value_opt {
22902287 let mut change_output = TxOut {
22912288 value: Amount::from_sat(change_value),
@@ -2313,8 +2310,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
23132310 outputs_to_contribute: funding_outputs,
23142311 expected_remote_shared_funding_output,
23152312 };
2316- let mut tx_constructor = InteractiveTxConstructor::new(constructor_args)
2317- .map_err(|_| ChannelError::Warn("Incorrect shared output provided".into()))?;
2313+ let mut tx_constructor = InteractiveTxConstructor::new(constructor_args)?;
23182314 let msg = tx_constructor.take_initiator_first_message();
23192315
23202316 self.interactive_tx_constructor = Some(tx_constructor);
@@ -4999,23 +4995,18 @@ impl DualFundingChannelContext {
49994995 /// Obtain prev outputs for each supplied input and matching transaction.
50004996 /// Will error when a prev tx does not have an output for the specified vout.
50014997 /// Also checks for matching of transaction IDs.
5002- fn txouts_from_input_prev_txs(inputs: &Vec<(TxIn, TransactionU16LenLimited)>) -> Result<Vec<&TxOut>, ChannelError > {
4998+ fn txouts_from_input_prev_txs(inputs: &Vec<(TxIn, TransactionU16LenLimited)>) -> Result<Vec<&TxOut>, AbortReason > {
50034999 let mut prev_outputs: Vec<&TxOut> = Vec::with_capacity(inputs.len());
50045000 // Check that vouts exist for each TxIn in provided transactions.
50055001 for (idx, (txin, tx)) in inputs.iter().enumerate() {
50065002 let txid = tx.as_transaction().compute_txid();
50075003 if txin.previous_output.txid != txid {
5008- return Err(ChannelError::Warn(
5009- format!("Transaction input txid mismatch, {} vs. {}, at index {}", txin.previous_output.txid, txid, idx)
5010- ));
5004+ return Err(AbortReason::ProvidedInputsAndPrevtxsTxIdMismatch(idx as u32));
50115005 }
50125006 if let Some(output) = tx.as_transaction().output.get(txin.previous_output.vout as usize) {
50135007 prev_outputs.push(output);
50145008 } else {
5015- return Err(ChannelError::Warn(
5016- format!("Transaction with txid {} does not have an output with vout of {} corresponding to TxIn, at index {}",
5017- txid, txin.previous_output.vout, idx)
5018- ));
5009+ return Err(AbortReason::ProvidedInputsAndPrevtxsVoutNotFound(idx as u32));
50195010 }
50205011 }
50215012 Ok(prev_outputs)
0 commit comments