diff --git a/Cargo.toml b/Cargo.toml index 3bc8be6..5923e76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ default = [] esplora = ["bdk_esplora"] debug = ["console_error_panic_hook"] snap = ["esplora"] -bitcoind = ["bdk_bitcoind_rpc"] [dependencies] wasm-bindgen = "0.2.95" @@ -49,7 +48,6 @@ bdk_esplora = { version = "0.19", default-features = false, features = [ ], optional = true } bitcoin = { version = "0.32.4", default-features = false } miniscript = "12.2.0" -bdk_bitcoind_rpc = { version = "0.16.0", optional = true } # Debug dependencies console_error_panic_hook = { version = "0.1.7", optional = true } diff --git a/src/bitcoin/mod.rs b/src/bitcoin/mod.rs index eaabb82..e18439d 100644 --- a/src/bitcoin/mod.rs +++ b/src/bitcoin/mod.rs @@ -10,14 +10,8 @@ mod esplora_wallet; #[cfg(feature = "snap")] mod snap_wallet; -#[cfg(feature = "bitcoind")] -mod rpc_wallet; - #[cfg(feature = "esplora")] pub use esplora_wallet::EsploraWallet; #[cfg(feature = "snap")] pub use snap_wallet::SnapWallet; - -#[cfg(feature = "bitcoind")] -pub use rpc_wallet::RpcWallet; diff --git a/src/bitcoin/rpc_wallet.rs b/src/bitcoin/rpc_wallet.rs deleted file mode 100644 index daee0d3..0000000 --- a/src/bitcoin/rpc_wallet.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::{cell::RefCell, rc::Rc}; - -use bdk_bitcoind_rpc::bitcoincore_rpc::{Auth, Client, RpcApi}; -use bdk_wallet::Wallet; -use serde_wasm_bindgen::to_value; -use wasm_bindgen::{prelude::wasm_bindgen, JsValue}; - -use crate::types::Network; - -#[wasm_bindgen] -pub struct RpcWallet { - wallet: Rc>, - client: Rc>, -} - -#[wasm_bindgen] -impl RpcWallet { - #[wasm_bindgen(constructor)] - pub fn new( - network: Network, - external_descriptor: String, - internal_descriptor: String, - url: String, - rpc_user: String, - rpc_pass: String, - ) -> Result { - let wallet: Wallet = Wallet::create(external_descriptor, internal_descriptor) - .network(network.into()) - .create_wallet_no_persist() - .map_err(|e| format!("{:?}", e))?; - - let auth = Auth::UserPass(rpc_user.clone(), rpc_pass.clone()); - let client = Client::new(&url, auth).map_err(|e| format!("{:?}", e))?; - - Ok(RpcWallet { - wallet: Rc::new(RefCell::new(wallet)), - client: Rc::new(RefCell::new(client)), - }) - } - - #[wasm_bindgen] - pub fn balance(&self) -> u64 { - let balance = self.wallet.borrow().balance(); - balance.total().to_sat() - } - - #[wasm_bindgen] - pub fn get_blockchain_info(&self) -> Result { - let block = self - .client - .borrow() - .get_blockchain_info() - .map_err(|e| format!("{:?}", e))?; - - let block_js = to_value(&block).map_err(|e| format!("{:?}", e))?; - - Ok(block_js) - } -} diff --git a/tests/rpc.rs b/tests/rpc.rs deleted file mode 100644 index e8cf800..0000000 --- a/tests/rpc.rs +++ /dev/null @@ -1,43 +0,0 @@ -//! Test suite for the Web and headless browsers. - -#![cfg(all(feature = "bitcoind", target_arch = "wasm32"))] - -extern crate wasm_bindgen_test; - -use bdk_wallet::bip39::Mnemonic; -use web_sys::console; - -use bdk_wasm::{ - bitcoin::RpcWallet, - seed_to_descriptor, set_panic_hook, - types::{AddressType, Network}, -}; -use wasm_bindgen_test::*; - -wasm_bindgen_test_configure!(run_in_browser); - -const NETWORK: Network = Network::Testnet; -const MNEMONIC: &str = "drip drum plug universe beyond gasp cram action hurt keep awake tortoise luggage return luxury net jar awake mimic hurry critic curtain quiz kit"; - -#[wasm_bindgen_test] -async fn test_rpc_wallet() { - set_panic_hook(); - - let seed = Mnemonic::parse(MNEMONIC).unwrap().to_seed(""); - let descriptors = seed_to_descriptor(&seed, NETWORK, AddressType::P2wpkh).expect("descriptor"); - let rpc_url = "http://127.0.0.1:18443"; - - let wallet = RpcWallet::new( - NETWORK, - descriptors.external(), - descriptors.internal(), - rpc_url.to_string(), - "polaruser".to_string(), - "polarpass".to_string(), - ) - .expect("rpc_wallet"); - - let info = wallet.get_blockchain_info().expect("get_blockchain_info"); - - console::log_1(&info); -}