]> Untitled Git - bdk-cli/commitdiff
ref(persister): mv persister into wallet subdir
authorVihiga Tyonum <withtvpeter@gmail.com>
Tue, 21 Apr 2026 10:08:44 +0000 (11:08 +0100)
committerVihiga Tyonum <withtvpeter@gmail.com>
Fri, 5 Jun 2026 15:43:08 +0000 (16:43 +0100)
- move persister into wallet subdirectory
- update imports in payjoin module

src/payjoin/mod.rs
src/persister.rs [deleted file]
src/wallet/persister.rs [new file with mode: 0644]

index 19beb7d2b8662ccab5c65f843fcf65fabee49384..30a6774102cb9ca968bd97ed5552585ccbd58dee 100644 (file)
@@ -1,6 +1,14 @@
-use crate::error::BDKCliError as Error;
-use crate::handlers::{broadcast_transaction, sync_wallet};
-use crate::utils::BlockchainClient;
+#![cfg(any(
+    feature = "electrum",
+    feature = "esplora",
+    feature = "rpc",
+    feature = "cbf"
+))]
+
+use crate::{
+    backend::BlockchainClient,
+    handlers::online::{broadcast_transaction, sync_wallet},
+};
 use bdk_wallet::{
     SignOptions, Wallet,
     bitcoin::{FeeRate, Psbt, Txid, consensus::encode::serialize_hex},
@@ -22,7 +30,10 @@ use payjoin::{ImplementationError, UriExt};
 use serde_json::{json, to_string_pretty};
 use std::sync::{Arc, Mutex};
 
-use crate::payjoin::ohttp::{RelayManager, fetch_ohttp_keys};
+use crate::{
+    error::BDKCliError as Error,
+    payjoin::ohttp::{RelayManager, fetch_ohttp_keys},
+};
 
 pub mod ohttp;
 
@@ -109,6 +120,12 @@ impl<'a> PayjoinManager<'a> {
         Ok(to_string_pretty(&json!({}))?)
     }
 
+    #[cfg(any(
+        feature = "electrum",
+        feature = "esplora",
+        feature = "rpc",
+        feature = "cbf"
+    ))]
     pub async fn send_payjoin(
         &mut self,
         uri: String,
diff --git a/src/persister.rs b/src/persister.rs
deleted file mode 100644 (file)
index 1f9a742..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-use crate::error::BDKCliError;
-use bdk_wallet::WalletPersister;
-
-// Types of Persistence backends supported by bdk-cli
-pub(crate) enum Persister {
-    #[cfg(feature = "sqlite")]
-    Connection(bdk_wallet::rusqlite::Connection),
-    #[cfg(feature = "redb")]
-    RedbStore(bdk_redb::Store),
-}
-
-impl WalletPersister for Persister {
-    type Error = BDKCliError;
-
-    fn initialize(persister: &mut Self) -> Result<bdk_wallet::ChangeSet, Self::Error> {
-        match persister {
-            #[cfg(feature = "sqlite")]
-            Persister::Connection(connection) => {
-                WalletPersister::initialize(connection).map_err(BDKCliError::from)
-            }
-            #[cfg(feature = "redb")]
-            Persister::RedbStore(store) => {
-                WalletPersister::initialize(store).map_err(BDKCliError::from)
-            }
-        }
-    }
-
-    fn persist(persister: &mut Self, changeset: &bdk_wallet::ChangeSet) -> Result<(), Self::Error> {
-        match persister {
-            #[cfg(feature = "sqlite")]
-            Persister::Connection(connection) => {
-                WalletPersister::persist(connection, changeset).map_err(BDKCliError::from)
-            }
-            #[cfg(feature = "redb")]
-            Persister::RedbStore(store) => {
-                WalletPersister::persist(store, changeset).map_err(BDKCliError::from)
-            }
-        }
-    }
-}
diff --git a/src/wallet/persister.rs b/src/wallet/persister.rs
new file mode 100644 (file)
index 0000000..1f9a742
--- /dev/null
@@ -0,0 +1,40 @@
+use crate::error::BDKCliError;
+use bdk_wallet::WalletPersister;
+
+// Types of Persistence backends supported by bdk-cli
+pub(crate) enum Persister {
+    #[cfg(feature = "sqlite")]
+    Connection(bdk_wallet::rusqlite::Connection),
+    #[cfg(feature = "redb")]
+    RedbStore(bdk_redb::Store),
+}
+
+impl WalletPersister for Persister {
+    type Error = BDKCliError;
+
+    fn initialize(persister: &mut Self) -> Result<bdk_wallet::ChangeSet, Self::Error> {
+        match persister {
+            #[cfg(feature = "sqlite")]
+            Persister::Connection(connection) => {
+                WalletPersister::initialize(connection).map_err(BDKCliError::from)
+            }
+            #[cfg(feature = "redb")]
+            Persister::RedbStore(store) => {
+                WalletPersister::initialize(store).map_err(BDKCliError::from)
+            }
+        }
+    }
+
+    fn persist(persister: &mut Self, changeset: &bdk_wallet::ChangeSet) -> Result<(), Self::Error> {
+        match persister {
+            #[cfg(feature = "sqlite")]
+            Persister::Connection(connection) => {
+                WalletPersister::persist(connection, changeset).map_err(BDKCliError::from)
+            }
+            #[cfg(feature = "redb")]
+            Persister::RedbStore(store) => {
+                WalletPersister::persist(store, changeset).map_err(BDKCliError::from)
+            }
+        }
+    }
+}