diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cff6b17..d1cd281c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Set coin type in BIP44, BIP49, and BIP84 templates - Get block hash given a block height - A `get_block_hash` method is now defined on the `GetBlockHash` trait and implemented on every blockchain backend. This method expects a block height and returns the corresponding block hash. - Add `remove_partial_sigs` and `try_finalize` to `SignOptions` +- Deprecate `AddressValidator` ## [v0.19.0] - [v0.18.0] diff --git a/examples/address_validator.rs b/examples/address_validator.rs index 85a23560..26c36dfe 100644 --- a/examples/address_validator.rs +++ b/examples/address_validator.rs @@ -14,6 +14,7 @@ use std::sync::Arc; use bdk::bitcoin; use bdk::database::MemoryDatabase; use bdk::descriptor::HdKeyPaths; +#[allow(deprecated)] use bdk::wallet::address_validator::{AddressValidator, AddressValidatorError}; use bdk::KeychainKind; use bdk::Wallet; @@ -25,6 +26,7 @@ use bitcoin::{Network, Script}; #[derive(Debug)] struct DummyValidator; +#[allow(deprecated)] impl AddressValidator for DummyValidator { fn validate( &self, @@ -50,6 +52,7 @@ fn main() -> Result<(), bdk::Error> { let descriptor = "sh(and_v(v:pk(tpubDDpWvmUrPZrhSPmUzCMBHffvC3HyMAPnWDSAQNBTnj1iZeJa7BZQEttFiP4DS4GCcXQHezdXhn86Hj6LHX5EDstXPWrMaSneRWM8yUf6NFd/*),after(630000)))"; let mut wallet = Wallet::new(descriptor, None, Network::Regtest, MemoryDatabase::new())?; + #[allow(deprecated)] wallet.add_address_validator(Arc::new(DummyValidator)); wallet.get_address(New)?; diff --git a/src/wallet/address_validator.rs b/src/wallet/address_validator.rs index a0e418ab..eaac582c 100644 --- a/src/wallet/address_validator.rs +++ b/src/wallet/address_validator.rs @@ -100,6 +100,7 @@ impl std::error::Error for AddressValidatorError {} /// validator will be propagated up to the original caller that triggered the address generation. /// /// For a usage example see [this module](crate::address_validator)'s documentation. +#[deprecated = "AddressValidator was rarely used. Address validation can occur outside of BDK"] pub trait AddressValidator: Send + Sync + fmt::Debug { /// Validate or inspect an address fn validate( @@ -120,6 +121,7 @@ mod test { #[derive(Debug)] struct TestValidator; + #[allow(deprecated)] impl AddressValidator for TestValidator { fn validate( &self, @@ -135,6 +137,7 @@ mod test { #[should_panic(expected = "InvalidScript")] fn test_address_validator_external() { let (mut wallet, _, _) = get_funded_wallet(get_test_wpkh()); + #[allow(deprecated)] wallet.add_address_validator(Arc::new(TestValidator)); wallet.get_address(New).unwrap(); @@ -144,6 +147,7 @@ mod test { #[should_panic(expected = "InvalidScript")] fn test_address_validator_internal() { let (mut wallet, descriptors, _) = get_funded_wallet(get_test_wpkh()); + #[allow(deprecated)] wallet.add_address_validator(Arc::new(TestValidator)); let addr = crate::testutils!(@external descriptors, 10); diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index cab3b020..dad10657 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -50,6 +50,7 @@ pub mod verify; pub use utils::IsDust; +#[allow(deprecated)] use address_validator::AddressValidator; use coin_selection::DefaultCoinSelectionAlgorithm; use signer::{SignOptions, SignerOrdering, SignersContainer, TransactionSigner}; @@ -94,6 +95,7 @@ pub struct Wallet { signers: Arc, change_signers: Arc, + #[allow(deprecated)] address_validators: Vec>, network: Network, @@ -500,11 +502,17 @@ where /// Add an address validator /// /// See [the `address_validator` module](address_validator) for an example. + #[deprecated] + #[allow(deprecated)] pub fn add_address_validator(&mut self, validator: Arc) { self.address_validators.push(validator); } /// Get the address validators + /// + /// See [the `address_validator` module](address_validator). + #[deprecated] + #[allow(deprecated)] pub fn get_address_validators(&self) -> &[Arc] { &self.address_validators } @@ -1267,6 +1275,7 @@ where let script = derived_descriptor.script_pubkey(); for validator in &self.address_validators { + #[allow(deprecated)] validator.validate(keychain, &hd_keypaths, &script)?; }