Skip to content

Commit a60d70d

Browse files
committed
deps: update bdk_chain to 4fe121e
1 parent 3e61d2a commit a60d70d

File tree

13 files changed

+102
-75
lines changed

13 files changed

+102
-75
lines changed

examples/example_wallet_electrum/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ edition = "2021"
55

66
[dependencies]
77
bdk_wallet = { path = "../../wallet", features = ["file_store"] }
8-
bdk_electrum = { version = "0.21" }
8+
# bdk_electrum = { version = "0.21" }
9+
bdk_electrum = { git = "https://github.com/bitcoindevkit/bdk", rev = "4fe121e7167cf93a8abf26c87d35b26a682f6cbc" }
910
anyhow = "1"

examples/example_wallet_electrum/src/main.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ 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.20", features = ["async-https", "tokio"] }
11+
bdk_esplora = { git = "https://github.com/bitcoindevkit/bdk", rev = "4fe121e7167cf93a8abf26c87d35b26a682f6cbc", features = ["async-https", "tokio"] }
1112
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
1213
anyhow = "1"

examples/example_wallet_esplora_blocking/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ 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.20", features = ["blocking"] }
12+
bdk_esplora = { git = "https://github.com/bitcoindevkit/bdk", rev = "4fe121e7167cf93a8abf26c87d35b26a682f6cbc", features = ["blocking"] }
1213
anyhow = "1"

examples/example_wallet_esplora_blocking/src/main.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ 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.18" }
11+
bdk_bitcoind_rpc = { git = "https://github.com/bitcoindevkit/bdk", rev = "4fe121e7167cf93a8abf26c87d35b26a682f6cbc" }
1112

1213
anyhow = "1"
1314
clap = { version = "4.5.17", features = ["derive", "env"] }

examples/example_wallet_rpc/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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())

wallet/Cargo.toml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,22 @@ 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 }
29+
30+
[dependencies.bdk_chain]
31+
git = "https://github.com/bitcoindevkit/bdk"
32+
rev = "4fe121e7167cf93a8abf26c87d35b26a682f6cbc"
33+
default-features = false
34+
features = ["miniscript", "serde"]
35+
36+
[dependencies.bdk_file_store]
37+
git = "https://github.com/bitcoindevkit/bdk"
38+
rev = "4fe121e7167cf93a8abf26c87d35b26a682f6cbc"
39+
optional = true
2940

3041
[features]
3142
default = ["std"]
@@ -41,12 +52,16 @@ test-utils = ["std"]
4152
lazy_static = "1.4"
4253
assert_matches = "1.5.0"
4354
tempfile = "3"
44-
bdk_chain = { version = "0.21.1", features = ["rusqlite"] }
55+
# bdk_chain = { version = "0.22.0", features = ["rusqlite"] }
4556
bdk_wallet = { path = ".", features = ["rusqlite", "file_store", "test-utils"] }
46-
bdk_file_store = { version = "0.18.1" }
4757
anyhow = "1"
4858
rand = "^0.8"
4959

60+
[dev-dependencies.bdk_chain]
61+
git = "https://github.com/bitcoindevkit/bdk"
62+
rev = "4fe121e7167cf93a8abf26c87d35b26a682f6cbc"
63+
features = ["rusqlite"]
64+
5065
[package.metadata.docs.rs]
5166
all-features = true
5267
rustdoc-args = ["--cfg", "docsrs"]

wallet/README.md

Lines changed: 2 additions & 3 deletions
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

Lines changed: 20 additions & 18 deletions
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)