Skip to content

Commit 237ecdf

Browse files
committed
refactor!: comment out Wallet dependant code.
added #![allow(unused)] to circumvent clippy errors.
1 parent e5a824d commit 237ecdf

24 files changed

+11580
-11346
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ To persist `Wallet` state use a data storage crate that reads and writes [`Chang
7575
* [`bdk_file_store`]: Stores wallet changes in a simple flat file.
7676
* `rusqlite`: Stores wallet changes in a SQLite database.
7777

78-
**Example**
78+
<!-- **Example**
7979
8080
```rust,no_run
8181
use bdk_wallet::rusqlite;
@@ -110,7 +110,7 @@ wallet.persist(&mut conn)?;
110110
111111
println!("Next receive address: {}", address_info.address);
112112
Ok::<_, anyhow::Error>(())
113-
```
113+
``` -->
114114

115115
## Minimum Supported Rust Version (MSRV)
116116

examples/bitcoind_rpc.rs

Lines changed: 111 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unused)]
12
use bdk_bitcoind_rpc::{
23
bitcoincore_rpc::{Auth, Client, RpcApi},
34
Emitter, MempoolEvent,
@@ -84,125 +85,125 @@ enum Emission {
8485
}
8586

8687
fn main() -> anyhow::Result<()> {
87-
let args = Args::parse();
88+
// let args = Args::parse();
8889

89-
let rpc_client = Arc::new(args.client()?);
90-
println!(
91-
"Connected to Bitcoin Core RPC at {:?}",
92-
rpc_client.get_blockchain_info().unwrap()
93-
);
90+
// let rpc_client = Arc::new(args.client()?);
91+
// println!(
92+
// "Connected to Bitcoin Core RPC at {:?}",
93+
// rpc_client.get_blockchain_info().unwrap()
94+
// );
9495

95-
let start_load_wallet = Instant::now();
96-
let mut db = Connection::open(args.db_path)?;
97-
let wallet_opt = Wallet::load()
98-
.descriptor(KeychainKind::External, Some(args.descriptor.clone()))
99-
.descriptor(KeychainKind::Internal, args.change_descriptor.clone())
100-
.extract_keys()
101-
.check_network(args.network)
102-
.load_wallet(&mut db)?;
103-
let mut wallet = match wallet_opt {
104-
Some(wallet) => wallet,
105-
None => match &args.change_descriptor {
106-
Some(change_desc) => Wallet::create(args.descriptor.clone(), change_desc.clone())
107-
.network(args.network)
108-
.create_wallet(&mut db)?,
109-
None => Wallet::create_single(args.descriptor.clone())
110-
.network(args.network)
111-
.create_wallet(&mut db)?,
112-
},
113-
};
114-
println!(
115-
"Loaded wallet in {}s",
116-
start_load_wallet.elapsed().as_secs_f32()
117-
);
96+
// let start_load_wallet = Instant::now();
97+
// let mut db = Connection::open(args.db_path)?;
98+
// let wallet_opt = Wallet::load()
99+
// .descriptor(KeychainKind::External, Some(args.descriptor.clone()))
100+
// .descriptor(KeychainKind::Internal, args.change_descriptor.clone())
101+
// .extract_keys()
102+
// .check_network(args.network)
103+
// .load_wallet(&mut db)?;
104+
// let mut wallet = match wallet_opt {
105+
// Some(wallet) => wallet,
106+
// None => match &args.change_descriptor {
107+
// Some(change_desc) => Wallet::create(args.descriptor.clone(), change_desc.clone())
108+
// .network(args.network)
109+
// .create_wallet(&mut db)?,
110+
// None => Wallet::create_single(args.descriptor.clone())
111+
// .network(args.network)
112+
// .create_wallet(&mut db)?,
113+
// },
114+
// };
115+
// println!(
116+
// "Loaded wallet in {}s",
117+
// start_load_wallet.elapsed().as_secs_f32()
118+
// );
118119

119-
let address = wallet.reveal_next_address(KeychainKind::External).address;
120-
println!("Wallet address: {address}");
120+
// let address = wallet.reveal_next_address(KeychainKind::External).address;
121+
// println!("Wallet address: {address}");
121122

122-
let balance = wallet.balance();
123-
println!("Wallet balance before syncing: {}", balance.total());
123+
// let balance = wallet.balance();
124+
// println!("Wallet balance before syncing: {}", balance.total());
124125

125-
let wallet_tip = wallet.latest_checkpoint();
126-
println!(
127-
"Wallet tip: {} at height {}",
128-
wallet_tip.hash(),
129-
wallet_tip.height()
130-
);
126+
// let wallet_tip = wallet.latest_checkpoint();
127+
// println!(
128+
// "Wallet tip: {} at height {}",
129+
// wallet_tip.hash(),
130+
// wallet_tip.height()
131+
// );
131132

132-
let (sender, receiver) = sync_channel::<Emission>(21);
133+
// let (sender, receiver) = sync_channel::<Emission>(21);
133134

134-
let signal_sender = sender.clone();
135-
let _ = ctrlc::set_handler(move || {
136-
signal_sender
137-
.send(Emission::SigTerm)
138-
.expect("failed to send sigterm")
139-
});
135+
// let signal_sender = sender.clone();
136+
// let _ = ctrlc::set_handler(move || {
137+
// signal_sender
138+
// .send(Emission::SigTerm)
139+
// .expect("failed to send sigterm")
140+
// });
140141

141-
let mut emitter = Emitter::new(
142-
rpc_client,
143-
wallet_tip,
144-
args.start_height,
145-
wallet
146-
.transactions()
147-
.filter(|tx| tx.chain_position.is_unconfirmed()),
148-
);
149-
spawn(move || -> Result<(), anyhow::Error> {
150-
while let Some(emission) = emitter.next_block()? {
151-
sender.send(Emission::Block(emission))?;
152-
}
153-
sender.send(Emission::Mempool(emitter.mempool()?))?;
154-
Ok(())
155-
});
142+
// let mut emitter = Emitter::new(
143+
// rpc_client,
144+
// wallet_tip,
145+
// args.start_height,
146+
// wallet
147+
// .transactions()
148+
// .filter(|tx| tx.chain_position.is_unconfirmed()),
149+
// );
150+
// spawn(move || -> Result<(), anyhow::Error> {
151+
// while let Some(emission) = emitter.next_block()? {
152+
// sender.send(Emission::Block(emission))?;
153+
// }
154+
// sender.send(Emission::Mempool(emitter.mempool()?))?;
155+
// Ok(())
156+
// });
156157

157-
let mut blocks_received = 0_usize;
158-
for emission in receiver {
159-
match emission {
160-
Emission::SigTerm => {
161-
println!("Sigterm received, exiting...");
162-
break;
163-
}
164-
Emission::Block(block_emission) => {
165-
blocks_received += 1;
166-
let height = block_emission.block_height();
167-
let hash = block_emission.block_hash();
168-
let connected_to = block_emission.connected_to();
169-
let start_apply_block = Instant::now();
170-
wallet.apply_block_connected_to(&block_emission.block, height, connected_to)?;
171-
wallet.persist(&mut db)?;
172-
let elapsed = start_apply_block.elapsed().as_secs_f32();
173-
println!("Applied block {hash} at height {height} in {elapsed}s");
174-
}
175-
Emission::Mempool(event) => {
176-
let start_apply_mempool = Instant::now();
177-
wallet.apply_evicted_txs(event.evicted);
178-
wallet.apply_unconfirmed_txs(event.update);
179-
wallet.persist(&mut db)?;
180-
println!(
181-
"Applied unconfirmed transactions in {}s",
182-
start_apply_mempool.elapsed().as_secs_f32()
183-
);
184-
break;
185-
}
186-
}
187-
}
188-
let wallet_tip_end = wallet.latest_checkpoint();
189-
let balance = wallet.balance();
190-
println!(
191-
"Synced {} blocks in {}s",
192-
blocks_received,
193-
start_load_wallet.elapsed().as_secs_f32(),
194-
);
195-
println!(
196-
"Wallet tip is '{}:{}'",
197-
wallet_tip_end.height(),
198-
wallet_tip_end.hash()
199-
);
200-
println!("Wallet balance is {}", balance.total());
201-
println!(
202-
"Wallet has {} transactions and {} utxos",
203-
wallet.transactions().count(),
204-
wallet.list_unspent().count()
205-
);
158+
// let mut blocks_received = 0_usize;
159+
// for emission in receiver {
160+
// match emission {
161+
// Emission::SigTerm => {
162+
// println!("Sigterm received, exiting...");
163+
// break;
164+
// }
165+
// Emission::Block(block_emission) => {
166+
// blocks_received += 1;
167+
// let height = block_emission.block_height();
168+
// let hash = block_emission.block_hash();
169+
// let connected_to = block_emission.connected_to();
170+
// let start_apply_block = Instant::now();
171+
// wallet.apply_block_connected_to(&block_emission.block, height, connected_to)?;
172+
// wallet.persist(&mut db)?;
173+
// let elapsed = start_apply_block.elapsed().as_secs_f32();
174+
// println!("Applied block {hash} at height {height} in {elapsed}s");
175+
// }
176+
// Emission::Mempool(event) => {
177+
// let start_apply_mempool = Instant::now();
178+
// wallet.apply_evicted_txs(event.evicted);
179+
// wallet.apply_unconfirmed_txs(event.update);
180+
// wallet.persist(&mut db)?;
181+
// println!(
182+
// "Applied unconfirmed transactions in {}s",
183+
// start_apply_mempool.elapsed().as_secs_f32()
184+
// );
185+
// break;
186+
// }
187+
// }
188+
// }
189+
// let wallet_tip_end = wallet.latest_checkpoint();
190+
// let balance = wallet.balance();
191+
// println!(
192+
// "Synced {} blocks in {}s",
193+
// blocks_received,
194+
// start_load_wallet.elapsed().as_secs_f32(),
195+
// );
196+
// println!(
197+
// "Wallet tip is '{}:{}'",
198+
// wallet_tip_end.height(),
199+
// wallet_tip_end.hash()
200+
// );
201+
// println!("Wallet balance is {}", balance.total());
202+
// println!(
203+
// "Wallet has {} transactions and {} utxos",
204+
// wallet.transactions().count(),
205+
// wallet.list_unspent().count()
206+
// );
206207

207208
Ok(())
208209
}

examples/compiler.rs

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
99
// You may not use this file except in accordance with one or both of these
1010
// licenses.
11-
11+
#![allow(unused)]
1212
extern crate bdk_wallet;
13-
extern crate bitcoin;
14-
extern crate miniscript;
15-
extern crate serde_json;
13+
// extern crate bitcoin;
14+
// extern crate miniscript;
15+
// extern crate serde_json;
1616

1717
use std::error::Error;
1818
use std::str::FromStr;
@@ -32,47 +32,52 @@ use bdk_wallet::{KeychainKind, Wallet};
3232
/// This example demonstrates the interaction between a bdk wallet and miniscript policy.
3333
#[allow(clippy::print_stdout)]
3434
fn main() -> Result<(), Box<dyn Error>> {
35-
// We start with a miniscript policy string
36-
let policy_str = "or(
37-
10@thresh(4,
38-
pk(029ffbe722b147f3035c87cb1c60b9a5947dd49c774cc31e94773478711a929ac0),pk(025f05815e3a1a8a83bfbb03ce016c9a2ee31066b98f567f6227df1d76ec4bd143),pk(025625f41e4a065efc06d5019cbbd56fe8c07595af1231e7cbc03fafb87ebb71ec),pk(02a27c8b850a00f67da3499b60562673dcf5fdfb82b7e17652a7ac54416812aefd),pk(03e618ec5f384d6e19ca9ebdb8e2119e5bef978285076828ce054e55c4daf473e2)
39-
),1@and(
40-
older(4209713),
41-
thresh(2,
42-
pk(03deae92101c790b12653231439f27b8897264125ecb2f46f48278603102573165),pk(033841045a531e1adf9910a6ec279589a90b3b8a904ee64ffd692bd08a8996c1aa),pk(02aebf2d10b040eb936a6f02f44ee82f8b34f5c1ccb20ff3949c2b28206b7c1068)
43-
)
44-
)
45-
)"
46-
.replace(&[' ', '\n', '\t'][..], "");
35+
// // We start with a miniscript policy string
36+
// let policy_str = "or(
37+
// 10@thresh(4,
38+
// pk(029ffbe722b147f3035c87cb1c60b9a5947dd49c774cc31e94773478711a929ac0),
39+
// pk(025f05815e3a1a8a83bfbb03ce016c9a2ee31066b98f567f6227df1d76ec4bd143),
40+
// pk(025625f41e4a065efc06d5019cbbd56fe8c07595af1231e7cbc03fafb87ebb71ec),
41+
// pk(02a27c8b850a00f67da3499b60562673dcf5fdfb82b7e17652a7ac54416812aefd),
42+
// pk(03e618ec5f384d6e19ca9ebdb8e2119e5bef978285076828ce054e55c4daf473e2) ),1@and(
43+
// older(4209713),
44+
// thresh(2,
45+
//
46+
// pk(03deae92101c790b12653231439f27b8897264125ecb2f46f48278603102573165),
47+
// pk(033841045a531e1adf9910a6ec279589a90b3b8a904ee64ffd692bd08a8996c1aa),
48+
// pk(02aebf2d10b040eb936a6f02f44ee82f8b34f5c1ccb20ff3949c2b28206b7c1068) )
49+
// )
50+
// )"
51+
// .replace(&[' ', '\n', '\t'][..], "");
4752

48-
println!("Compiling policy: \n{policy_str}");
53+
// println!("Compiling policy: \n{policy_str}");
4954

50-
// Parse the string as a [`Concrete`] type miniscript policy.
51-
let policy = Concrete::<String>::from_str(&policy_str)?;
55+
// // Parse the string as a [`Concrete`] type miniscript policy.
56+
// let policy = Concrete::<String>::from_str(&policy_str)?;
5257

53-
// Create a `wsh` type descriptor from the policy.
54-
// `policy.compile()` returns the resulting miniscript from the policy.
55-
let descriptor = Descriptor::new_wsh(policy.compile()?)?.to_string();
58+
// // Create a `wsh` type descriptor from the policy.
59+
// // `policy.compile()` returns the resulting miniscript from the policy.
60+
// let descriptor = Descriptor::new_wsh(policy.compile()?)?.to_string();
5661

57-
println!("Compiled into Descriptor: \n{descriptor}");
62+
// println!("Compiled into Descriptor: \n{descriptor}");
5863

59-
// Create a new wallet from descriptors
60-
let mut wallet = Wallet::create_single(descriptor)
61-
.network(Network::Regtest)
62-
.create_wallet_no_persist()?;
64+
// // Create a new wallet from descriptors
65+
// let mut wallet = Wallet::create_single(descriptor)
66+
// .network(Network::Regtest)
67+
// .create_wallet_no_persist()?;
6368

64-
println!(
65-
"First derived address from the descriptor: \n{}",
66-
wallet.next_unused_address(KeychainKind::External),
67-
);
69+
// println!(
70+
// "First derived address from the descriptor: \n{}",
71+
// wallet.next_unused_address(KeychainKind::External),
72+
// );
6873

69-
// BDK also has it's own `Policy` structure to represent the spending condition in a more
70-
// human readable json format.
71-
let spending_policy = wallet.policies(KeychainKind::External)?;
72-
println!(
73-
"The BDK spending policy: \n{}",
74-
serde_json::to_string_pretty(&spending_policy)?
75-
);
74+
// // BDK also has it's own `Policy` structure to represent the spending condition in a more
75+
// // human readable json format.
76+
// let spending_policy = wallet.policies(KeychainKind::External)?;
77+
// println!(
78+
// "The BDK spending policy: \n{}",
79+
// serde_json::to_string_pretty(&spending_policy)?
80+
// );
7681

7782
Ok(())
7883
}

0 commit comments

Comments
 (0)