]> Untitled Git - bdk/commitdiff
docs: remove PersistBackend from docs, Cargo.toml and wallet README.md
authorSteve Myers <steve@notmandatory.org>
Fri, 14 Jun 2024 23:09:55 +0000 (18:09 -0500)
committerSteve Myers <steve@notmandatory.org>
Fri, 14 Jun 2024 23:16:14 +0000 (18:16 -0500)
crates/chain/src/changeset.rs
crates/file_store/Cargo.toml
crates/sqlite/Cargo.toml
crates/sqlite/README.md
crates/wallet/README.md

index 2612884b3681b604dfd6447f4c94a7025e5719d9..d84228409bf82f6fa0fabccd4d374194ba35945c 100644 (file)
@@ -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)]
index 392424cb38128b9fe93bbc246fa184bcb400b1da..a0df36cbc8089c79a955825ff3f2f639f3d836b3 100644 (file)
@@ -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"
index 238c818f73ce7fb7067fdb1cd6316fd8c85bf938..8dff341a97d2b77caee84170cb8d10b57b811c30 100644 (file)
@@ -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"
index 26f4650bc32132ffa20e2cc42cf8ff9155dfe0c5..ba612bded4a4b008fb929cd445e50a1b2b2ce513 100644 (file)
@@ -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
index 9aba478214e715d329078ad29fe658b622526867..ffe99474ebf4d61f68e111d62cd1f10ff8e8249a 100644 (file)
@@ -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 store crate that reads and writes [`bdk_chain::CombinedChangeSet`].
 
 **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`]: Stores 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);
 }
 ```
 
@@ -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