diff --git a/Cargo.toml b/Cargo.toml index 1bb9b983c..185744802 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,9 +80,6 @@ electrum = ["electrum-client"] # MUST ALSO USE `--no-default-features`. use-esplora-async = ["esplora", "esplora-client/async", "futures"] use-esplora-blocking = ["esplora", "esplora-client/blocking"] -# Deprecated aliases -use-esplora-reqwest = ["use-esplora-async"] -use-esplora-ureq = ["use-esplora-blocking"] # Typical configurations will not need to use `esplora` feature directly. esplora = [] diff --git a/src/descriptor/checksum.rs b/src/descriptor/checksum.rs index 6be3a2444..e69e74b53 100644 --- a/src/descriptor/checksum.rs +++ b/src/descriptor/checksum.rs @@ -41,22 +41,19 @@ fn poly_mod(mut c: u64, val: u64) -> u64 { c } -/// Computes the checksum bytes of a descriptor. -/// `exclude_hash = true` ignores all data after the first '#' (inclusive). -pub(crate) fn calc_checksum_bytes_internal( - mut desc: &str, - exclude_hash: bool, -) -> Result<[u8; 8], DescriptorError> { +/// Compute the checksum bytes of a descriptor, excludes any existing checksum in the descriptor string from the calculation +pub fn calc_checksum_bytes(desc: &str) -> Result<[u8; 8], DescriptorError> { + let mut desc = desc; let mut c = 1; let mut cls = 0; let mut clscount = 0; let mut original_checksum = None; - if exclude_hash { - if let Some(split) = desc.split_once('#') { - desc = split.0; - original_checksum = Some(split.1); - } + + // always remove original checksum if one exists + if let Some(split) = desc.split_once('#') { + desc = split.0; + original_checksum = Some(split.1); } for ch in desc.as_bytes() { @@ -94,39 +91,10 @@ pub(crate) fn calc_checksum_bytes_internal( Ok(checksum) } -/// Compute the checksum bytes of a descriptor, excludes any existing checksum in the descriptor string from the calculation -pub fn calc_checksum_bytes(desc: &str) -> Result<[u8; 8], DescriptorError> { - calc_checksum_bytes_internal(desc, true) -} - /// Compute the checksum of a descriptor, excludes any existing checksum in the descriptor string from the calculation pub fn calc_checksum(desc: &str) -> Result { // unsafe is okay here as the checksum only uses bytes in `CHECKSUM_CHARSET` - calc_checksum_bytes_internal(desc, true) - .map(|b| unsafe { String::from_utf8_unchecked(b.to_vec()) }) -} - -// TODO in release 0.25.0, remove get_checksum_bytes and get_checksum -// TODO in release 0.25.0, consolidate calc_checksum_bytes_internal into calc_checksum_bytes - -/// Compute the checksum bytes of a descriptor -#[deprecated( - since = "0.24.0", - note = "Use new `calc_checksum_bytes` function which excludes any existing checksum in the descriptor string before calculating the checksum hash bytes. See https://github.com/bitcoindevkit/bdk/pull/765." -)] -pub fn get_checksum_bytes(desc: &str) -> Result<[u8; 8], DescriptorError> { - calc_checksum_bytes_internal(desc, false) -} - -/// Compute the checksum of a descriptor -#[deprecated( - since = "0.24.0", - note = "Use new `calc_checksum` function which excludes any existing checksum in the descriptor string before calculating the checksum hash. See https://github.com/bitcoindevkit/bdk/pull/765." -)] -pub fn get_checksum(desc: &str) -> Result { - // unsafe is okay here as the checksum only uses bytes in `CHECKSUM_CHARSET` - calc_checksum_bytes_internal(desc, false) - .map(|b| unsafe { String::from_utf8_unchecked(b.to_vec()) }) + calc_checksum_bytes(desc).map(|b| unsafe { String::from_utf8_unchecked(b.to_vec()) }) } #[cfg(test)] diff --git a/src/types.rs b/src/types.rs index 59c264ee5..d7fd1c220 100644 --- a/src/types.rs +++ b/src/types.rs @@ -256,12 +256,6 @@ pub struct BlockTime { pub timestamp: u64, } -/// **DEPRECATED**: Confirmation time of a transaction -/// -/// The structure has been renamed to `BlockTime` -#[deprecated(note = "This structure has been renamed to `BlockTime`")] -pub type ConfirmationTime = BlockTime; - impl BlockTime { /// Returns `Some` `BlockTime` if both `height` and `timestamp` are `Some` pub fn new(height: Option, timestamp: Option) -> Option { diff --git a/src/wallet/export.rs b/src/wallet/export.rs index 9c7532119..399dd5456 100644 --- a/src/wallet/export.rs +++ b/src/wallet/export.rs @@ -70,10 +70,6 @@ use crate::database::BatchDatabase; use crate::types::KeychainKind; use crate::wallet::Wallet; -/// Alias for [`FullyNodedExport`] -#[deprecated(since = "0.18.0", note = "Please use [`FullyNodedExport`] instead")] -pub type WalletExport = FullyNodedExport; - /// Structure that contains the export of a wallet /// /// For a usage example see [this module](crate::wallet::export)'s documentation. diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index c400c5a4d..775e086ec 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -59,7 +59,7 @@ use utils::{check_nsequence_rbf, After, Older, SecpCtx}; use crate::blockchain::{GetHeight, NoopProgress, Progress, WalletSync}; use crate::database::memory::MemoryDatabase; use crate::database::{AnyDatabase, BatchDatabase, BatchOperations, DatabaseUtils, SyncTime}; -use crate::descriptor::checksum::calc_checksum_bytes_internal; +use crate::descriptor::checksum::calc_checksum_bytes; use crate::descriptor::policy::BuildSatisfaction; use crate::descriptor::{ calc_checksum, into_wallet_descriptor_checked, DerivedDescriptor, DescriptorMeta, @@ -171,17 +171,6 @@ impl Wallet where D: BatchDatabase, { - #[deprecated = "Just use Wallet::new -- all wallets are offline now!"] - /// Create a new "offline" wallet - pub fn new_offline( - descriptor: E, - change_descriptor: Option, - network: Network, - database: D, - ) -> Result { - Self::new(descriptor, change_descriptor, network, database) - } - /// Create a wallet. /// /// The only way this can fail is if the descriptors passed in do not match the checksums in `database`. @@ -232,17 +221,10 @@ where }) } - /// This checks the checksum within [`BatchDatabase`] twice (if needed). The first time with the - /// actual checksum, and the second time with the checksum of `descriptor+checksum`. The second - /// check is necessary for backwards compatibility of a checksum-inception bug. + /// This checks the checksum within [`BatchDatabase`]. fn db_checksum(db: &mut D, desc: &str, kind: KeychainKind) -> Result<(), Error> { - let checksum = calc_checksum_bytes_internal(desc, true)?; - if db.check_descriptor_checksum(kind, checksum).is_ok() { - return Ok(()); - } - - let checksum_inception = calc_checksum_bytes_internal(desc, false)?; - db.check_descriptor_checksum(kind, checksum_inception) + let checksum = calc_checksum_bytes(desc)?; + db.check_descriptor_checksum(kind, checksum) } /// Get the Bitcoin network the wallet is using. @@ -1884,8 +1866,7 @@ pub(crate) mod test { let (wallet, _, _) = get_funded_wallet(get_test_wpkh()); let desc = wallet.descriptor.to_string(); - let checksum = calc_checksum_bytes_internal(&desc, true).unwrap(); - let checksum_inception = calc_checksum_bytes_internal(&desc, false).unwrap(); + let checksum = calc_checksum_bytes(&desc).unwrap(); let checksum_invalid = [b'q'; 8]; let mut db = MemoryDatabase::new(); @@ -1894,12 +1875,6 @@ pub(crate) mod test { Wallet::db_checksum(&mut db, &desc, KeychainKind::External) .expect("db that uses actual checksum should be supported"); - let mut db = MemoryDatabase::new(); - db.check_descriptor_checksum(KeychainKind::External, checksum_inception) - .expect("failed to save checksum inception"); - Wallet::db_checksum(&mut db, &desc, KeychainKind::External) - .expect("db that uses checksum inception should be supported"); - let mut db = MemoryDatabase::new(); db.check_descriptor_checksum(KeychainKind::External, checksum_invalid) .expect("failed to save invalid checksum");