docs: remove PersistBackend from docs, Cargo.toml and wallet README.md
This commit is contained in:
parent
feb27df180
commit
a0bf45bef1
@ -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.
|
/// A changeset containing [`crate`] structures typically persisted together.
|
||||||
#[cfg(feature = "miniscript")]
|
#[cfg(feature = "miniscript")]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
@ -5,7 +5,7 @@ edition = "2021"
|
|||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/bitcoindevkit/bdk"
|
repository = "https://github.com/bitcoindevkit/bdk"
|
||||||
documentation = "https://docs.rs/bdk_file_store"
|
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"]
|
keywords = ["bitcoin", "persist", "persistence", "bdk", "file"]
|
||||||
authors = ["Bitcoin Dev Kit Developers"]
|
authors = ["Bitcoin Dev Kit Developers"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
@ -5,7 +5,7 @@ edition = "2021"
|
|||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/bitcoindevkit/bdk"
|
repository = "https://github.com/bitcoindevkit/bdk"
|
||||||
documentation = "https://docs.rs/bdk_sqlite"
|
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"]
|
keywords = ["bitcoin", "persist", "persistence", "bdk", "sqlite"]
|
||||||
authors = ["Bitcoin Dev Kit Developers"]
|
authors = ["Bitcoin Dev Kit Developers"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# BDK SQLite
|
# 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.
|
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
|
[SQLite]: https://www.sqlite.org/index.html
|
||||||
|
@ -57,31 +57,42 @@ that the `Wallet` can use to update its view of the chain.
|
|||||||
|
|
||||||
## Persistence
|
## 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**
|
**Implementations**
|
||||||
|
|
||||||
* [`bdk_file_store`]: A simple flat-file implementation of [`PersistBackend`].
|
* [`bdk_file_store`]: Stores wallet changes in a simple flat file.
|
||||||
* [`bdk_sqlite`]: A simple sqlite implementation of [`PersistBackend`].
|
* [`bdk_sqlite`]: Stores wallet changes in a SQLite relational database file.
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
<!-- compile_fail because outpoint and txout are fake variables -->
|
<!-- compile_fail because outpoint and txout are fake variables -->
|
||||||
```rust,compile_fail
|
```rust,no_run
|
||||||
use bdk_wallet::{bitcoin::Network, wallet::{ChangeSet, Wallet}};
|
use bdk_wallet::{bitcoin::Network, KeychainKind, wallet::{ChangeSet, Wallet}};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Create a new file `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", "path/to/my_wallet.db").expect("create store");
|
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 descriptor = "wpkh(tprv8ZgxMBicQKsPdcAqYBpzAFwU5yxBUo88ggoBqu1qPcHUfSbKK1sKMLmC7EAk438btHQrSdu3jGGQa6PA71nvH5nkDexhLteJqkM4dQmWF9g/84'/1'/0'/0/*)";
|
||||||
let change_descriptor = "wpkh(tprv8ZgxMBicQKsPdcAqYBpzAFwU5yxBUo88ggoBqu1qPcHUfSbKK1sKMLmC7EAk438btHQrSdu3jGGQa6PA71nvH5nkDexhLteJqkM4dQmWF9g/84'/1'/0'/1/*)";
|
let change_descriptor = "wpkh(tprv8ZgxMBicQKsPdcAqYBpzAFwU5yxBUo88ggoBqu1qPcHUfSbKK1sKMLmC7EAk438btHQrSdu3jGGQa6PA71nvH5nkDexhLteJqkM4dQmWF9g/84'/1'/0'/1/*)";
|
||||||
let changeset = db.load_changes().expect("changeset loaded");
|
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");
|
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.
|
// Get a new address to receive bitcoin.
|
||||||
let _ = wallet.insert_txout(outpoint, txout);
|
let receive_address = wallet.reveal_next_address(KeychainKind::External);
|
||||||
wallet.commit_to(&mut db).expect("must commit changes to database");
|
// 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.
|
conditions.
|
||||||
|
|
||||||
[`Wallet`]: https://docs.rs/bdk_wallet/latest/bdk_wallet/wallet/struct.Wallet.html
|
[`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_chain`]: https://docs.rs/bdk_chain/latest
|
||||||
[`bdk_file_store`]: https://docs.rs/bdk_file_store/latest
|
[`bdk_file_store`]: https://docs.rs/bdk_file_store/latest
|
||||||
[`bdk_sqlite`]: https://docs.rs/bdk_sqlite/latest
|
[`bdk_sqlite`]: https://docs.rs/bdk_sqlite/latest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user