Skip to content

Commit b117239

Browse files
committed
docs: Add example to README
1 parent fd2bbe3 commit b117239

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,48 @@
1-
# bdk-sqlite
1+
# `bdk_sqlite`
2+
3+
This crate features the [`Store`] type which provides async read and write methods of persisting BDK change sets by way of [`sqlx`].
4+
5+
## Example
6+
7+
```rust,no_run
8+
use bdk_sqlite::Store;
9+
use bdk_wallet::bitcoin;
10+
use bdk_wallet::{KeychainKind, Wallet};
11+
use bitcoin::Network;
12+
13+
#[tokio::main]
14+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
15+
// Create `Store`.
16+
let mut db = Store::new("test.db").await?;
17+
18+
let descriptor = "wpkh([e273fe42/84'/1'/0']tpubDCmr3Luq75npLaYmRqqW1rLfSbfpnBXwLwAmUbR333fp95wjCHar3zoc9zSWovZFwrWr53mm3NTVqt6d1Pt6G26uf4etQjc3Pr5Hxe9QEQ2/0/*)";
19+
let change_descriptor = "wpkh([e273fe42/84'/1'/0']tpubDCmr3Luq75npLaYmRqqW1rLfSbfpnBXwLwAmUbR333fp95wjCHar3zoc9zSWovZFwrWr53mm3NTVqt6d1Pt6G26uf4etQjc3Pr5Hxe9QEQ2/1/*)";
20+
21+
// Create `Wallet`.
22+
let mut wallet = Wallet::create(descriptor, change_descriptor)
23+
.network(Network::Signet)
24+
.create_wallet_async(&mut db)
25+
.await?;
26+
27+
println!(
28+
"Address: {}",
29+
wallet.reveal_next_address(KeychainKind::External),
30+
);
31+
32+
// Persist wallet state to SQLite database.
33+
wallet.persist_async(&mut db).await?;
34+
35+
Ok(())
36+
}
37+
```
38+
39+
## Features
40+
41+
* `wallet` - Provides access to the [`AsyncWalletPersister`] implementation for [`Store`] (enabled by default).
42+
43+
## MSRV
44+
45+
The Minimum Supported Rust Version (MSRV) is 1.85.0.
46+
47+
[`sqlx`]: https://docs.rs/sqlx/latest/sqlx/
48+
[`AsyncWalletPersister`]: https://docs.rs/bdk_wallet/latest/bdk_wallet/trait.AsyncWalletPersister.html

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//! `bdk_sqlite`
2-
1+
#![doc = include_str!("../README.md")]
32
#![warn(missing_docs)]
43

54
mod async_store;

0 commit comments

Comments
 (0)