Skip to content

Commit 17ed322

Browse files
committed
Switch error result to ChannelError in begin_intera...()
1 parent 93028bb commit 17ed322

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

lightning/src/ln/channel.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22272227
&mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey,
22282228
change_destination_opt: Option<ScriptBuf>,
22292229
prev_funding_input: Option<(TxIn, TransactionU16LenLimited)>,
2230-
) -> Result<Option<InteractiveTxMessageSend>, APIError>
2230+
) -> Result<Option<InteractiveTxMessageSend>, ChannelError>
22312231
where ES::Target: EntropySource
22322232
{
22332233
let mut funding_inputs = Vec::new();
@@ -2237,14 +2237,13 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22372237
funding_inputs.push(prev_funding_input);
22382238
}
22392239

2240-
let funding_inputs_prev_outputs = DualFundingChannelContext::txouts_from_input_prev_txs(&funding_inputs)
2241-
.map_err(|err| APIError::APIMisuseError { err: err.to_string() })?;
2240+
let funding_inputs_prev_outputs = DualFundingChannelContext::txouts_from_input_prev_txs(&funding_inputs)?;
22422241

22432242
let total_input_satoshis: u64 = funding_inputs_prev_outputs.iter().map(|txout| txout.value.to_sat()).sum();
22442243
if total_input_satoshis < self.dual_funding_context.our_funding_satoshis {
2245-
return Err(APIError::APIMisuseError {
2246-
err: format!("Total value of funding inputs must be at least funding amount. It was {} sats",
2247-
total_input_satoshis) });
2244+
return Err(ChannelError::Warn(format!(
2245+
"Total value of funding inputs must be at least funding amount. It was {} sats", total_input_satoshis,
2246+
)));
22482247
}
22492248

22502249
// Add output for funding tx
@@ -2276,19 +2275,18 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22762275
&funding_inputs_prev_outputs, &funding_outputs,
22772276
self.dual_funding_context.funding_feerate_sat_per_1000_weight,
22782277
self.context.holder_dust_limit_satoshis,
2279-
).map_err(|err| APIError::APIMisuseError {
2280-
err: format!("Insufficient inputs, cannot cover intended contribution of {} and fees; {}",
2281-
self.dual_funding_context.our_funding_satoshis, err
2282-
),
2283-
})?;
2278+
).map_err(|err| ChannelError::Warn(format!(
2279+
"Insufficient inputs, cannot cover intended contribution of {} and fees; {}",
2280+
self.dual_funding_context.our_funding_satoshis, err
2281+
)))?;
22842282
if let Some(change_value) = change_value_opt {
22852283
let change_script = if let Some(script) = change_destination_opt {
22862284
script
22872285
} else {
22882286
signer_provider.get_destination_script(self.context.channel_keys_id)
2289-
.map_err(|err| APIError::APIMisuseError {
2290-
err: format!("Failed to get change script as new destination script, {:?}", err),
2291-
})?
2287+
.map_err(|err| ChannelError::Warn(format!(
2288+
"Failed to get change script as new destination script, {:?}", err,
2289+
)))?
22922290
};
22932291
let mut change_output = TxOut {
22942292
value: Amount::from_sat(change_value),
@@ -2317,7 +2315,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
23172315
expected_remote_shared_funding_output,
23182316
};
23192317
let mut tx_constructor = InteractiveTxConstructor::new(constructor_args)
2320-
.map_err(|_| APIError::APIMisuseError { err: "Incorrect shared output provided".into() })?;
2318+
.map_err(|_| ChannelError::Warn("Incorrect shared output provided".into()))?;
23212319
let msg = tx_constructor.take_initiator_first_message();
23222320

23232321
self.interactive_tx_constructor = Some(tx_constructor);

0 commit comments

Comments
 (0)