diff --git a/example-crates/wallet_electrum/src/main.rs b/example-crates/wallet_electrum/src/main.rs index 2adf090aa..b63e4604f 100644 --- a/example-crates/wallet_electrum/src/main.rs +++ b/example-crates/wallet_electrum/src/main.rs @@ -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() { diff --git a/example-crates/wallet_esplora_async/src/main.rs b/example-crates/wallet_esplora_async/src/main.rs index 0fd82b985..85400abcd 100644 --- a/example-crates/wallet_esplora_async/src/main.rs +++ b/example-crates/wallet_esplora_async/src/main.rs @@ -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() { diff --git a/example-crates/wallet_esplora_blocking/src/main.rs b/example-crates/wallet_esplora_blocking/src/main.rs index 32211b04b..dfa97ee5f 100644 --- a/example-crates/wallet_esplora_blocking/src/main.rs +++ b/example-crates/wallet_esplora_blocking/src/main.rs @@ -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() { diff --git a/example-crates/wallet_rpc/src/main.rs b/example-crates/wallet_rpc/src/main.rs index e09e6d762..e5a70b1dc 100644 --- a/example-crates/wallet_rpc/src/main.rs +++ b/example-crates/wallet_rpc/src/main.rs @@ -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()