refactor!: move WalletChangeSet to bdk_wallet and fix import paths

This commit is contained in:
志宇
2024-07-17 14:37:10 +00:00
parent 6b43001951
commit eb73f0659e
24 changed files with 142 additions and 166 deletions

View File

@@ -4,7 +4,6 @@ version = "0.2.0"
edition = "2021"
[dependencies]
bdk_wallet = { path = "../../crates/wallet", feature = ["file_store"] }
bdk_wallet = { path = "../../crates/wallet", features = ["file_store"] }
bdk_electrum = { path = "../../crates/electrum" }
bdk_file_store = { path = "../../crates/file_store" }
anyhow = "1"

View File

@@ -1,11 +1,11 @@
use bdk_wallet::wallet::CreateParams;
use bdk_wallet::wallet::LoadParams;
use bdk_wallet::file_store::Store;
use bdk_wallet::CreateParams;
use bdk_wallet::LoadParams;
use std::io::Write;
use std::str::FromStr;
use bdk_electrum::electrum_client;
use bdk_electrum::BdkElectrumClient;
use bdk_file_store::Store;
use bdk_wallet::bitcoin::Network;
use bdk_wallet::bitcoin::{Address, Amount};
use bdk_wallet::chain::collections::HashSet;
@@ -24,8 +24,7 @@ const ELECTRUM_URL: &str = "ssl://electrum.blockstream.info:60002";
fn main() -> Result<(), anyhow::Error> {
let db_path = "bdk-electrum-example.db";
let mut db =
Store::<bdk_wallet::wallet::ChangeSet>::open_or_create_new(DB_MAGIC.as_bytes(), db_path)?;
let mut db = Store::<bdk_wallet::ChangeSet>::open_or_create_new(DB_MAGIC.as_bytes(), db_path)?;
let load_params = LoadParams::with_descriptors(EXTERNAL_DESC, INTERNAL_DESC, NETWORK)?;
let create_params = CreateParams::new(EXTERNAL_DESC, INTERNAL_DESC, NETWORK)?;

View File

@@ -5,8 +5,7 @@ use bdk_esplora::{esplora_client, EsploraAsyncExt};
use bdk_wallet::{
bitcoin::{Amount, Network},
rusqlite::Connection,
wallet::{CreateParams, LoadParams},
KeychainKind, SignOptions,
CreateParams, KeychainKind, LoadParams, SignOptions,
};
const SEND_AMOUNT: Amount = Amount::from_sat(5000);

View File

@@ -7,7 +7,6 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bdk_wallet = { path = "../../crates/wallet" }
bdk_wallet = { path = "../../crates/wallet", features = ["file_store"] }
bdk_esplora = { path = "../../crates/esplora", features = ["blocking"] }
bdk_file_store = { path = "../../crates/file_store" }
anyhow = "1"

View File

@@ -1,11 +1,10 @@
use std::{collections::BTreeSet, io::Write};
use bdk_esplora::{esplora_client, EsploraExt};
use bdk_file_store::Store;
use bdk_wallet::{
bitcoin::{Amount, Network},
wallet::{CreateParams, LoadParams},
KeychainKind, SignOptions,
file_store::Store,
CreateParams, KeychainKind, LoadParams, SignOptions,
};
const DB_MAGIC: &str = "bdk_wallet_esplora_example";
@@ -20,8 +19,7 @@ const INTERNAL_DESC: &str = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7
const ESPLORA_URL: &str = "http://signet.bitcoindevkit.net";
fn main() -> Result<(), anyhow::Error> {
let mut db =
Store::<bdk_wallet::wallet::ChangeSet>::open_or_create_new(DB_MAGIC.as_bytes(), DB_PATH)?;
let mut db = Store::<bdk_wallet::ChangeSet>::open_or_create_new(DB_MAGIC.as_bytes(), DB_PATH)?;
let load_params = LoadParams::with_descriptors(EXTERNAL_DESC, INTERNAL_DESC, NETWORK)?;
let create_params = CreateParams::new(EXTERNAL_DESC, INTERNAL_DESC, NETWORK)?;

View File

@@ -7,7 +7,6 @@ edition = "2021"
[dependencies]
bdk_wallet = { path = "../../crates/wallet", features = ["file_store"] }
bdk_file_store = { path = "../../crates/file_store" }
bdk_bitcoind_rpc = { path = "../../crates/bitcoind_rpc" }
anyhow = "1"

View File

@@ -2,10 +2,10 @@ use bdk_bitcoind_rpc::{
bitcoincore_rpc::{Auth, Client, RpcApi},
Emitter,
};
use bdk_file_store::Store;
use bdk_wallet::{
bitcoin::{Block, Network, Transaction},
wallet::{CreateParams, LoadParams},
file_store::Store,
CreateParams, LoadParams,
};
use clap::{self, Parser};
use std::{path::PathBuf, sync::mpsc::sync_channel, thread::spawn, time::Instant};
@@ -86,10 +86,8 @@ fn main() -> anyhow::Result<()> {
);
let start_load_wallet = Instant::now();
let mut db = Store::<bdk_wallet::wallet::ChangeSet>::open_or_create_new(
DB_MAGIC.as_bytes(),
args.db_path,
)?;
let mut db =
Store::<bdk_wallet::ChangeSet>::open_or_create_new(DB_MAGIC.as_bytes(), args.db_path)?;
let load_params =
LoadParams::with_descriptors(&args.descriptor, &args.change_descriptor, args.network)?;