Skip to content

Commit d9d34a6

Browse files
kaloudisclaude
andcommitted
feat: propagate LDK error details in ChannelCreationFailed
Include the actual LDK APIError message in ChannelCreationFailed instead of discarding it with a generic "Failed to create channel." message. This surfaces rejection reasons (e.g., minimum channel size, insufficient funds) to the UI. Remove Copy derive from Error enum (replaced with Clone) to support String field on ChannelCreationFailed variant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1d15e78 commit d9d34a6

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

src/chain/bitcoind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl BitcoindChainSource {
385385
)
386386
.await;
387387

388-
self.wallet_polling_status.lock().unwrap().propagate_result_to_subscribers(res);
388+
self.wallet_polling_status.lock().unwrap().propagate_result_to_subscribers(res.clone());
389389

390390
res
391391
}

src/chain/electrum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl ElectrumChainSource {
110110

111111
let res = self.sync_onchain_wallet_inner(onchain_wallet).await;
112112

113-
self.onchain_wallet_sync_status.lock().unwrap().propagate_result_to_subscribers(res);
113+
self.onchain_wallet_sync_status.lock().unwrap().propagate_result_to_subscribers(res.clone());
114114

115115
res
116116
}
@@ -202,7 +202,7 @@ impl ElectrumChainSource {
202202
let res =
203203
self.sync_lightning_wallet_inner(channel_manager, chain_monitor, output_sweeper).await;
204204

205-
self.lightning_wallet_sync_status.lock().unwrap().propagate_result_to_subscribers(res);
205+
self.lightning_wallet_sync_status.lock().unwrap().propagate_result_to_subscribers(res.clone());
206206

207207
res
208208
}

src/chain/esplora.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl EsploraChainSource {
9595

9696
let res = self.sync_onchain_wallet_inner(onchain_wallet).await;
9797

98-
self.onchain_wallet_sync_status.lock().unwrap().propagate_result_to_subscribers(res);
98+
self.onchain_wallet_sync_status.lock().unwrap().propagate_result_to_subscribers(res.clone());
9999

100100
res
101101
}
@@ -221,7 +221,7 @@ impl EsploraChainSource {
221221
let res =
222222
self.sync_lightning_wallet_inner(channel_manager, chain_monitor, output_sweeper).await;
223223

224-
self.lightning_wallet_sync_status.lock().unwrap().propagate_result_to_subscribers(res);
224+
self.lightning_wallet_sync_status.lock().unwrap().propagate_result_to_subscribers(res.clone());
225225

226226
res
227227
}

src/connection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ where
108108
},
109109
};
110110

111-
self.propagate_result_to_subscribers(&node_id, res);
111+
self.propagate_result_to_subscribers(&node_id, res.clone());
112112

113113
res
114114
}
@@ -135,7 +135,7 @@ where
135135
let mut pending_connections_lock = self.pending_connections.lock().unwrap();
136136
if let Some(connection_ready_senders) = pending_connections_lock.remove(node_id) {
137137
for sender in connection_ready_senders {
138-
let _ = sender.send(res).map_err(|e| {
138+
let _ = sender.send(res.clone()).map_err(|e| {
139139
debug_assert!(
140140
false,
141141
"Failed to send connection result to subscribers: {:?}",

src/error.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use bdk_wallet::error::CreateTxError as BdkCreateTxError;
1414
#[allow(deprecated)]
1515
use bdk_wallet::signer::SignerError as BdkSignerError;
1616

17-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
17+
#[derive(Clone, Debug, PartialEq, Eq)]
1818
/// An error that possibly needs to be handled by the user.
1919
pub enum Error {
2020
/// Returned when trying to start [`crate::Node`] while it is already running.
@@ -40,7 +40,10 @@ pub enum Error {
4040
/// Sending a payment probe has failed.
4141
ProbeSendingFailed,
4242
/// A channel could not be opened.
43-
ChannelCreationFailed,
43+
ChannelCreationFailed {
44+
/// Details about why channel creation failed.
45+
message: String,
46+
},
4447
/// A channel could not be closed.
4548
ChannelClosingFailed,
4649
/// A channel could not be spliced.
@@ -147,7 +150,7 @@ impl fmt::Display for Error {
147150
Self::PaymentSendingFailed => write!(f, "Failed to send the given payment."),
148151
Self::InvalidCustomTlvs => write!(f, "Failed to construct payment with custom TLVs."),
149152
Self::ProbeSendingFailed => write!(f, "Failed to send the given payment probe."),
150-
Self::ChannelCreationFailed => write!(f, "Failed to create channel."),
153+
Self::ChannelCreationFailed { ref message } => write!(f, "Failed to create channel: {}", message),
151154
Self::ChannelClosingFailed => write!(f, "Failed to close channel."),
152155
Self::ChannelSplicingFailed => write!(f, "Failed to splice channel."),
153156
Self::ChannelConfigUpdateFailed => write!(f, "Failed to update channel config."),

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ impl Node {
11591159
},
11601160
Err(e) => {
11611161
log_error!(self.logger, "Failed to initiate channel creation: {:?}", e);
1162-
Err(Error::ChannelCreationFailed)
1162+
Err(Error::ChannelCreationFailed { message: format!("{:?}", e) })
11631163
},
11641164
}
11651165
}
@@ -1267,7 +1267,7 @@ impl Node {
12671267
) -> Result<UserChannelId, Error> {
12681268
if let Err(err) = may_announce_channel(&self.config) {
12691269
log_error!(self.logger, "Failed to open announced channel as the node hasn't been sufficiently configured to act as a forwarding node: {}", err);
1270-
return Err(Error::ChannelCreationFailed);
1270+
return Err(Error::ChannelCreationFailed { message: format!("Node not configured for channel forwarding: {}", err) });
12711271
}
12721272

12731273
self.open_channel_inner(

0 commit comments

Comments
 (0)