@@ -30,7 +30,7 @@ use crate::ln::types::ChannelId;
30
30
use crate::types::payment::{PaymentPreimage, PaymentHash};
31
31
use crate::types::features::{ChannelTypeFeatures, InitFeatures};
32
32
use 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,
34
34
InteractiveTxConstructorArgs, InteractiveTxMessageSend, InteractiveTxSigningSession, InteractiveTxMessageSendResult,
35
35
OutputOwned, SharedOwnedOutput, TX_COMMON_FIELDS_WEIGHT,
36
36
};
@@ -2223,13 +2223,15 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for FundedChannel<SP> where
2223
2223
2224
2224
impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2225
2225
/// 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.
2227
2229
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled
2228
2230
fn begin_interactive_funding_tx_construction<ES: Deref>(
2229
2231
&mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey,
2230
2232
change_destination_opt: Option<ScriptBuf>,
2231
2233
prev_funding_input: Option<(TxIn, TransactionU16LenLimited)>,
2232
- ) -> Result<Option<InteractiveTxMessageSend>, ChannelError >
2234
+ ) -> Result<Option<InteractiveTxMessageSend>, AbortReason >
2233
2235
where ES::Target: EntropySource
2234
2236
{
2235
2237
debug_assert!(self.interactive_tx_constructor.is_none());
@@ -2273,19 +2275,14 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2273
2275
script
2274
2276
} else {
2275
2277
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)?
2279
2279
};
2280
2280
let change_value_opt = calculate_change_output_value(
2281
2281
self.funding.is_outbound(), self.dual_funding_context.our_funding_satoshis,
2282
2282
&funding_inputs_prev_outputs, &funding_outputs,
2283
2283
self.dual_funding_context.funding_feerate_sat_per_1000_weight,
2284
2284
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
+ )?;
2289
2286
if let Some(change_value) = change_value_opt {
2290
2287
let mut change_output = TxOut {
2291
2288
value: Amount::from_sat(change_value),
@@ -2313,8 +2310,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2313
2310
outputs_to_contribute: funding_outputs,
2314
2311
expected_remote_shared_funding_output,
2315
2312
};
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)?;
2318
2314
let msg = tx_constructor.take_initiator_first_message();
2319
2315
2320
2316
self.interactive_tx_constructor = Some(tx_constructor);
@@ -4999,23 +4995,18 @@ impl DualFundingChannelContext {
4999
4995
/// Obtain prev outputs for each supplied input and matching transaction.
5000
4996
/// Will error when a prev tx does not have an output for the specified vout.
5001
4997
/// 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 > {
5003
4999
let mut prev_outputs: Vec<&TxOut> = Vec::with_capacity(inputs.len());
5004
5000
// Check that vouts exist for each TxIn in provided transactions.
5005
5001
for (idx, (txin, tx)) in inputs.iter().enumerate() {
5006
5002
let txid = tx.as_transaction().compute_txid();
5007
5003
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));
5011
5005
}
5012
5006
if let Some(output) = tx.as_transaction().output.get(txin.previous_output.vout as usize) {
5013
5007
prev_outputs.push(output);
5014
5008
} 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));
5019
5010
}
5020
5011
}
5021
5012
Ok(prev_outputs)
0 commit comments