Skip to content

Commit

Permalink
docs: remove PersistBackend from docs, Cargo.toml and wallet README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
notmandatory committed Jun 14, 2024
1 parent feb27df commit 0816732
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
6 changes: 0 additions & 6 deletions crates/chain/src/changeset.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
//! This module is home to the [`PersistBackend`] trait which defines the behavior of a data store
//! required to persist changes made to BDK data structures.
//!
//! The [`CombinedChangeSet`] type encapsulates a combination of [`crate`] structures that are
//! typically persisted together.

/// A changeset containing [`crate`] structures typically persisted together.
#[cfg(feature = "miniscript")]
#[derive(Debug, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion crates/file_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/bitcoindevkit/bdk"
documentation = "https://docs.rs/bdk_file_store"
description = "A simple append-only flat file implementation of PersistBackend for Bitcoin Dev Kit."
description = "A simple append-only flat file database for persisting bdk_chain data."
keywords = ["bitcoin", "persist", "persistence", "bdk", "file"]
authors = ["Bitcoin Dev Kit Developers"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion crates/sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/bitcoindevkit/bdk"
documentation = "https://docs.rs/bdk_sqlite"
description = "A simple SQLite based implementation of PersistBackend for Bitcoin Dev Kit."
description = "A simple SQLite relational database client for persisting bdk_chain data."
keywords = ["bitcoin", "persist", "persistence", "bdk", "sqlite"]
authors = ["Bitcoin Dev Kit Developers"]
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions crates/sqlite/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# BDK SQLite

This is a simple [SQLite] relational database schema backed implementation of `PersistBackend`.
This is a simple [SQLite] relational database client for persisting [`bdk_chain`] changesets.

The main structure is `Store` which persists `CombinedChangeSet` data into a SQLite database file.

<!-- [`PersistBackend`]: bdk_chain::persist::PersistBackend -->
[`bdk_chain`]:https://docs.rs/bdk_chain/latest/bdk_chain/
[SQLite]: https://www.sqlite.org/index.html
38 changes: 24 additions & 14 deletions crates/wallet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,42 @@ that the `Wallet` can use to update its view of the chain.

## Persistence

To persist `Wallet` state data on disk use an implementation of the [`PersistBackend`] trait.
To persist `Wallet` state data use a data storage crate that reads and writes [`bdk_chain::CombinedChangeSet`] data.

**Implementations**

* [`bdk_file_store`]: A simple flat-file implementation of [`PersistBackend`].
* [`bdk_sqlite`]: A simple sqlite implementation of [`PersistBackend`].
* [`bdk_file_store`]: Stores wallet changes in a simple flat file.
* [`bdk_sqlite`]: Store wallet changes in a SQLite relational database file.

**Example**

<!-- compile_fail because outpoint and txout are fake variables -->
```rust,compile_fail
use bdk_wallet::{bitcoin::Network, wallet::{ChangeSet, Wallet}};
```rust,no_run
use bdk_wallet::{bitcoin::Network, KeychainKind, wallet::{ChangeSet, Wallet}};
fn main() {
// Create a new file `Store`.
let mut db = bdk_file_store::Store::<ChangeSet>::open_or_create_new(b"magic_bytes", "path/to/my_wallet.db").expect("create store");
// Open or create a new file store for wallet data.
let mut db =
bdk_file_store::Store::<ChangeSet>::open_or_create_new(b"magic_bytes", "/tmp/my_wallet.db")
.expect("create store");
// Create a wallet with initial wallet data read from the file store.
let descriptor = "wpkh(tprv8ZgxMBicQKsPdcAqYBpzAFwU5yxBUo88ggoBqu1qPcHUfSbKK1sKMLmC7EAk438btHQrSdu3jGGQa6PA71nvH5nkDexhLteJqkM4dQmWF9g/84'/1'/0'/0/*)";
let change_descriptor = "wpkh(tprv8ZgxMBicQKsPdcAqYBpzAFwU5yxBUo88ggoBqu1qPcHUfSbKK1sKMLmC7EAk438btHQrSdu3jGGQa6PA71nvH5nkDexhLteJqkM4dQmWF9g/84'/1'/0'/1/*)";
let changeset = db.load_changes().expect("changeset loaded");
let mut wallet = Wallet::new_or_load(descriptor, change_descriptor, changeset, Network::Testnet).expect("create or load wallet");
// Insert a single `TxOut` at `OutPoint` into the wallet.
let _ = wallet.insert_txout(outpoint, txout);
wallet.commit_to(&mut db).expect("must commit changes to database");
let changeset = db.aggregate_changesets().expect("changeset loaded");
let mut wallet =
Wallet::new_or_load(descriptor, change_descriptor, changeset, Network::Testnet)
.expect("create or load wallet");
// Get a new address to receive bitcoin.
let receive_address = wallet.reveal_next_address(KeychainKind::External);
// Persist staged wallet data changes to the file store.
let staged_changeset = wallet.take_staged();
if let Some(changeset) = staged_changeset {
db.append_changeset(&changeset)
.expect("must commit changes to database");
}
println!("Your new receive address is: {}", receive_address.address);
}
```

Expand Down Expand Up @@ -222,7 +233,6 @@ license, shall be dual licensed as above, without any additional terms or
conditions.

[`Wallet`]: https://docs.rs/bdk_wallet/latest/bdk_wallet/wallet/struct.Wallet.html
[`PersistBackend`]: https://docs.rs/bdk_chain/latest/bdk_chain/persist/trait.PersistBackend.html
[`bdk_chain`]: https://docs.rs/bdk_chain/latest
[`bdk_file_store`]: https://docs.rs/bdk_file_store/latest
[`bdk_sqlite`]: https://docs.rs/bdk_sqlite/latest
Expand Down

0 comments on commit 0816732

Please sign in to comment.