@@ -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
};
@@ -2221,13 +2221,15 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for FundedChannel<SP> where
2221
2221
2222
2222
impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2223
2223
/// Prepare and start interactive transaction negotiation.
2224
- /// `change_destination_opt` - Optional destination for optional change; if None, default destination address is used.
2224
+ /// `change_destination_opt` - Optional destination for optional change; if None,
2225
+ /// default destination address is used.
2226
+ /// If error occurs, it is caused by our side, not the counterparty.
2225
2227
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled
2226
2228
fn begin_interactive_funding_tx_construction<ES: Deref>(
2227
2229
&mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey,
2228
2230
change_destination_opt: Option<ScriptBuf>,
2229
2231
prev_funding_input: Option<(TxIn, TransactionU16LenLimited)>,
2230
- ) -> Result<Option<InteractiveTxMessageSend>, ChannelError >
2232
+ ) -> Result<Option<InteractiveTxMessageSend>, AbortReason >
2231
2233
where ES::Target: EntropySource
2232
2234
{
2233
2235
debug_assert!(self.interactive_tx_constructor.is_none());
@@ -2271,19 +2273,14 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2271
2273
script
2272
2274
} else {
2273
2275
signer_provider.get_destination_script(self.context.channel_keys_id)
2274
- .map_err(|err| ChannelError::Warn(format!(
2275
- "Failed to get change script as new destination script, {:?}", err,
2276
- )))?
2276
+ .map_err(|_err| AbortReason::InternalErrorGettingDestinationScript)?
2277
2277
};
2278
2278
let change_value_opt = calculate_change_output_value(
2279
2279
self.funding.is_outbound(), self.dual_funding_context.our_funding_satoshis,
2280
2280
&funding_inputs_prev_outputs, &funding_outputs,
2281
2281
self.dual_funding_context.funding_feerate_sat_per_1000_weight,
2282
2282
change_script.minimal_non_dust().to_sat(),
2283
- ).map_err(|err| ChannelError::Warn(format!(
2284
- "Insufficient inputs, cannot cover intended contribution of {} and fees; {}",
2285
- self.dual_funding_context.our_funding_satoshis, err
2286
- )))?;
2283
+ )?;
2287
2284
if let Some(change_value) = change_value_opt {
2288
2285
let mut change_output = TxOut {
2289
2286
value: Amount::from_sat(change_value),
@@ -2311,8 +2308,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2311
2308
outputs_to_contribute: funding_outputs,
2312
2309
expected_remote_shared_funding_output,
2313
2310
};
2314
- let mut tx_constructor = InteractiveTxConstructor::new(constructor_args)
2315
- .map_err(|_| ChannelError::Warn("Incorrect shared output provided".into()))?;
2311
+ let mut tx_constructor = InteractiveTxConstructor::new(constructor_args)?;
2316
2312
let msg = tx_constructor.take_initiator_first_message();
2317
2313
2318
2314
self.interactive_tx_constructor = Some(tx_constructor);
@@ -4973,23 +4969,18 @@ impl DualFundingChannelContext {
4973
4969
/// Obtain prev outputs for each supplied input and matching transaction.
4974
4970
/// Will error when a prev tx does not have an output for the specified vout.
4975
4971
/// Also checks for matching of transaction IDs.
4976
- fn txouts_from_input_prev_txs(inputs: &Vec<(TxIn, TransactionU16LenLimited)>) -> Result<Vec<&TxOut>, ChannelError > {
4972
+ fn txouts_from_input_prev_txs(inputs: &Vec<(TxIn, TransactionU16LenLimited)>) -> Result<Vec<&TxOut>, AbortReason > {
4977
4973
let mut prev_outputs: Vec<&TxOut> = Vec::with_capacity(inputs.len());
4978
4974
// Check that vouts exist for each TxIn in provided transactions.
4979
4975
for (idx, (txin, tx)) in inputs.iter().enumerate() {
4980
4976
let txid = tx.as_transaction().compute_txid();
4981
4977
if txin.previous_output.txid != txid {
4982
- return Err(ChannelError::Warn(
4983
- format!("Transaction input txid mismatch, {} vs. {}, at index {}", txin.previous_output.txid, txid, idx)
4984
- ));
4978
+ return Err(AbortReason::ProvidedInputsAndPrevtxsTxIdMismatch(idx as u32));
4985
4979
}
4986
4980
if let Some(output) = tx.as_transaction().output.get(txin.previous_output.vout as usize) {
4987
4981
prev_outputs.push(output);
4988
4982
} else {
4989
- return Err(ChannelError::Warn(
4990
- format!("Transaction with txid {} does not have an output with vout of {} corresponding to TxIn, at index {}",
4991
- txid, txin.previous_output.vout, idx)
4992
- ));
4983
+ return Err(AbortReason::ProvidedInputsAndPrevtxsVoutNotFound(idx as u32));
4993
4984
}
4994
4985
}
4995
4986
Ok(prev_outputs)
0 commit comments