Skip to content

Commit e5650db

Browse files
committed
Account for chain::Watch::watch_channel returning a Result
1 parent 8c5f311 commit e5650db

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

bindings/ldk_node.udl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ enum BuildError {
129129
"InvalidSeedBytes",
130130
"InvalidSeedFile",
131131
"InvalidSystemTime",
132+
"InvalidChannelMonitor",
132133
"ReadFailed",
133134
"WriteFailed",
134135
"StoragePathAccessFailed",

src/builder.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ pub enum BuildError {
8686
InvalidSeedFile,
8787
/// The current system time is invalid, clocks might have gone backwards.
8888
InvalidSystemTime,
89+
/// The a read channel monitor is invalid.
90+
InvalidChannelMonitor,
8991
/// We failed to read data from the [`KVStore`].
9092
ReadFailed,
9193
/// We failed to write data to the [`KVStore`].
@@ -108,6 +110,9 @@ impl fmt::Display for BuildError {
108110
Self::InvalidSystemTime => {
109111
write!(f, "System time is invalid. Clocks might have gone back in time.")
110112
}
113+
Self::InvalidChannelMonitor => {
114+
write!(f, "Failed to watch a deserialzed ChannelMonitor")
115+
}
111116
Self::ReadFailed => write!(f, "Failed to read from store."),
112117
Self::WriteFailed => write!(f, "Failed to write to store."),
113118
Self::StoragePathAccessFailed => write!(f, "Failed to access the given storage path."),
@@ -608,7 +613,10 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
608613
// Give ChannelMonitors to ChainMonitor
609614
for (_blockhash, channel_monitor) in channel_monitors.into_iter() {
610615
let funding_outpoint = channel_monitor.get_funding_txo().0;
611-
chain_monitor.watch_channel(funding_outpoint, channel_monitor);
616+
chain_monitor.watch_channel(funding_outpoint, channel_monitor).map_err(|e| {
617+
log_error!(logger, "Failed to watch channel monitor: {:?}", e);
618+
BuildError::InvalidChannelMonitor
619+
})?;
612620
}
613621

614622
// Initialize the PeerManager

0 commit comments

Comments
 (0)