Skip to content

Commit e86b45b

Browse files
committed
feat(handlers): mv feats into subdirs in handlers
1 parent 89b4b86 commit e86b45b

11 files changed

Lines changed: 34 additions & 39 deletions

File tree

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub enum BDKCliError {
154154

155155
#[cfg(feature = "payjoin")]
156156
#[error("Payjoin database error: {0}")]
157-
PayjoinDb(#[from] crate::payjoin::db::Error),
157+
PayjoinDb(#[from] crate::handlers::payjoin::db::Error),
158158

159159
#[cfg(feature = "bip322")]
160160
#[error("BIP-322 error: {0}")]
File renamed without changes.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
use crate::dns_payment_instructions::{
1+
mod dns_payment_instructions;
2+
3+
use crate::error::BDKCliError as Error;
4+
use crate::handlers::dns::dns_payment_instructions::{
25
parse_dns_instructions, process_instructions, resolve_dns_recipient,
36
};
4-
use crate::error::BDKCliError as Error;
57
use crate::handlers::{AppContext, AsyncAppCommand, Init, OfflineOperations};
68
use crate::utils::types::{PsbtResult, StatusResult};
79
use crate::utils::{parse_dns_recipient, parse_outpoint, parse_recipient};
@@ -168,6 +170,6 @@ impl AsyncAppCommand<AppContext<OfflineOperations<'_>>> for CreateDnsTxCommand {
168170
}
169171

170172
let psbt = tx_builder.finish()?;
171-
Ok(PsbtResult::new(&psbt, false, Some(false)))
173+
Ok(PsbtResult::new(&psbt, Some(false)))
172174
}
173175
}

src/handlers/key.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
use crate::commands::KeySubCommand;
22
use crate::error::BDKCliError as Error;
3-
use crate::handlers::Init;
4-
use crate::handlers::{AppCommand, AppContext};
5-
use crate::utils::output::FormatOutput;
6-
use crate::utils::types::KeyResult;
3+
use crate::handlers::{AppCommand, AppContext, Init};
4+
use crate::utils::{output::FormatOutput, types::KeyResult};
75
use bdk_wallet::bip39::{Language, Mnemonic};
8-
use bdk_wallet::bitcoin::bip32::DerivationPath;
9-
use bdk_wallet::bitcoin::bip32::KeySource;
10-
use bdk_wallet::bitcoin::bip32::Xpriv;
6+
use bdk_wallet::bitcoin::bip32::{DerivationPath, KeySource, Xpriv};
117
use bdk_wallet::bitcoin::key::Secp256k1;
12-
use bdk_wallet::keys::bip39::WordCount;
13-
use bdk_wallet::keys::{DerivableKey, GeneratableKey};
14-
use bdk_wallet::keys::{DescriptorKey, ExtendedKey, GeneratedKey};
8+
use bdk_wallet::keys::{
9+
DerivableKey, DescriptorKey, ExtendedKey, GeneratableKey, GeneratedKey, bip39::WordCount,
10+
};
1511
use bdk_wallet::miniscript::{self, Segwitv0};
1612
use clap::Parser;
1713

src/handlers/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ pub mod dns;
55
pub mod key;
66
pub mod offline;
77
pub mod online;
8+
#[cfg(any(
9+
feature = "electrum",
10+
feature = "esplora",
11+
feature = "cbf",
12+
feature = "rpc"
13+
))]
14+
pub mod payjoin;
815
pub mod repl;
916

1017
#[cfg(any(

src/handlers/offline.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ impl OfflineWalletSubCommand {
8484
.write_out(std::io::stdout()),
8585
#[cfg(feature = "dns_payment")]
8686
Self::CreateDnsTx(_) => Err(Error::Generic(
87-
"CreateDnsTx is dispatched asynchronously through main"
88-
.to_string(),
87+
"CreateDnsTx is dispatched asynchronously through main".to_string(),
8988
)),
9089
}
9190
}

src/handlers/online.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ use clap::Parser;
22

33
#[cfg(feature = "electrum")]
44
use crate::client::BlockchainClient::Electrum;
5-
#[cfg(feature = "rpc")]
6-
use crate::client::BlockchainClient::RpcClient;
75
#[cfg(feature = "cbf")]
86
use crate::client::{BlockchainClient::KyotoClient, sync_kyoto_client};
97
#[cfg(feature = "esplora")]
108
use {crate::client::BlockchainClient::Esplora, bdk_esplora::EsploraAsyncExt};
119
#[cfg(feature = "rpc")]
1210
use {
11+
crate::client::BlockchainClient::RpcClient,
1312
bdk_bitcoind_rpc::{Emitter, NO_EXPECTED_MEMPOOL_TXS, bitcoincore_rpc::RpcApi},
1413
bdk_wallet::chain::{BlockId, CanonicalizationParams, CheckPoint},
1514
};
@@ -27,11 +26,12 @@ use crate::utils::print_wallet_events;
2726
use {
2827
crate::commands::OnlineWalletSubCommand,
2928
crate::error::BDKCliError as Error,
30-
crate::handlers::{AppContext, AsyncAppCommand, OnlineOperations},
31-
crate::payjoin::PayjoinManager,
32-
crate::utils::is_final,
33-
crate::utils::output::FormatOutput,
34-
crate::utils::types::{StatusResult, TransactionResult},
29+
crate::handlers::{AppContext, AsyncAppCommand, OnlineOperations, payjoin::PayjoinManager},
30+
crate::utils::{
31+
is_final,
32+
output::FormatOutput,
33+
types::{StatusResult, TransactionResult},
34+
},
3535
bdk_wallet::bitcoin::{
3636
Psbt, Transaction, Txid, base64::Engine, base64::prelude::BASE64_STANDARD,
3737
consensus::Decodable, hex::FromHex,
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,9 @@ mod tests {
814814
.get_inactive_recv_session_ids()
815815
.expect("inactive receiver ids should load");
816816

817-
let table = crate::payjoin::PayjoinManager::history(Some(datadir.clone()), wallet_name)
818-
.expect("history should render");
817+
let table =
818+
crate::handlers::payjoin::PayjoinManager::history(Some(datadir.clone()), wallet_name)
819+
.expect("history should render");
819820

820821
assert!(table.contains("Sender"));
821822
assert!(table.contains("Receiver"));
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use payjoin::{HpkePublicKey, ImplementationError, UriExt};
2424
use serde_json::{json, to_string_pretty};
2525
use std::{path::PathBuf, sync::Arc};
2626

27-
use crate::payjoin::db::{ReceiverPersister, SenderPersister, open_payjoin_db};
28-
use crate::payjoin::ohttp::RelayManager;
27+
use crate::handlers::payjoin::db::{ReceiverPersister, SenderPersister, open_payjoin_db};
28+
use crate::handlers::payjoin::ohttp::RelayManager;
2929

3030
pub mod db;
3131
pub mod ohttp;
@@ -38,7 +38,7 @@ pub mod ohttp;
3838
pub(crate) struct PayjoinManager<'a> {
3939
wallet: &'a mut Wallet,
4040
relay_manager: RelayManager,
41-
db: Arc<crate::payjoin::db::Database>,
41+
db: Arc<crate::handlers::payjoin::db::Database>,
4242
}
4343

4444
trait StatusText {
@@ -136,7 +136,7 @@ impl<'a> PayjoinManager<'a> {
136136
self.relay_manager.configure(ohttp_relays)?;
137137
let ohttp_keys = self.relay_manager.fetch_ohttp_keys(&directory).await?;
138138

139-
let persister = crate::payjoin::db::ReceiverPersister::new(self.db.clone())?;
139+
let persister = crate::handlers::payjoin::db::ReceiverPersister::new(self.db.clone())?;
140140

141141
let checked_max_fee_rate = max_fee_rate
142142
.map(FeeRate::from_sat_per_kwu)

0 commit comments

Comments
 (0)