From: Vihiga Tyonum Date: Tue, 21 Apr 2026 10:08:44 +0000 (+0100) Subject: ref(persister): mv persister into wallet subdir X-Git-Url: http://internal-gitweb-vhost/blockdata/script/encode/-script/display/struct.ScriptHash.html?a=commitdiff_plain;h=eb3a6aa7798a9994b4a69a85abc65a32163b945f;p=bdk-cli ref(persister): mv persister into wallet subdir - move persister into wallet subdirectory - update imports in payjoin module --- diff --git a/src/payjoin/mod.rs b/src/payjoin/mod.rs index 19beb7d..30a6774 100644 --- a/src/payjoin/mod.rs +++ b/src/payjoin/mod.rs @@ -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 index 1f9a742..0000000 --- a/src/persister.rs +++ /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 { - 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 index 0000000..1f9a742 --- /dev/null +++ b/src/wallet/persister.rs @@ -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 { + 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) + } + } + } +}