Skip to content

Commit

Permalink
docs: update example crates after new_or_load removal
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Jul 3, 2024
1 parent 0688a76 commit 24fa925
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
18 changes: 12 additions & 6 deletions example-crates/wallet_electrum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ fn main() -> Result<(), anyhow::Error> {
let changeset = db
.aggregate_changesets()
.map_err(|e| anyhow!("load changes error: {}", e))?;
let mut wallet = Wallet::new_or_load(
external_descriptor,
internal_descriptor,
changeset,
Network::Testnet,
)?;
let mut wallet;

if let Some(changeset) = changeset {
wallet = Wallet::load(
external_descriptor,
internal_descriptor,
changeset,
Network::Testnet,
)?;
} else {
wallet = Wallet::new(external_descriptor, internal_descriptor, Network::Testnet)?;
}

let address = wallet.next_unused_address(KeychainKind::External);
if let Some(changeset) = wallet.take_staged() {
Expand Down
10 changes: 2 additions & 8 deletions example-crates/wallet_esplora_async/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ async fn main() -> Result<(), anyhow::Error> {
let mut db = Store::new(conn)?;
let external_descriptor = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7h6Eziw3SpThFfczTDh5rW2krkqffa11UpX3XkeTTB2FvzZKWXqPY54Y6Rq4AQ5R8L/84'/1'/0'/0/*)";
let internal_descriptor = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7h6Eziw3SpThFfczTDh5rW2krkqffa11UpX3XkeTTB2FvzZKWXqPY54Y6Rq4AQ5R8L/84'/1'/0'/1/*)";
let changeset = db.read()?;

let mut wallet = Wallet::new_or_load(
external_descriptor,
internal_descriptor,
changeset,
Network::Signet,
)?;

let mut wallet = Wallet::new(external_descriptor, internal_descriptor, Network::Signet)?;

let address = wallet.next_unused_address(KeychainKind::External);
if let Some(changeset) = wallet.take_staged() {
Expand Down
17 changes: 11 additions & 6 deletions example-crates/wallet_esplora_blocking/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ fn main() -> Result<(), anyhow::Error> {
let internal_descriptor = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7h6Eziw3SpThFfczTDh5rW2krkqffa11UpX3XkeTTB2FvzZKWXqPY54Y6Rq4AQ5R8L/84'/1'/0'/1/*)";
let changeset = db.aggregate_changesets()?;

let mut wallet = Wallet::new_or_load(
external_descriptor,
internal_descriptor,
changeset,
Network::Testnet,
)?;
let mut wallet;
if let Some(changeset) = changeset {
wallet = Wallet::load(
external_descriptor,
internal_descriptor,
changeset,
Network::Testnet,
)?;
} else {
wallet = Wallet::new(external_descriptor, internal_descriptor, Network::Testnet)?;
}

let address = wallet.next_unused_address(KeychainKind::External);
if let Some(changeset) = wallet.take_staged() {
Expand Down
18 changes: 12 additions & 6 deletions example-crates/wallet_rpc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,19 @@ fn main() -> anyhow::Result<()> {
args.db_path,
)?;
let changeset = db.aggregate_changesets()?;
let mut wallet;

if let Some(changeset) = changeset {
wallet = Wallet::load(
&args.descriptor,
&args.change_descriptor,
changeset,
Network::Testnet,
)?;
} else {
wallet = Wallet::new(&args.descriptor, &args.change_descriptor, Network::Testnet)?;
}

let mut wallet = Wallet::new_or_load(
&args.descriptor,
&args.change_descriptor,
changeset,
args.network,
)?;
println!(
"Loaded wallet in {}s",
start_load_wallet.elapsed().as_secs_f32()
Expand Down

0 comments on commit 24fa925

Please sign in to comment.