Skip to content

Commit ed3ccc1

Browse files
committed
Merge #1412: Add new crate bdk-persist
81de8f6 feat(bdk-persist): extract persistence traits to new crate (Rob N) Pull request description: ### Description #1387 introduced `anyhow` as a dependency to remove generics from `Wallet`. Introducing a new crate for persistence types removes the dependency on `anyhow` for `bdk_chain`. Resolves #1409, as well as removing the old documentation for "tracker". ### Notes to the reviewers Open for any comments. ### Changelog notice - Introduce `bdk-persist` crate ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [ ] I've added tests for the new feature * [ ] I've added docs for the new feature #### Bugfixes: * [ ] This pull request breaks the existing API * [ ] I've added tests to reproduce the issue which are now passing * [x] I'm linking the issue being fixed by this PR ACKs for top commit: evanlinjin: ACK 81de8f6 Tree-SHA512: 29b192b13f3951cc67c06bec7f788d8d7a4aeaf2ffcbf9476d4a6567529d284a93594c8d94b69741a68a9aadfdc9f6c4178084a2298c505e8e0d505219400382
2 parents 8e73998 + 81de8f6 commit ed3ccc1

File tree

18 files changed

+52
-24
lines changed

18 files changed

+52
-24
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"crates/esplora",
99
"crates/bitcoind_rpc",
1010
"crates/hwi",
11+
"crates/persist",
1112
"crates/testenv",
1213
"example-crates/example_cli",
1314
"example-crates/example_electrum",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The project is split up into several crates in the `/crates` directory:
4141

4242
- [`bdk`](./crates/bdk): Contains the central high level `Wallet` type that is built from the low-level mechanisms provided by the other components
4343
- [`chain`](./crates/chain): Tools for storing and indexing chain data
44+
- [`persist`](./crates/persist): Types that define data persistence of a BDK wallet
4445
- [`file_store`](./crates/file_store): A (experimental) persistence backend for storing chain data in a single file.
4546
- [`esplora`](./crates/esplora): Extends the [`esplora-client`] crate with methods to fetch chain data from an esplora HTTP server in the form that [`bdk_chain`] and `Wallet` can consume.
4647
- [`electrum`](./crates/electrum): Extends the [`electrum-client`] crate with methods to fetch chain data from an electrum server in the form that [`bdk_chain`] and `Wallet` can consume.

crates/bdk/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ bitcoin = { version = "0.31.0", features = ["serde", "base64", "rand-std"], defa
2020
serde = { version = "^1.0", features = ["derive"] }
2121
serde_json = { version = "^1.0" }
2222
bdk_chain = { path = "../chain", version = "0.12.0", features = ["miniscript", "serde"], default-features = false }
23+
bdk_persist = { path = "../persist", version = "0.1.0" }
2324

2425
# Optional dependencies
2526
bip39 = { version = "2.0", optional = true }

crates/bdk/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ license, shall be dual licensed as above, without any additional terms or
219219
conditions.
220220

221221
[`Wallet`]: https://docs.rs/bdk/1.0.0-alpha.7/bdk/wallet/struct.Wallet.html
222-
[`PersistBackend`]: https://docs.rs/bdk_chain/latest/bdk_chain/trait.PersistBackend.html
222+
[`PersistBackend`]: https://docs.rs/bdk_persist/latest/bdk_persist/trait.PersistBackend.html
223223
[`bdk_chain`]: https://docs.rs/bdk_chain/latest
224224
[`bdk_file_store`]: https://docs.rs/bdk_file_store/latest
225225
[`bdk_electrum`]: https://docs.rs/bdk_electrum/latest

crates/bdk/src/wallet/coin_selection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
//! # use bitcoin::*;
2929
//! # use bdk::wallet::{self, ChangeSet, coin_selection::*, coin_selection};
3030
//! # use bdk::wallet::error::CreateTxError;
31-
//! # use bdk_chain::PersistBackend;
31+
//! # use bdk_persist::PersistBackend;
3232
//! # use bdk::*;
3333
//! # use bdk::wallet::coin_selection::decide_change;
3434
//! # use anyhow::Error;

crates/bdk/src/wallet/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ use bdk_chain::{
2828
},
2929
tx_graph::{CanonicalTx, TxGraph},
3030
Append, BlockId, ChainPosition, ConfirmationTime, ConfirmationTimeHeightAnchor, FullTxOut,
31-
IndexedTxGraph, Persist, PersistBackend,
31+
IndexedTxGraph,
3232
};
33+
use bdk_persist::{Persist, PersistBackend};
3334
use bitcoin::constants::genesis_block;
3435
use bitcoin::secp256k1::{All, Secp256k1};
3536
use bitcoin::sighash::{EcdsaSighashType, TapSighashType};
@@ -1167,7 +1168,7 @@ impl Wallet {
11671168
/// # use bdk::*;
11681169
/// # use bdk::wallet::ChangeSet;
11691170
/// # use bdk::wallet::error::CreateTxError;
1170-
/// # use bdk_chain::PersistBackend;
1171+
/// # use bdk_persist::PersistBackend;
11711172
/// # use anyhow::Error;
11721173
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
11731174
/// # let mut wallet = doctest_wallet!();
@@ -1549,7 +1550,7 @@ impl Wallet {
15491550
/// # use bdk::*;
15501551
/// # use bdk::wallet::ChangeSet;
15511552
/// # use bdk::wallet::error::CreateTxError;
1552-
/// # use bdk_chain::PersistBackend;
1553+
/// # use bdk_persist::PersistBackend;
15531554
/// # use anyhow::Error;
15541555
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
15551556
/// # let mut wallet = doctest_wallet!();
@@ -1724,7 +1725,7 @@ impl Wallet {
17241725
/// # use bdk::*;
17251726
/// # use bdk::wallet::ChangeSet;
17261727
/// # use bdk::wallet::error::CreateTxError;
1727-
/// # use bdk_chain::PersistBackend;
1728+
/// # use bdk_persist::PersistBackend;
17281729
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
17291730
/// # let mut wallet = doctest_wallet!();
17301731
/// # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap().assume_checked();

crates/bdk/src/wallet/tx_builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//! # use bdk::wallet::ChangeSet;
2121
//! # use bdk::wallet::error::CreateTxError;
2222
//! # use bdk::wallet::tx_builder::CreateTx;
23-
//! # use bdk_chain::PersistBackend;
23+
//! # use bdk_persist::PersistBackend;
2424
//! # use anyhow::Error;
2525
//! # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap().assume_checked();
2626
//! # let mut wallet = doctest_wallet!();
@@ -84,7 +84,7 @@ impl TxBuilderContext for BumpFee {}
8484
/// # use core::str::FromStr;
8585
/// # use bdk::wallet::ChangeSet;
8686
/// # use bdk::wallet::error::CreateTxError;
87-
/// # use bdk_chain::PersistBackend;
87+
/// # use bdk_persist::PersistBackend;
8888
/// # use anyhow::Error;
8989
/// # let mut wallet = doctest_wallet!();
9090
/// # let addr1 = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap().assume_checked();
@@ -758,7 +758,7 @@ impl<'a, Cs: CoinSelectionAlgorithm> TxBuilder<'a, Cs, CreateTx> {
758758
/// # use bdk::wallet::ChangeSet;
759759
/// # use bdk::wallet::error::CreateTxError;
760760
/// # use bdk::wallet::tx_builder::CreateTx;
761-
/// # use bdk_chain::PersistBackend;
761+
/// # use bdk_persist::PersistBackend;
762762
/// # use anyhow::Error;
763763
/// # let to_address =
764764
/// Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt")

crates/chain/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ readme = "README.md"
1414

1515
[dependencies]
1616
# For no-std, remember to enable the bitcoin/no-std feature
17-
anyhow = { version = "1", default-features = false }
1817
bitcoin = { version = "0.31.0", default-features = false }
1918
serde_crate = { package = "serde", version = "1", optional = true, features = ["derive", "rc"] }
2019

crates/chain/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ pub use tx_data_traits::*;
3535
pub use tx_graph::TxGraph;
3636
mod chain_oracle;
3737
pub use chain_oracle::*;
38-
mod persist;
39-
pub use persist::*;
4038

4139
#[doc(hidden)]
4240
pub mod example_utils;

crates/file_store/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ readme = "README.md"
1313
[dependencies]
1414
anyhow = { version = "1", default-features = false }
1515
bdk_chain = { path = "../chain", version = "0.12.0", features = [ "serde", "miniscript" ] }
16+
bdk_persist = { path = "../persist", version = "0.1.0"}
1617
bincode = { version = "1" }
1718
serde = { version = "1", features = ["derive"] }
1819

0 commit comments

Comments
 (0)