What changed, and why it matters
This commit removes old, deprecated function names and type aliases from the rust-bitcoin `units` crate in preparation for a 1.0.0 release. It is a routine API cleanup: no security bug is fixed and no new unsafe code is added. Downstream projects that still use the removed names will get compile-time errors and must switch to the replacement APIs.
No security action required. Library consumers should update call sites to the replacement APIs before upgrading to `units` 1.0.0.
Security signals we found
No security-relevant signal: routine removal of deprecated public API surface
No memory-safety, cryptographic, consensus, or authorization changes
No bug fixes or behavioral changes to active code paths
Evidence from the diff
The diff deletes #[deprecated(...)] items across units: SignedAmount::checked_abs, FeeRate::fee_wu/fee_vb, the BlockInterval alias, several from_time/from_consensus/to_consensus_u32 helpers, CompactTarget::to_hex, Sequence::ENABLE_RBF_NO_LOCKTIME/to_hex, and Weight::from_vb_unwrap/from_witness_data_size/from_non_witness_data_size. All removed items have documented replacements. This is a breaking API change, not a vulnerability patch.
Changed components
units/src/amount/signed.rsunits/src/fee_rate/mod.rsunits/src/lib.rsunits/src/locktime/absolute/mod.rsunits/src/locktime/relative/mod.rsunits/src/pow.rsunits/src/sequence.rsunits/src/weight.rsInspect captured patch +2 / −142
diff --git a/units/CHANGELOG.md b/units/CHANGELOG.md
index 514f76bc..bd1a9069 100644
--- a/units/CHANGELOG.md
+++ b/units/CHANGELOG.md
@@ -2,6 +2,8 @@
## [Unreleased]
+* Remove all deprecated code.
+
## [0.4.0] - 2026-05-27
* Add format traits for `Target` and `Work` [#5626](https://github.com/rust-bitcoin/rust-bitcoin/pull/5626)
diff --git a/units/src/amount/signed.rs b/units/src/amount/signed.rs
index 772f2333..edf87498 100644
--- a/units/src/amount/signed.rs
+++ b/units/src/amount/signed.rs
@@ -423,16 +423,6 @@ impl SignedAmount {
#[inline]
pub fn is_negative(self) -> bool { self.to_sat().is_negative() }
- /// Returns the absolute value of this [`SignedAmount`].
- ///
- /// Consider using `unsigned_abs` which is often more practical.
- ///
- /// Returns [`None`] if overflow occurred. (`self == i64::MIN`)
- #[must_use]
- #[deprecated(since = "1.0.0-rc.0", note = "Never returns none, use `abs()` instead")]
- #[allow(clippy::unnecessary_wraps)] // To match stdlib function definition.
- pub const fn checked_abs(self) -> Option<Self> { Some(self.abs()) }
-
/// Checked addition.
///
/// Returns [`None`] if the sum is above [`SignedAmount::MAX`] or below [`SignedAmount::MIN`].
diff --git a/units/src/fee_rate/mod.rs b/units/src/fee_rate/mod.rs
index 942bf7a9..5ea3cc74 100644
--- a/units/src/fee_rate/mod.rs
+++ b/units/src/fee_rate/mod.rs
@@ -208,23 +208,6 @@ impl FeeRate {
}
}
- /// Calculates the fee by multiplying this fee rate by weight, in weight units, returning [`None`]
- /// if an overflow occurred.
- ///
- /// This is equivalent to `Self::mul_by_weight(weight).ok()`.
- #[must_use]
- #[deprecated(since = "1.0.0-rc.0", note = "use `to_fee()` instead")]
- pub fn fee_wu(self, weight: Weight) -> Option<Amount> { self.mul_by_weight(weight).ok() }
-
- /// Calculates the fee by multiplying this fee rate by weight, in virtual bytes, returning [`None`]
- /// if `vb` cannot be represented as [`Weight`].
- ///
- /// This is equivalent to converting `vb` to [`Weight`] using [`Weight::from_vb`] and then calling
- /// [`Self::to_fee`].
- #[must_use]
- #[deprecated(since = "1.0.0-rc.0", note = "use Weight::from_vb and then `to_fee()` instead")]
- pub fn fee_vb(self, vb: u64) -> Option<Amount> { Weight::from_vb(vb).map(|w| self.to_fee(w)) }
-
/// Checked weight multiplication.
///
/// Computes the absolute fee amount for a given [`Weight`] at this fee rate. When the resulting
diff --git a/units/src/lib.rs b/units/src/lib.rs
index 3ce26681..9051a7f8 100644
--- a/units/src/lib.rs
+++ b/units/src/lib.rs
@@ -74,10 +74,6 @@ pub use self::{
weight::Weight
};
-#[deprecated(since = "1.0.0-rc.0", note = "use `BlockHeightInterval` instead")]
-#[doc(hidden)]
-pub type BlockInterval = BlockHeightInterval;
-
// decoder_newtype! macro
#[cfg(feature = "encoding")]
include!("../include/decoder_newtype.rs");
diff --git a/units/src/locktime/absolute/mod.rs b/units/src/locktime/absolute/mod.rs
index 4f9da2bd..8ef4846f 100644
--- a/units/src/locktime/absolute/mod.rs
+++ b/units/src/locktime/absolute/mod.rs
@@ -207,11 +207,6 @@ impl LockTime {
Ok(Self::Blocks(height))
}
- #[inline]
- #[deprecated(since = "1.0.0-rc.0", note = "use `from_mtp` instead")]
- #[doc(hidden)]
- pub fn from_time(n: u32) -> Result<Self, ConversionError> { Self::from_mtp(n) }
-
/// Constructs a new `LockTime` from `n`, expecting `n` to be a median-time-past (MTP)
/// which is in range for a locktime.
///
@@ -532,14 +527,6 @@ impl Height {
Ok(Self::from_u32(height).map_err(|_| ParseError::Conversion(height.into()))?)
}
- #[deprecated(since = "1.0.0-rc.0", note = "use `from_u32` instead")]
- #[doc(hidden)]
- pub const fn from_consensus(n: u32) -> Result<Self, ConversionError> { Self::from_u32(n) }
-
- #[deprecated(since = "1.0.0-rc.0", note = "use `to_u32` instead")]
- #[doc(hidden)]
- pub const fn to_consensus_u32(self) -> u32 { self.to_u32() }
-
/// Constructs a new block height directly from a `u32` value.
///
/// # Errors
@@ -599,10 +586,6 @@ impl fmt::Display for Height {
parse_int::impl_parse_str!(Height, ParseHeightError, parser(Height::from_u32));
-#[deprecated(since = "1.0.0-rc.0", note = "use `MedianTimePast` instead")]
-#[doc(hidden)]
-pub type Time = MedianTimePast;
-
/// The median timestamp of 11 consecutive blocks, representing "the timestamp" of the
/// final block for locktime-checking purposes.
///
@@ -663,14 +646,6 @@ impl MedianTimePast {
Ok(Self::from_u32(height).map_err(|_| ParseError::Conversion(height.into()))?)
}
- #[deprecated(since = "1.0.0-rc.0", note = "use `from_u32` instead")]
- #[doc(hidden)]
- pub const fn from_consensus(n: u32) -> Result<Self, ConversionError> { Self::from_u32(n) }
-
- #[deprecated(since = "1.0.0-rc.0", note = "use `to_u32` instead")]
- #[doc(hidden)]
- pub const fn to_consensus_u32(self) -> u32 { self.to_u32() }
-
/// Constructs a new MTP directly from a `u32` value.
///
/// This function, with [`MedianTimePast::to_u32`], is used to obtain a raw MTP value. It is
diff --git a/units/src/locktime/relative/mod.rs b/units/src/locktime/relative/mod.rs
index 837fd4e2..a704d8e9 100644
--- a/units/src/locktime/relative/mod.rs
+++ b/units/src/locktime/relative/mod.rs
@@ -389,10 +389,6 @@ impl<'de> serde::Deserialize<'de> for LockTime {
}
}
-#[deprecated(since = "1.0.0-rc.0", note = "use `NumberOfBlocks` instead")]
-#[doc(hidden)]
-pub type Height = NumberOfBlocks;
-
/// A relative lock time lock-by-height value.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct NumberOfBlocks(u16);
@@ -416,23 +412,6 @@ impl NumberOfBlocks {
#[must_use]
pub const fn to_height(self) -> u16 { self.0 }
- /// Returns the inner `u16` value.
- #[inline]
- #[must_use]
- #[deprecated(since = "1.0.0-rc.0", note = "use `to_height` instead")]
- #[doc(hidden)]
- pub const fn value(self) -> u16 { self.0 }
-
- /// Returns the `u32` value used to encode this locktime in an nSequence field or
- /// argument to `OP_CHECKSEQUENCEVERIFY`.
- #[deprecated(
- since = "1.0.0-rc.0",
- note = "use `LockTime::from` followed by `to_consensus_u32` instead"
- )]
- pub const fn to_consensus_u32(self) -> u32 {
- self.0 as u32 // cast safety: u32 is wider than u16 on all architectures
- }
-
/// Constructs a new `NumberOfBlocks` from a prefixed hex string.
///
/// # Errors
@@ -495,10 +474,6 @@ impl fmt::Display for NumberOfBlocks {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) }
}
-#[deprecated(since = "1.0.0-rc.0", note = "use `NumberOf512Seconds` instead")]
-#[doc(hidden)]
-pub type Time = NumberOf512Seconds;
-
/// A relative lock time lock-by-time value.
///
/// For BIP-0068 relative lock-by-time locks, time is measured in 512 second intervals.
@@ -565,23 +540,6 @@ impl NumberOf512Seconds {
#[inline]
pub const fn to_seconds(self) -> u32 { const_casts::u16_to_u32(self.0) * 512 }
- /// Returns the inner `u16` value.
- #[inline]
- #[must_use]
- #[deprecated(since = "1.0.0-rc.0", note = "use `to_512_second_intervals` instead")]
- #[doc(hidden)]
- pub const fn value(self) -> u16 { self.0 }
-
- /// Returns the `u32` value used to encode this locktime in an nSequence field or
- /// argument to `OP_CHECKSEQUENCEVERIFY`.
- #[deprecated(
- since = "1.0.0-rc.0",
- note = "use `LockTime::from` followed by `to_consensus_u32` instead"
- )]
- pub const fn to_consensus_u32(self) -> u32 {
- (1u32 << 22) | self.0 as u32 // cast safety: u32 is wider than u16 on all architectures
- }
-
/// Constructs a new `NumberOf512Seconds` from a prefixed hex string.
///
/// # Errors
@@ -947,7 +905,6 @@ mod tests {
}
#[test]
- #[allow(deprecated_in_future)]
fn sanity_check() {
assert_eq!(LockTime::from(NumberOfBlocks::MAX).to_consensus_u32(), u32::from(u16::MAX));
assert_eq!(
diff --git a/units/src/pow.rs b/units/src/pow.rs
index 1635cfa7..1955ddb7 100644
--- a/units/src/pow.rs
+++ b/units/src/pow.rs
@@ -252,12 +252,6 @@ impl CompactTarget {
#[inline]
pub const fn to_consensus(self) -> u32 { self.0 }
- /// Gets the hex representation of this [`CompactTarget`].
- #[cfg(feature = "alloc")]
- #[inline]
- #[deprecated(since = "1.0.0-rc.0", note = "use `format!(\"{var:x}\")` instead")]
- pub fn to_hex(self) -> alloc::string::String { alloc::format!("{:x}", self) }
-
/// Constructs a new `CompactTarget` from a prefixed hex string.
///
/// # Errors
diff --git a/units/src/sequence.rs b/units/src/sequence.rs
index 326764f5..49b7ce07 100644
--- a/units/src/sequence.rs
+++ b/units/src/sequence.rs
@@ -49,10 +49,6 @@ impl Sequence {
/// The sequence number that enables absolute lock time but disables replace-by-fee
/// and relative lock time.
pub const ENABLE_LOCKTIME_NO_RBF: Self = Self::MIN_NO_RBF;
- /// The sequence number that enables replace-by-fee and absolute lock time but
- /// disables relative lock time.
- #[deprecated(since = "1.0.0-rc.0", note = "use `ENABLE_LOCKTIME_AND_RBF` instead")]
- pub const ENABLE_RBF_NO_LOCKTIME: Self = Self(0xFFFF_FFFD);
/// The maximum sequence number that enables replace-by-fee and absolute lock time but
/// disables relative lock time.
///
@@ -199,12 +195,6 @@ impl Sequence {
#[inline]
pub const fn to_consensus_u32(self) -> u32 { self.0 }
- /// Gets the hex representation of this [`Sequence`].
- #[cfg(feature = "alloc")]
- #[inline]
- #[deprecated(since = "1.0.0-rc.0", note = "use `format!(\"{var:x}\")` instead")]
- pub fn to_hex(self) -> alloc::string::String { alloc::format!("{:x}", self) }
-
/// Constructs a new [`relative::LockTime`] from this [`Sequence`] number.
#[inline]
pub fn to_relative_lock_time(self) -> Option<relative::LockTime> {
diff --git a/units/src/weight.rs b/units/src/weight.rs
index f5a54067..9e0f8be8 100644
--- a/units/src/weight.rs
+++ b/units/src/weight.rs
@@ -82,39 +82,12 @@ impl Weight {
}
}
- /// Constructs a new [`Weight`] from virtual bytes panicking if an overflow occurred.
- ///
- /// # Panics
- ///
- /// If the conversion from virtual bytes overflows.
- #[deprecated(since = "1.0.0-rc.0", note = "use `from_vb_unchecked` instead")]
- pub const fn from_vb_unwrap(vb: u64) -> Self {
- match vb.checked_mul(Self::WITNESS_SCALE_FACTOR) {
- Some(weight) => Self::from_wu(weight),
- None => panic!("checked_mul overflowed"),
- }
- }
-
/// Constructs a new [`Weight`] from virtual bytes without an overflow check.
#[inline]
pub const fn from_vb_unchecked(vb: u64) -> Self {
Self::from_wu(vb * Self::WITNESS_SCALE_FACTOR)
}
- /// Constructs a new [`Weight`] from witness size.
- #[deprecated(since = "1.0.0-rc.1", note = "use `from_wu` instead")]
- pub const fn from_witness_data_size(witness_size: u64) -> Self { Self::from_wu(witness_size) }
-
- /// Constructs a new [`Weight`] from non-witness size.
- ///
- /// # Panics
- ///
- /// If the conversion from virtual bytes overflows.
- #[deprecated(since = "1.0.0-rc.1", note = "use `from_vb` or `from_vb_unchecked` instead")]
- pub const fn from_non_witness_data_size(non_witness_size: u64) -> Self {
- Self::from_wu(non_witness_size * Self::WITNESS_SCALE_FACTOR)
- }
-
/// Constructs a new `Weight` from a prefixed hex string.
///
/// # Errors
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.