Merge pull request #2822 from TheBlueMatt/2024-01-pm-dyn-ref
[rust-lightning] / lightning-transaction-sync / src / error.rs
index 0a529d063ec81187336df0ba6b58055093ecca7d..d1f4a319e8686c86218e93ea80303dfb90c6957c 100644 (file)
@@ -18,29 +18,32 @@ impl fmt::Display for TxSyncError {
 }
 
 #[derive(Debug)]
-#[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
 pub(crate) enum InternalError {
        /// A transaction sync failed and needs to be retried eventually.
        Failed,
-       /// An inconsisteny was encounterd during transaction sync.
+       /// An inconsistency was encountered during transaction sync.
        Inconsistency,
 }
 
-#[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
 impl fmt::Display for InternalError {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                match *self {
                        Self::Failed => write!(f, "Failed to conduct transaction sync."),
                        Self::Inconsistency => {
-                               write!(f, "Encountered an inconsisteny during transaction sync.")
+                               write!(f, "Encountered an inconsistency during transaction sync.")
                        }
                }
        }
 }
 
-#[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
 impl std::error::Error for InternalError {}
 
+impl From<InternalError> for TxSyncError {
+       fn from(_e: InternalError) -> Self {
+               Self::Failed
+       }
+}
+
 #[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
 impl From<esplora_client::Error> for TxSyncError {
        fn from(_e: esplora_client::Error) -> Self {
@@ -55,9 +58,16 @@ impl From<esplora_client::Error> for InternalError {
        }
 }
 
-#[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
-impl From<InternalError> for TxSyncError {
-       fn from(_e: InternalError) -> Self {
+#[cfg(feature = "electrum")]
+impl From<electrum_client::Error> for InternalError {
+       fn from(_e: electrum_client::Error) -> Self {
+               Self::Failed
+       }
+}
+
+#[cfg(feature = "electrum")]
+impl From<electrum_client::Error> for TxSyncError {
+       fn from(_e: electrum_client::Error) -> Self {
                Self::Failed
        }
 }