Skip to content

Commit c2d27c0

Browse files
committed
deps!: update bdk_chain to 0.22.0
1 parent ea771d7 commit c2d27c0

File tree

13 files changed

+132
-91
lines changed

13 files changed

+132
-91
lines changed

examples/example_wallet_electrum/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ edition = "2021"
55

66
[dependencies]
77
bdk_wallet = { path = "../../wallet", features = ["file_store"] }
8-
bdk_electrum = { version = "0.21" }
8+
bdk_electrum = { version = "0.22.0" }
99
anyhow = "1"

examples/example_wallet_electrum/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const ELECTRUM_URL: &str = "ssl://electrum.blockstream.info:60002";
2222
fn main() -> Result<(), anyhow::Error> {
2323
let db_path = "bdk-electrum-example.db";
2424

25-
let mut db = Store::<bdk_wallet::ChangeSet>::open_or_create_new(DB_MAGIC.as_bytes(), db_path)?;
25+
let (mut db, _) = Store::<bdk_wallet::ChangeSet>::load_or_create(DB_MAGIC.as_bytes(), db_path)?;
2626

2727
let wallet_opt = Wallet::load()
2828
.descriptor(KeychainKind::External, Some(EXTERNAL_DESC))

examples/example_wallet_esplora_async/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ edition = "2021"
77

88
[dependencies]
99
bdk_wallet = { path = "../../wallet", features = ["rusqlite"] }
10-
bdk_esplora = { version = "0.20", features = ["async-https", "tokio"] }
10+
bdk_esplora = { version = "0.21.0", features = ["async-https", "tokio"] }
1111
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
1212
anyhow = "1"

examples/example_wallet_esplora_blocking/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ publish = false
88

99
[dependencies]
1010
bdk_wallet = { path = "../../wallet", features = ["file_store"] }
11-
bdk_esplora = { version = "0.20", features = ["blocking"] }
11+
bdk_esplora = { version = "0.21.0", features = ["blocking"] }
1212
anyhow = "1"

examples/example_wallet_esplora_blocking/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const INTERNAL_DESC: &str = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7
1919
const ESPLORA_URL: &str = "http://signet.bitcoindevkit.net";
2020

2121
fn main() -> Result<(), anyhow::Error> {
22-
let mut db = Store::<bdk_wallet::ChangeSet>::open_or_create_new(DB_MAGIC.as_bytes(), DB_PATH)?;
22+
let (mut db, _) = Store::<bdk_wallet::ChangeSet>::load_or_create(DB_MAGIC.as_bytes(), DB_PATH)?;
2323

2424
let wallet_opt = Wallet::load()
2525
.descriptor(KeychainKind::External, Some(EXTERNAL_DESC))

examples/example_wallet_rpc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
bdk_wallet = { path = "../../wallet", features = ["file_store"] }
10-
bdk_bitcoind_rpc = { version = "0.18" }
10+
bdk_bitcoind_rpc = { version = "0.19.0" }
1111

1212
anyhow = "1"
1313
clap = { version = "4.5.17", features = ["derive", "env"] }

examples/example_wallet_rpc/src/main.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use bdk_bitcoind_rpc::{
22
bitcoincore_rpc::{Auth, Client, RpcApi},
3-
Emitter,
3+
Emitter, MempoolEvent,
44
};
55
use bdk_wallet::{
6-
bitcoin::{Block, Network, Transaction},
6+
bitcoin::{Block, Network, Txid},
77
file_store::Store,
88
KeychainKind, Wallet,
99
};
@@ -73,7 +73,7 @@ impl Args {
7373
enum Emission {
7474
SigTerm,
7575
Block(bdk_bitcoind_rpc::BlockEvent<Block>),
76-
Mempool(Vec<(Transaction, u64)>),
76+
Mempool(MempoolEvent),
7777
}
7878

7979
fn main() -> anyhow::Result<()> {
@@ -86,8 +86,8 @@ fn main() -> anyhow::Result<()> {
8686
);
8787

8888
let start_load_wallet = Instant::now();
89-
let mut db =
90-
Store::<bdk_wallet::ChangeSet>::open_or_create_new(DB_MAGIC.as_bytes(), args.db_path)?;
89+
let (mut db, _) =
90+
Store::<bdk_wallet::ChangeSet>::load_or_create(DB_MAGIC.as_bytes(), args.db_path)?;
9191
let wallet_opt = Wallet::load()
9292
.descriptor(KeychainKind::External, Some(args.descriptor.clone()))
9393
.descriptor(KeychainKind::Internal, args.change_descriptor.clone())
@@ -131,7 +131,12 @@ fn main() -> anyhow::Result<()> {
131131

132132
let emitter_tip = wallet_tip.clone();
133133
spawn(move || -> Result<(), anyhow::Error> {
134-
let mut emitter = Emitter::new(&rpc_client, emitter_tip, args.start_height);
134+
let mut emitter = Emitter::new(
135+
&rpc_client,
136+
emitter_tip,
137+
args.start_height,
138+
core::iter::empty::<Txid>(),
139+
);
135140
while let Some(emission) = emitter.next_block()? {
136141
sender.send(Emission::Block(emission))?;
137142
}
@@ -160,9 +165,9 @@ fn main() -> anyhow::Result<()> {
160165
hash, height, elapsed
161166
);
162167
}
163-
Emission::Mempool(mempool_emission) => {
168+
Emission::Mempool(event) => {
164169
let start_apply_mempool = Instant::now();
165-
wallet.apply_unconfirmed_txs(mempool_emission);
170+
wallet.apply_unconfirmed_txs(event.new_txs);
166171
wallet.persist(&mut db)?;
167172
println!(
168173
"Applied unconfirmed transactions in {}s",

wallet/Cargo.toml

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ miniscript = { version = "12.3.1", features = [ "serde" ], default-features = fa
2121
bitcoin = { version = "0.32.4", features = [ "serde", "base64" ], default-features = false }
2222
serde = { version = "^1.0", features = ["derive"] }
2323
serde_json = { version = "^1.0" }
24-
bdk_chain = { version = "0.21.1", features = [ "miniscript", "serde" ], default-features = false }
25-
bdk_file_store = { version = "0.18.1", optional = true }
24+
bdk_chain = { version = "0.22.0", features = [ "miniscript", "serde" ], default-features = false }
2625

2726
# Optional dependencies
2827
bip39 = { version = "2.0", optional = true }
28+
bdk_file_store = { version = "0.20.0", optional = true }
2929

3030
[features]
3131
default = ["std"]
@@ -40,9 +40,8 @@ test-utils = ["std"]
4040
[dev-dependencies]
4141
assert_matches = "1.5.0"
4242
tempfile = "3"
43-
bdk_chain = { version = "0.21.1", features = ["rusqlite"] }
43+
bdk_chain = { version = "0.22.0", features = ["rusqlite"] }
4444
bdk_wallet = { path = ".", features = ["rusqlite", "file_store", "test-utils"] }
45-
bdk_file_store = { version = "0.18.1" }
4645
anyhow = "1"
4746
rand = "^0.8"
4847

wallet/README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,12 @@ To persist `Wallet` state data use a data store crate that reads and writes [`Ch
6565

6666
**Example**
6767

68-
<!-- compile_fail because outpoint and txout are fake variables -->
6968
```rust,no_run
7069
use bdk_wallet::{bitcoin::Network, KeychainKind, ChangeSet, Wallet};
7170
7271
// Open or create a new file store for wallet data.
73-
let mut db =
74-
bdk_file_store::Store::<ChangeSet>::open_or_create_new(b"magic_bytes", "/tmp/my_wallet.db")
72+
let (mut db, _changeset) =
73+
bdk_file_store::Store::<ChangeSet>::load_or_create(b"magic_bytes", "/tmp/my_wallet.db")
7574
.expect("create store");
7675
7776
// Create a wallet with initial wallet data read from the file store.

wallet/src/test_utils.rs

+20-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use alloc::string::ToString;
44
use alloc::sync::Arc;
55
use core::str::FromStr;
66

7-
use bdk_chain::{tx_graph, BlockId, ConfirmationBlockTime};
7+
use bdk_chain::{BlockId, ConfirmationBlockTime, TxUpdate};
88
use bitcoin::{
99
absolute, hashes::Hash, transaction, Address, Amount, BlockHash, FeeRate, Network, OutPoint,
1010
Transaction, TxIn, TxOut, Txid,
@@ -312,43 +312,45 @@ pub fn insert_checkpoint(wallet: &mut Wallet, block: BlockId) {
312312
.unwrap();
313313
}
314314

315-
/// Insert transaction
315+
/// Inserts a transaction into the local view, assuming it is currently present in the mempool.
316+
///
317+
/// This can be used, for example, to track a transaction immediately after it is broadcast.
316318
pub fn insert_tx(wallet: &mut Wallet, tx: Transaction) {
319+
let txid = tx.compute_txid();
320+
let seen_at = std::time::UNIX_EPOCH.elapsed().unwrap().as_secs();
321+
let mut tx_update = TxUpdate::default();
322+
tx_update.txs = vec![Arc::new(tx)];
323+
tx_update.seen_ats = [(txid, seen_at)].into();
317324
wallet
318325
.apply_update(Update {
319-
tx_update: bdk_chain::TxUpdate {
320-
txs: vec![Arc::new(tx)],
321-
..Default::default()
322-
},
326+
tx_update,
323327
..Default::default()
324328
})
325-
.unwrap();
329+
.expect("failed to apply update");
326330
}
327331

328332
/// Simulates confirming a tx with `txid` by applying an update to the wallet containing
329333
/// the given `anchor`. Note: to be considered confirmed the anchor block must exist in
330334
/// the current active chain.
331335
pub fn insert_anchor(wallet: &mut Wallet, txid: Txid, anchor: ConfirmationBlockTime) {
336+
let mut tx_update = TxUpdate::default();
337+
tx_update.anchors = [(anchor, txid)].into();
332338
wallet
333339
.apply_update(Update {
334-
tx_update: tx_graph::TxUpdate {
335-
anchors: [(anchor, txid)].into(),
336-
..Default::default()
337-
},
340+
tx_update,
338341
..Default::default()
339342
})
340-
.unwrap();
343+
.expect("failed to apply update");
341344
}
342345

343346
/// Marks the given `txid` seen as unconfirmed at `seen_at`
344347
pub fn insert_seen_at(wallet: &mut Wallet, txid: Txid, seen_at: u64) {
348+
let mut tx_update = TxUpdate::default();
349+
tx_update.seen_ats = [(txid, seen_at)].into();
345350
wallet
346-
.apply_update(crate::Update {
347-
tx_update: tx_graph::TxUpdate {
348-
seen_ats: [(txid, seen_at)].into_iter().collect(),
349-
..Default::default()
350-
},
351+
.apply_update(Update {
352+
tx_update,
351353
..Default::default()
352354
})
353-
.unwrap();
355+
.expect("failed to apply update");
354356
}

0 commit comments

Comments
 (0)