Repository: rust-bitcoin/rust-bitcoin
Pull request #3838 (2024-12-31 02:09:43)

primitives: Add core re-exports
This is not strictly needed but we would like to copy the public macros from `units` to primitives and they use `$crate::_export` paths.


Patch:
diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock
index 67b68fc9..4ca2d3d5 100644
--- a/Cargo-minimal.lock
+++ b/Cargo-minimal.lock
@@ -303,9 +303,9 @@ dependencies = [
 
 [[package]]
 name = "ordered"
-version = "0.3.0"
+version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3cd8ca7e3c0ec0f0ae705488e2df4ea2eae87e97de8c8abd2bda12b23324cac9"
+checksum = "7f0642533dea0bb58bd5cae31bafc1872429f0f12ac8c61fe2b4ba44f80b959b"
 
 [[package]]
 name = "ppv-lite86"
diff --git a/Cargo-recent.lock b/Cargo-recent.lock
index 3a1d1b39..c4fd9762 100644
--- a/Cargo-recent.lock
+++ b/Cargo-recent.lock
@@ -311,9 +311,9 @@ dependencies = [
 
 [[package]]
 name = "ordered"
-version = "0.3.0"
+version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3cd8ca7e3c0ec0f0ae705488e2df4ea2eae87e97de8c8abd2bda12b23324cac9"
+checksum = "7f0642533dea0bb58bd5cae31bafc1872429f0f12ac8c61fe2b4ba44f80b959b"
 
 [[package]]
 name = "ppv-lite86"
diff --git a/api/hashes/alloc-only.txt b/api/hashes/alloc-only.txt
index 93d5bf78..50246e2d 100644
--- a/api/hashes/alloc-only.txt
+++ b/api/hashes/alloc-only.txt
@@ -859,6 +859,7 @@ pub fn bitcoin_hashes::siphash24::State::fmt(&self, f: &mut core::fmt::Formatter
 pub macro bitcoin_hashes::hash_newtype!
 pub macro bitcoin_hashes::impl_debug_only_for_newtype!
 pub macro bitcoin_hashes::impl_hex_for_newtype!
+pub macro bitcoin_hashes::serde_impl!
 pub macro bitcoin_hashes::sha256t_hash_newtype!
 pub macro bitcoin_hashes::sha256t_tag!
 pub mod bitcoin_hashes
diff --git a/api/hashes/no-features.txt b/api/hashes/no-features.txt
index e1ce2255..5283250b 100644
--- a/api/hashes/no-features.txt
+++ b/api/hashes/no-features.txt
@@ -806,6 +806,7 @@ pub fn bitcoin_hashes::siphash24::State::clone(&self) -> bitcoin_hashes::siphash
 pub fn bitcoin_hashes::siphash24::State::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
 pub macro bitcoin_hashes::hash_newtype!
 pub macro bitcoin_hashes::impl_debug_only_for_newtype!
+pub macro bitcoin_hashes::serde_impl!
 pub macro bitcoin_hashes::sha256t_hash_newtype!
 pub macro bitcoin_hashes::sha256t_tag!
 pub mod bitcoin_hashes
diff --git a/api/io/all-features.txt b/api/io/all-features.txt
index af10dd88..aef13ac5 100644
--- a/api/io/all-features.txt
+++ b/api/io/all-features.txt
@@ -214,8 +214,6 @@ pub fn bitcoin_io::BufRead::consume(&mut self, amount: usize)
 pub fn bitcoin_io::BufRead::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
 pub fn bitcoin_io::Cursor<T>::consume(&mut self, amount: usize)
 pub fn bitcoin_io::Cursor<T>::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
-pub fn bitcoin_io::Cursor<T>::get_mut(&mut self) -> &mut T
-pub fn bitcoin_io::Cursor<T>::get_ref(&self) -> &T
 pub fn bitcoin_io::Cursor<T>::inner(&self) -> &T
 pub fn bitcoin_io::Cursor<T>::into_inner(self) -> T
 pub fn bitcoin_io::Cursor<T>::new(inner: T) -> Self
diff --git a/api/io/alloc-only.txt b/api/io/alloc-only.txt
index 572cb17e..b0aaeff4 100644
--- a/api/io/alloc-only.txt
+++ b/api/io/alloc-only.txt
@@ -91,8 +91,6 @@ pub fn bitcoin_io::BufRead::consume(&mut self, amount: usize)
 pub fn bitcoin_io::BufRead::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
 pub fn bitcoin_io::Cursor<T>::consume(&mut self, amount: usize)
 pub fn bitcoin_io::Cursor<T>::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
-pub fn bitcoin_io::Cursor<T>::get_mut(&mut self) -> &mut T
-pub fn bitcoin_io::Cursor<T>::get_ref(&self) -> &T
 pub fn bitcoin_io::Cursor<T>::inner(&self) -> &T
 pub fn bitcoin_io::Cursor<T>::into_inner(self) -> T
 pub fn bitcoin_io::Cursor<T>::new(inner: T) -> Self
diff --git a/api/io/no-features.txt b/api/io/no-features.txt
index 93613d4e..facd4c3e 100644
--- a/api/io/no-features.txt
+++ b/api/io/no-features.txt
@@ -87,8 +87,6 @@ pub fn bitcoin_io::BufRead::consume(&mut self, amount: usize)
 pub fn bitcoin_io::BufRead::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
 pub fn bitcoin_io::Cursor<T>::consume(&mut self, amount: usize)
 pub fn bitcoin_io::Cursor<T>::fill_buf(&mut self) -> bitcoin_io::Result<&[u8]>
-pub fn bitcoin_io::Cursor<T>::get_mut(&mut self) -> &mut T
-pub fn bitcoin_io::Cursor<T>::get_ref(&self) -> &T
 pub fn bitcoin_io::Cursor<T>::inner(&self) -> &T
 pub fn bitcoin_io::Cursor<T>::into_inner(self) -> T
 pub fn bitcoin_io::Cursor<T>::new(inner: T) -> Self
diff --git a/api/units/all-features.txt b/api/units/all-features.txt
index f084694c..6217193e 100644
--- a/api/units/all-features.txt
+++ b/api/units/all-features.txt
@@ -145,7 +145,6 @@ impl core::cmp::PartialOrd for bitcoin_units::locktime::relative::Height
 impl core::cmp::PartialOrd for bitcoin_units::locktime::relative::Time
 impl core::cmp::PartialOrd for bitcoin_units::weight::Weight
 impl core::convert::AsRef<core::num::error::ParseIntError> for bitcoin_units::parse::ParseIntError
-impl core::convert::From<bitcoin_units::Amount> for bitcoin_units::SignedAmount
 impl core::convert::From<bitcoin_units::amount::InputTooLargeError> for bitcoin_units::amount::ParseAmountError
 impl core::convert::From<bitcoin_units::amount::InputTooLargeError> for bitcoin_units::amount::ParseError
 impl core::convert::From<bitcoin_units::amount::InvalidCharacterError> for bitcoin_units::amount::ParseAmountError
@@ -199,6 +198,7 @@ impl core::convert::TryFrom<alloc::string::String> for bitcoin_units::locktime::
 impl core::convert::TryFrom<alloc::string::String> for bitcoin_units::locktime::relative::Height
 impl core::convert::TryFrom<alloc::string::String> for bitcoin_units::locktime::relative::Time
 impl core::convert::TryFrom<alloc::string::String> for bitcoin_units::weight::Weight
+impl core::convert::TryFrom<bitcoin_units::Amount> for bitcoin_units::SignedAmount
 impl core::convert::TryFrom<bitcoin_units::SignedAmount> for bitcoin_units::Amount
 impl core::convert::TryFrom<bitcoin_units::block::BlockHeight> for bitcoin_units::locktime::absolute::Height
 impl core::convert::TryFrom<bitcoin_units::block::BlockInterval> for bitcoin_units::locktime::relative::Height
@@ -714,7 +714,6 @@ pub const fn bitcoin_units::Amount::checked_rem(self, rhs: u64) -> core::option:
 pub const fn bitcoin_units::Amount::checked_sub(self, rhs: bitcoin_units::Amount) -> core::option::Option<bitcoin_units::Amount>
 pub const fn bitcoin_units::Amount::from_int_btc_const(whole_bitcoin: u32) -> bitcoin_units::Amount
 pub const fn bitcoin_units::Amount::from_sat(satoshi: u64) -> bitcoin_units::Amount
-pub const fn bitcoin_units::Amount::from_sat_unchecked(satoshi: u64) -> bitcoin_units::Amount
 pub const fn bitcoin_units::Amount::to_sat(self) -> u64
 pub const fn bitcoin_units::SignedAmount::checked_abs(self) -> core::option::Option<bitcoin_units::SignedAmount>
 pub const fn bitcoin_units::SignedAmount::checked_add(self, rhs: bitcoin_units::SignedAmount) -> core::option::Option<bitcoin_units::SignedAmount>
@@ -724,7 +723,6 @@ pub const fn bitcoin_units::SignedAmount::checked_rem(self, rhs: i64) -> core::o
 pub const fn bitcoin_units::SignedAmount::checked_sub(self, rhs: bitcoin_units::SignedAmount) -> core::option::Option<bitcoin_units::SignedAmount>
 pub const fn bitcoin_units::SignedAmount::from_int_btc_const(whole_bitcoin: i64) -> bitcoin_units::SignedAmount
 pub const fn bitcoin_units::SignedAmount::from_sat(satoshi: i64) -> bitcoin_units::SignedAmount
-pub const fn bitcoin_units::SignedAmount::from_sat_unchecked(satoshi: i64) -> bitcoin_units::SignedAmount
 pub const fn bitcoin_units::SignedAmount::to_sat(self) -> i64
 pub const fn bitcoin_units::block::BlockHeight::from_u32(inner: u32) -> Self
 pub const fn bitcoin_units::block::BlockHeight::to_u32(self) -> u32
@@ -832,7 +830,7 @@ pub fn bitcoin_units::Amount::sum<I: core::iter::traits::iterator::Iterator<Item
 pub fn bitcoin_units::Amount::sum<I>(iter: I) -> Self where I: core::iter::traits::iterator::Iterator<Item = &'a bitcoin_units::Amount>
 pub fn bitcoin_units::Amount::to_btc(self) -> f64
 pub fn bitcoin_units::Amount::to_float_in(self, denom: bitcoin_units::amount::Denomination) -> f64
-pub fn bitcoin_units::Amount::to_signed(self) -> bitcoin_units::SignedAmount
+pub fn bitcoin_units::Amount::to_signed(self) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::OutOfRangeError>
 pub fn bitcoin_units::Amount::to_string_in(self, denom: bitcoin_units::amount::Denomination) -> alloc::string::String
 pub fn bitcoin_units::Amount::to_string_with_denomination(self, denom: bitcoin_units::amount::Denomination) -> alloc::string::String
 pub fn bitcoin_units::Amount::try_from(value: bitcoin_units::SignedAmount) -> core::result::Result<Self, Self::Error>
@@ -857,7 +855,6 @@ pub fn bitcoin_units::SignedAmount::div(self, rhs: i64) -> Self::Output
 pub fn bitcoin_units::SignedAmount::div_assign(&mut self, rhs: i64)
 pub fn bitcoin_units::SignedAmount::eq(&self, other: &bitcoin_units::SignedAmount) -> bool
 pub fn bitcoin_units::SignedAmount::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
-pub fn bitcoin_units::SignedAmount::from(value: bitcoin_units::Amount) -> Self
 pub fn bitcoin_units::SignedAmount::from_btc(btc: f64) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::ParseAmountError>
 pub fn bitcoin_units::SignedAmount::from_float_in(value: f64, denom: bitcoin_units::amount::Denomination) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::ParseAmountError>
 pub fn bitcoin_units::SignedAmount::from_int_btc<T: core::convert::Into<i64>>(whole_bitcoin: T) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::OutOfRangeError>
@@ -892,6 +889,7 @@ pub fn bitcoin_units::SignedAmount::to_float_in(self, denom: bitcoin_units::amou
 pub fn bitcoin_units::SignedAmount::to_string_in(self, denom: bitcoin_units::amount::Denomination) -> alloc::string::String
 pub fn bitcoin_units::SignedAmount::to_string_with_denomination(self, denom: bitcoin_units::amount::Denomination) -> alloc::string::String
 pub fn bitcoin_units::SignedAmount::to_unsigned(self) -> core::result::Result<bitcoin_units::Amount, bitcoin_units::amount::OutOfRangeError>
+pub fn bitcoin_units::SignedAmount::try_from(value: bitcoin_units::Amount) -> core::result::Result<Self, Self::Error>
 pub fn bitcoin_units::SignedAmount::type_prefix(_: private::Token) -> &'static str
 pub fn bitcoin_units::SignedAmount::unchecked_add(self, rhs: bitcoin_units::SignedAmount) -> bitcoin_units::SignedAmount
 pub fn bitcoin_units::SignedAmount::unchecked_sub(self, rhs: bitcoin_units::SignedAmount) -> bitcoin_units::SignedAmount
@@ -1256,6 +1254,7 @@ pub type bitcoin_units::Amount::Error = bitcoin_units::amount::OutOfRangeError
 pub type bitcoin_units::Amount::Output = bitcoin_units::Amount
 pub type bitcoin_units::Amount::Output = bitcoin_units::fee_rate::FeeRate
 pub type bitcoin_units::SignedAmount::Err = bitcoin_units::amount::ParseError
+pub type bitcoin_units::SignedAmount::Error = bitcoin_units::amount::OutOfRangeError
 pub type bitcoin_units::SignedAmount::Output = bitcoin_units::SignedAmount
 pub type bitcoin_units::amount::Denomination::Err = bitcoin_units::amount::ParseDenominationError
 pub type bitcoin_units::block::BlockHeight::Err = bitcoin_units::parse::ParseIntError
diff --git a/api/units/alloc-only.txt b/api/units/alloc-only.txt
index d64e17e2..13e5cb27 100644
--- a/api/units/alloc-only.txt
+++ b/api/units/alloc-only.txt
@@ -141,7 +141,6 @@ impl core::cmp::PartialOrd for bitcoin_units::locktime::relative::Height
 impl core::cmp::PartialOrd for bitcoin_units::locktime::relative::Time
 impl core::cmp::PartialOrd for bitcoin_units::weight::Weight
 impl core::convert::AsRef<core::num::error::ParseIntError> for bitcoin_units::parse::ParseIntError
-impl core::convert::From<bitcoin_units::Amount> for bitcoin_units::SignedAmount
 impl core::convert::From<bitcoin_units::amount::InputTooLargeError> for bitcoin_units::amount::ParseAmountError
 impl core::convert::From<bitcoin_units::amount::InputTooLargeError> for bitcoin_units::amount::ParseError
 impl core::convert::From<bitcoin_units::amount::InvalidCharacterError> for bitcoin_units::amount::ParseAmountError
@@ -195,6 +194,7 @@ impl core::convert::TryFrom<alloc::string::String> for bitcoin_units::locktime::
 impl core::convert::TryFrom<alloc::string::String> for bitcoin_units::locktime::relative::Height
 impl core::convert::TryFrom<alloc::string::String> for bitcoin_units::locktime::relative::Time
 impl core::convert::TryFrom<alloc::string::String> for bitcoin_units::weight::Weight
+impl core::convert::TryFrom<bitcoin_units::Amount> for bitcoin_units::SignedAmount
 impl core::convert::TryFrom<bitcoin_units::SignedAmount> for bitcoin_units::Amount
 impl core::convert::TryFrom<bitcoin_units::block::BlockHeight> for bitcoin_units::locktime::absolute::Height
 impl core::convert::TryFrom<bitcoin_units::block::BlockInterval> for bitcoin_units::locktime::relative::Height
@@ -665,7 +665,6 @@ pub const fn bitcoin_units::Amount::checked_rem(self, rhs: u64) -> core::option:
 pub const fn bitcoin_units::Amount::checked_sub(self, rhs: bitcoin_units::Amount) -> core::option::Option<bitcoin_units::Amount>
 pub const fn bitcoin_units::Amount::from_int_btc_const(whole_bitcoin: u32) -> bitcoin_units::Amount
 pub const fn bitcoin_units::Amount::from_sat(satoshi: u64) -> bitcoin_units::Amount
-pub const fn bitcoin_units::Amount::from_sat_unchecked(satoshi: u64) -> bitcoin_units::Amount
 pub const fn bitcoin_units::Amount::to_sat(self) -> u64
 pub const fn bitcoin_units::SignedAmount::checked_abs(self) -> core::option::Option<bitcoin_units::SignedAmount>
 pub const fn bitcoin_units::SignedAmount::checked_add(self, rhs: bitcoin_units::SignedAmount) -> core::option::Option<bitcoin_units::SignedAmount>
@@ -675,7 +674,6 @@ pub const fn bitcoin_units::SignedAmount::checked_rem(self, rhs: i64) -> core::o
 pub const fn bitcoin_units::SignedAmount::checked_sub(self, rhs: bitcoin_units::SignedAmount) -> core::option::Option<bitcoin_units::SignedAmount>
 pub const fn bitcoin_units::SignedAmount::from_int_btc_const(whole_bitcoin: i64) -> bitcoin_units::SignedAmount
 pub const fn bitcoin_units::SignedAmount::from_sat(satoshi: i64) -> bitcoin_units::SignedAmount
-pub const fn bitcoin_units::SignedAmount::from_sat_unchecked(satoshi: i64) -> bitcoin_units::SignedAmount
 pub const fn bitcoin_units::SignedAmount::to_sat(self) -> i64
 pub const fn bitcoin_units::block::BlockHeight::from_u32(inner: u32) -> Self
 pub const fn bitcoin_units::block::BlockHeight::to_u32(self) -> u32
@@ -773,7 +771,7 @@ pub fn bitcoin_units::Amount::sum<I: core::iter::traits::iterator::Iterator<Item
 pub fn bitcoin_units::Amount::sum<I>(iter: I) -> Self where I: core::iter::traits::iterator::Iterator<Item = &'a bitcoin_units::Amount>
 pub fn bitcoin_units::Amount::to_btc(self) -> f64
 pub fn bitcoin_units::Amount::to_float_in(self, denom: bitcoin_units::amount::Denomination) -> f64
-pub fn bitcoin_units::Amount::to_signed(self) -> bitcoin_units::SignedAmount
+pub fn bitcoin_units::Amount::to_signed(self) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::OutOfRangeError>
 pub fn bitcoin_units::Amount::to_string_in(self, denom: bitcoin_units::amount::Denomination) -> alloc::string::String
 pub fn bitcoin_units::Amount::to_string_with_denomination(self, denom: bitcoin_units::amount::Denomination) -> alloc::string::String
 pub fn bitcoin_units::Amount::try_from(value: bitcoin_units::SignedAmount) -> core::result::Result<Self, Self::Error>
@@ -793,7 +791,6 @@ pub fn bitcoin_units::SignedAmount::div(self, rhs: i64) -> Self::Output
 pub fn bitcoin_units::SignedAmount::div_assign(&mut self, rhs: i64)
 pub fn bitcoin_units::SignedAmount::eq(&self, other: &bitcoin_units::SignedAmount) -> bool
 pub fn bitcoin_units::SignedAmount::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
-pub fn bitcoin_units::SignedAmount::from(value: bitcoin_units::Amount) -> Self
 pub fn bitcoin_units::SignedAmount::from_btc(btc: f64) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::ParseAmountError>
 pub fn bitcoin_units::SignedAmount::from_float_in(value: f64, denom: bitcoin_units::amount::Denomination) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::ParseAmountError>
 pub fn bitcoin_units::SignedAmount::from_int_btc<T: core::convert::Into<i64>>(whole_bitcoin: T) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::OutOfRangeError>
@@ -822,6 +819,7 @@ pub fn bitcoin_units::SignedAmount::to_float_in(self, denom: bitcoin_units::amou
 pub fn bitcoin_units::SignedAmount::to_string_in(self, denom: bitcoin_units::amount::Denomination) -> alloc::string::String
 pub fn bitcoin_units::SignedAmount::to_string_with_denomination(self, denom: bitcoin_units::amount::Denomination) -> alloc::string::String
 pub fn bitcoin_units::SignedAmount::to_unsigned(self) -> core::result::Result<bitcoin_units::Amount, bitcoin_units::amount::OutOfRangeError>
+pub fn bitcoin_units::SignedAmount::try_from(value: bitcoin_units::Amount) -> core::result::Result<Self, Self::Error>
 pub fn bitcoin_units::SignedAmount::unchecked_add(self, rhs: bitcoin_units::SignedAmount) -> bitcoin_units::SignedAmount
 pub fn bitcoin_units::SignedAmount::unchecked_sub(self, rhs: bitcoin_units::SignedAmount) -> bitcoin_units::SignedAmount
 pub fn bitcoin_units::SignedAmount::unsigned_abs(self) -> bitcoin_units::Amount
@@ -1118,6 +1116,7 @@ pub type bitcoin_units::Amount::Error = bitcoin_units::amount::OutOfRangeError
 pub type bitcoin_units::Amount::Output = bitcoin_units::Amount
 pub type bitcoin_units::Amount::Output = bitcoin_units::fee_rate::FeeRate
 pub type bitcoin_units::SignedAmount::Err = bitcoin_units::amount::ParseError
+pub type bitcoin_units::SignedAmount::Error = bitcoin_units::amount::OutOfRangeError
 pub type bitcoin_units::SignedAmount::Output = bitcoin_units::SignedAmount
 pub type bitcoin_units::amount::Denomination::Err = bitcoin_units::amount::ParseDenominationError
 pub type bitcoin_units::block::BlockHeight::Err = bitcoin_units::parse::ParseIntError
diff --git a/api/units/no-features.txt b/api/units/no-features.txt
index db86722e..17a93af2 100644
--- a/api/units/no-features.txt
+++ b/api/units/no-features.txt
@@ -141,7 +141,6 @@ impl core::cmp::PartialOrd for bitcoin_units::locktime::relative::Height
 impl core::cmp::PartialOrd for bitcoin_units::locktime::relative::Time
 impl core::cmp::PartialOrd for bitcoin_units::weight::Weight
 impl core::convert::AsRef<core::num::error::ParseIntError> for bitcoin_units::parse::ParseIntError
-impl core::convert::From<bitcoin_units::Amount> for bitcoin_units::SignedAmount
 impl core::convert::From<bitcoin_units::amount::InputTooLargeError> for bitcoin_units::amount::ParseAmountError
 impl core::convert::From<bitcoin_units::amount::InputTooLargeError> for bitcoin_units::amount::ParseError
 impl core::convert::From<bitcoin_units::amount::InvalidCharacterError> for bitcoin_units::amount::ParseAmountError
@@ -179,6 +178,7 @@ impl core::convert::TryFrom<&str> for bitcoin_units::locktime::absolute::Time
 impl core::convert::TryFrom<&str> for bitcoin_units::locktime::relative::Height
 impl core::convert::TryFrom<&str> for bitcoin_units::locktime::relative::Time
 impl core::convert::TryFrom<&str> for bitcoin_units::weight::Weight
+impl core::convert::TryFrom<bitcoin_units::Amount> for bitcoin_units::SignedAmount
 impl core::convert::TryFrom<bitcoin_units::SignedAmount> for bitcoin_units::Amount
 impl core::convert::TryFrom<bitcoin_units::block::BlockHeight> for bitcoin_units::locktime::absolute::Height
 impl core::convert::TryFrom<bitcoin_units::block::BlockInterval> for bitcoin_units::locktime::relative::Height
@@ -647,7 +647,6 @@ pub const fn bitcoin_units::Amount::checked_rem(self, rhs: u64) -> core::option:
 pub const fn bitcoin_units::Amount::checked_sub(self, rhs: bitcoin_units::Amount) -> core::option::Option<bitcoin_units::Amount>
 pub const fn bitcoin_units::Amount::from_int_btc_const(whole_bitcoin: u32) -> bitcoin_units::Amount
 pub const fn bitcoin_units::Amount::from_sat(satoshi: u64) -> bitcoin_units::Amount
-pub const fn bitcoin_units::Amount::from_sat_unchecked(satoshi: u64) -> bitcoin_units::Amount
 pub const fn bitcoin_units::Amount::to_sat(self) -> u64
 pub const fn bitcoin_units::SignedAmount::checked_abs(self) -> core::option::Option<bitcoin_units::SignedAmount>
 pub const fn bitcoin_units::SignedAmount::checked_add(self, rhs: bitcoin_units::SignedAmount) -> core::option::Option<bitcoin_units::SignedAmount>
@@ -657,7 +656,6 @@ pub const fn bitcoin_units::SignedAmount::checked_rem(self, rhs: i64) -> core::o
 pub const fn bitcoin_units::SignedAmount::checked_sub(self, rhs: bitcoin_units::SignedAmount) -> core::option::Option<bitcoin_units::SignedAmount>
 pub const fn bitcoin_units::SignedAmount::from_int_btc_const(whole_bitcoin: i64) -> bitcoin_units::SignedAmount
 pub const fn bitcoin_units::SignedAmount::from_sat(satoshi: i64) -> bitcoin_units::SignedAmount
-pub const fn bitcoin_units::SignedAmount::from_sat_unchecked(satoshi: i64) -> bitcoin_units::SignedAmount
 pub const fn bitcoin_units::SignedAmount::to_sat(self) -> i64
 pub const fn bitcoin_units::block::BlockHeight::from_u32(inner: u32) -> Self
 pub const fn bitcoin_units::block::BlockHeight::to_u32(self) -> u32
@@ -751,7 +749,7 @@ pub fn bitcoin_units::Amount::sub_assign(&mut self, rhs: &bitcoin_units::Amount)
 pub fn bitcoin_units::Amount::sub_assign(&mut self, rhs: bitcoin_units::Amount)
 pub fn bitcoin_units::Amount::sum<I: core::iter::traits::iterator::Iterator<Item = Self>>(iter: I) -> Self
 pub fn bitcoin_units::Amount::sum<I>(iter: I) -> Self where I: core::iter::traits::iterator::Iterator<Item = &'a bitcoin_units::Amount>
-pub fn bitcoin_units::Amount::to_signed(self) -> bitcoin_units::SignedAmount
+pub fn bitcoin_units::Amount::to_signed(self) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::OutOfRangeError>
 pub fn bitcoin_units::Amount::try_from(value: bitcoin_units::SignedAmount) -> core::result::Result<Self, Self::Error>
 pub fn bitcoin_units::Amount::unchecked_add(self, rhs: bitcoin_units::Amount) -> bitcoin_units::Amount
 pub fn bitcoin_units::Amount::unchecked_sub(self, rhs: bitcoin_units::Amount) -> bitcoin_units::Amount
@@ -769,7 +767,6 @@ pub fn bitcoin_units::SignedAmount::div(self, rhs: i64) -> Self::Output
 pub fn bitcoin_units::SignedAmount::div_assign(&mut self, rhs: i64)
 pub fn bitcoin_units::SignedAmount::eq(&self, other: &bitcoin_units::SignedAmount) -> bool
 pub fn bitcoin_units::SignedAmount::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
-pub fn bitcoin_units::SignedAmount::from(value: bitcoin_units::Amount) -> Self
 pub fn bitcoin_units::SignedAmount::from_int_btc<T: core::convert::Into<i64>>(whole_bitcoin: T) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::OutOfRangeError>
 pub fn bitcoin_units::SignedAmount::from_str(s: &str) -> core::result::Result<Self, Self::Err>
 pub fn bitcoin_units::SignedAmount::from_str_in(s: &str, denom: bitcoin_units::amount::Denomination) -> core::result::Result<bitcoin_units::SignedAmount, bitcoin_units::amount::ParseAmountError>
@@ -792,6 +789,7 @@ pub fn bitcoin_units::SignedAmount::sub_assign(&mut self, rhs: bitcoin_units::Si
 pub fn bitcoin_units::SignedAmount::sum<I: core::iter::traits::iterator::Iterator<Item = Self>>(iter: I) -> Self
 pub fn bitcoin_units::SignedAmount::sum<I>(iter: I) -> Self where I: core::iter::traits::iterator::Iterator<Item = &'a bitcoin_units::SignedAmount>
 pub fn bitcoin_units::SignedAmount::to_unsigned(self) -> core::result::Result<bitcoin_units::Amount, bitcoin_units::amount::OutOfRangeError>
+pub fn bitcoin_units::SignedAmount::try_from(value: bitcoin_units::Amount) -> core::result::Result<Self, Self::Error>
 pub fn bitcoin_units::SignedAmount::unchecked_add(self, rhs: bitcoin_units::SignedAmount) -> bitcoin_units::SignedAmount
 pub fn bitcoin_units::SignedAmount::unchecked_sub(self, rhs: bitcoin_units::SignedAmount) -> bitcoin_units::SignedAmount
 pub fn bitcoin_units::SignedAmount::unsigned_abs(self) -> bitcoin_units::Amount
@@ -1072,6 +1070,7 @@ pub type bitcoin_units::Amount::Error = bitcoin_units::amount::OutOfRangeError
 pub type bitcoin_units::Amount::Output = bitcoin_units::Amount
 pub type bitcoin_units::Amount::Output = bitcoin_units::fee_rate::FeeRate
 pub type bitcoin_units::SignedAmount::Err = bitcoin_units::amount::ParseError
+pub type bitcoin_units::SignedAmount::Error = bitcoin_units::amount::OutOfRangeError
 pub type bitcoin_units::SignedAmount::Output = bitcoin_units::SignedAmount
 pub type bitcoin_units::amount::Denomination::Err = bitcoin_units::amount::ParseDenominationError
 pub type bitcoin_units::block::BlockHeight::Err = bitcoin_units::parse::ParseIntError
diff --git a/bitcoin/Cargo.toml b/bitcoin/Cargo.toml
index 04cc4501..46e1e4c1 100644
--- a/bitcoin/Cargo.toml
+++ b/bitcoin/Cargo.toml
@@ -39,7 +39,7 @@ arbitrary = { version = "1.4", optional = true }
 base64 = { version = "0.22.0", optional = true }
 # `bitcoinconsensus` version includes metadata which indicates the version of Core. Use `cargo tree` to see it.
 bitcoinconsensus = { version = "0.106.0", default-features = false, optional = true }
-ordered = { version = "0.3.0", optional = true }
+ordered = { version = "0.2.0", optional = true }
 serde = { version = "1.0.103", default-features = false, features = [ "derive", "alloc" ], optional = true }
 
 [dev-dependencies]
diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs
index 5dea49ba..84c53de7 100644
--- a/bitcoin/src/blockdata/transaction.rs
+++ b/bitcoin/src/blockdata/transaction.rs
@@ -790,8 +790,8 @@ pub fn effective_value(
     value: Amount,
 ) -> Option<SignedAmount> {
     let weight = satisfaction_weight.checked_add(TX_IN_BASE_WEIGHT)?;
-    let signed_input_fee = fee_rate.checked_mul_by_weight(weight)?.to_signed();
-    value.to_signed().checked_sub(signed_input_fee)
+    let signed_input_fee = fee_rate.checked_mul_by_weight(weight)?.to_signed().ok()?;
+    value.to_signed().ok()?.checked_sub(signed_input_fee)
 }
 
 /// Predicts the weight of a to-be-constructed transaction.
@@ -1673,7 +1673,7 @@ fn effective_value_happy_path() {
 
         // 10 sat/kwu * (204wu + BASE_WEIGHT) = 4 sats
         let expected_fee = "4 sats".parse::<SignedAmount>().unwrap();
-        let expected_effective_value = value.to_signed() - expected_fee;
+        let expected_effective_value = value.to_signed().unwrap() - expected_fee;
         assert_eq!(effective_value, expected_effective_value);
     }
 
diff --git a/contrib/api.sh b/contrib/api.sh
index 03bfe120..97bfcf1e 100755
--- a/contrib/api.sh
+++ b/contrib/api.sh
@@ -99,12 +99,12 @@ main() {
 
 # Print all public structs and enums.
 structs_and_enums() {
-    grep -oP 'pub (struct|enum) \K[\w:]+(?:<[^>]+>)?(?=\(|;| |$)' "$file" | sed "s/^${crate_full_name}:://"
+    grep -oP 'pub (struct|enum) \K[\w:]+(?=\(|;| |$)' "$file" | sed "s/^${crate_full_name}:://"
 }
 
 # Print all public structs and enums excluding error types.
 structs_and_enums_no_err() {
-    grep -oP 'pub (struct|enum) \K[\w:]+(?:<[^>]+>)?(?=\(|;| |$)' "$file" | sed "s/^${crate_full_name}:://" | grep -v Error
+    grep -oP 'pub (struct|enum) \K[\w:]+(?=\(|;| |$)' "$file" | sed "s/^${crate_full_name}:://" | grep -v Error
 }
 
 # Print all public traits.
diff --git a/hashes/src/macros.rs b/hashes/src/macros.rs
index dc134577..3d5382ae 100644
--- a/hashes/src/macros.rs
+++ b/hashes/src/macros.rs
@@ -533,7 +533,6 @@ fn deserialize<D: $crate::serde::Deserializer<'de>>(d: D) -> core::result::Resul
 ));
 
 /// Does an "empty" serde implementation for the configuration without serde feature.
-#[doc(hidden)]
 #[macro_export]
 #[cfg(not(feature = "serde"))]
 macro_rules! serde_impl(
diff --git a/io/src/lib.rs b/io/src/lib.rs
index 35e12b63..9770f6ce 100644
--- a/io/src/lib.rs
+++ b/io/src/lib.rs
@@ -224,19 +224,6 @@ pub fn into_inner(self) -> T { self.inner }
     ///
     /// This is the whole wrapped buffer, including the bytes already read.
     #[inline]
-    pub fn get_ref(&self) -> &T { &self.inner }
-
-    /// Returns a mutable reference to the inner buffer.
-    ///
-    /// This is the whole wrapped buffer, including the bytes already read.
-    #[inline]
-    pub fn get_mut(&mut self) -> &mut T { &mut self.inner }
-
-    /// Returns a reference to the inner buffer.
-    ///
-    /// This is the whole wrapped buffer, including the bytes already read.
-    #[inline]
-    #[deprecated(since = "TBD", note = "use `get_ref()` instead")]
     pub fn inner(&self) -> &T { &self.inner }
 }
 
diff --git a/nightly-version b/nightly-version
index 5de8e302..a9dd23c1 100644
--- a/nightly-version
+++ b/nightly-version
@@ -1,1 +1,1 @@
-nightly-2024-12-26
+nightly-2024-12-20
diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml
index c8262265..3d75906e 100644
--- a/primitives/Cargo.toml
+++ b/primitives/Cargo.toml
@@ -29,7 +29,7 @@ io = { package = "bitcoin-io", version = "0.2.0", default-features = false }
 units = { package = "bitcoin-units", version = "0.2.0", default-features = false }
 
 arbitrary = { version = "1.4", optional = true }
-ordered = { version = "0.3.0", optional = true }
+ordered = { version = "0.2.0", optional = true }
 serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"], optional = true }
 
 [dev-dependencies]
diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs
index d629344e..a25d422e 100644
--- a/primitives/src/lib.rs
+++ b/primitives/src/lib.rs
@@ -33,6 +33,14 @@
 #[macro_use]
 extern crate serde;
 
+#[doc(hidden)]
+pub mod _export {
+    /// A re-export of `core::*`.
+    pub mod _core {
+        pub use core::*;
+    }
+}
+
 pub mod block;
 pub mod locktime;
 pub mod merkle_tree;
diff --git a/units/src/amount/signed.rs b/units/src/amount/signed.rs
index 4580af03..2faa7e45 100644
--- a/units/src/amount/signed.rs
+++ b/units/src/amount/signed.rs
@@ -83,13 +83,6 @@ pub const fn from_sat(satoshi: i64) -> SignedAmount { SignedAmount(satoshi) }
     /// ```
     pub const fn to_sat(self) -> i64 { self.0 }
 
-    /// Constructs a new [`SignedAmount`] with satoshi precision and the given number of satoshis.
-    ///
-    /// Caller to guarantee that `satoshi` is within valid range.
-    ///
-    /// See [`Self::MIN`] and [`Self::MAX_MONEY`].
-    pub const fn from_sat_unchecked(satoshi: i64) -> SignedAmount { SignedAmount(satoshi) }
-
     /// Converts from a value expressing a decimal number of bitcoin to a [`SignedAmount`].
     ///
     /// # Errors
@@ -295,6 +288,8 @@ pub fn to_string_with_denomination(self, denom: Denomination) -> String {
         self.display_in(denom).show_denomination().to_string()
     }
 
+    // Some arithmetic that doesn't fit in [`core::ops`] traits.
+
     /// Gets the absolute value of this [`SignedAmount`].
     #[must_use]
     pub fn abs(self) -> SignedAmount { SignedAmount(self.0.abs()) }
@@ -562,11 +557,10 @@ fn from_str(s: &str) -> Result<Self, Self::Err> {
     }
 }
 
-impl From<Amount> for SignedAmount {
-    fn from(value: Amount) -> Self {
-        let v = value.to_sat() as i64; // Cast ok, signed amount and amount share positive range.
-        SignedAmount::from_sat_unchecked(v)
-    }
+impl TryFrom<Amount> for SignedAmount {
+    type Error = OutOfRangeError;
+
+    fn try_from(value: Amount) -> Result<Self, Self::Error> { value.to_signed() }
 }
 
 impl core::iter::Sum for SignedAmount {
diff --git a/units/src/amount/unsigned.rs b/units/src/amount/unsigned.rs
index f6cb57eb..e7b21418 100644
--- a/units/src/amount/unsigned.rs
+++ b/units/src/amount/unsigned.rs
@@ -90,11 +90,6 @@ pub const fn from_sat(satoshi: u64) -> Amount { Amount(satoshi) }
     /// ```
     pub const fn to_sat(self) -> u64 { self.0 }
 
-    /// Constructs a new [`Amount`] with satoshi precision and the given number of satoshis.
-    ///
-    /// Caller to guarantee that `satoshi` is within valid range. See [`Self::MAX_MONEY`].
-    pub const fn from_sat_unchecked(satoshi: u64) -> Amount { Self(satoshi) }
-
     /// Converts from a value expressing a decimal number of bitcoin to an [`Amount`].
     ///
     /// # Errors
@@ -303,6 +298,8 @@ pub fn to_string_with_denomination(self, denom: Denomination) -> String {
         self.display_in(denom).show_denomination().to_string()
     }
 
+    // Some arithmetic that doesn't fit in [`core::ops`] traits.
+
     /// Checked addition.
     ///
     /// Returns [`None`] if the sum is larger than [`Amount::MAX`].
@@ -441,9 +438,17 @@ pub fn unchecked_add(self, rhs: Amount) -> Amount { Self(self.0 + rhs.0) }
     pub fn unchecked_sub(self, rhs: Amount) -> Amount { Self(self.0 - rhs.0) }
 
     /// Converts to a signed amount.
+    ///
+    /// # Errors
+    ///
+    /// If the amount is too big.
     #[rustfmt::skip] // Moves code comments to the wrong line.
-    pub fn to_signed(self) -> SignedAmount {
-        SignedAmount::from_sat_unchecked(self.to_sat() as i64) // Cast ok, signed amount and amount share positive range.
+    pub fn to_signed(self) -> Result<SignedAmount, OutOfRangeError> {
+        if self.to_sat() > SignedAmount::MAX.to_sat() as u64 { // Cast ok, signed max is positive and fits in u64.
+            Err(OutOfRangeError::too_big(true))
+        } else {
+            Ok(SignedAmount::from_sat(self.to_sat() as i64)) // Cast ok, checked not too big above.
+        }
     }
 
     /// Checks if the amount is below the maximum value. Returns `None` if it is above.


Test patch:
diff --git a/units/src/amount/tests.rs b/units/src/amount/tests.rs
index a5626c24..d5e93947 100644
--- a/units/src/amount/tests.rs
+++ b/units/src/amount/tests.rs
@@ -25,7 +25,7 @@ fn from_str_zero() {
             let s = format!("{} {}", v, denom);
             match s.parse::<Amount>() {
                 Err(e) => panic!("failed to crate amount from {}: {:?}", s, e),
-                Ok(amount) => assert_eq!(amount, Amount::ZERO),
+                Ok(amount) => assert_eq!(amount, Amount::from_sat(0)),
             }
         }
 
@@ -41,7 +41,7 @@ fn from_str_zero() {
         }
         match s.parse::<SignedAmount>() {
             Err(e) => panic!("failed to crate amount from {}: {:?}", s, e),
-            Ok(amount) => assert_eq!(amount, SignedAmount::ZERO),
+            Ok(amount) => assert_eq!(amount, SignedAmount::from_sat(0)),
         }
     }
 }
@@ -68,16 +68,23 @@ fn from_str_zero_without_denomination() {
 #[test]
 fn from_int_btc() {
     let amt = Amount::from_int_btc_const(2);
-    assert_eq!(Amount::from_sat_unchecked(200_000_000), amt);
+    assert_eq!(Amount::from_sat(200_000_000), amt);
+}
+
+#[test]
+fn test_signed_amount_try_from_amount() {
+    let ua_positive = Amount::from_sat(123);
+    let sa_positive = SignedAmount::try_from(ua_positive).unwrap();
+    assert_eq!(sa_positive, SignedAmount::from_sat(123));
 }
 
 #[test]
 fn test_amount_try_from_signed_amount() {
-    let sa_positive = SignedAmount::from_sat_unchecked(123);
+    let sa_positive = SignedAmount::from_sat(123);
     let ua_positive = Amount::try_from(sa_positive).unwrap();
-    assert_eq!(ua_positive, Amount::from_sat_unchecked(123));
+    assert_eq!(ua_positive, Amount::from_sat(123));
 
-    let sa_negative = SignedAmount::from_sat_unchecked(-123);
+    let sa_negative = SignedAmount::from_sat(-123);
     let result = Amount::try_from(sa_negative);
     assert_eq!(result, Err(OutOfRangeError { is_signed: false, is_greater_than_max: false }));
 }
@@ -105,9 +112,9 @@ fn mul_div() {
 #[test]
 fn test_overflows() {
     // panic on overflow
-    let result = panic::catch_unwind(|| Amount::MAX + Amount::from_sat_unchecked(1));
+    let result = panic::catch_unwind(|| Amount::MAX + Amount::from_sat(1));
     assert!(result.is_err());
-    let result = panic::catch_unwind(|| Amount::from_sat_unchecked(8_446_744_073_709_551_615) * 3);
+    let result = panic::catch_unwind(|| Amount::from_sat(8_446_744_073_709_551_615) * 3);
     assert!(result.is_err());
 }
 
@@ -129,12 +136,12 @@ fn checked_arithmetic() {
 #[test]
 fn amount_checked_div_by_weight_ceil() {
     let weight = Weight::from_kwu(1).unwrap();
-    let fee_rate = Amount::from_sat_unchecked(1).checked_div_by_weight_ceil(weight).unwrap();
+    let fee_rate = Amount::from_sat(1).checked_div_by_weight_ceil(weight).unwrap();
     // 1 sats / 1,000 wu = 1 sats/kwu
     assert_eq!(fee_rate, FeeRate::from_sat_per_kwu(1));
 
     let weight = Weight::from_wu(381);
-    let fee_rate = Amount::from_sat_unchecked(329).checked_div_by_weight_ceil(weight).unwrap();
+    let fee_rate = Amount::from_sat(329).checked_div_by_weight_ceil(weight).unwrap();
     // 329 sats / 381 wu = 863.5 sats/kwu
     // round up to 864
     assert_eq!(fee_rate, FeeRate::from_sat_per_kwu(864));
@@ -147,12 +154,12 @@ fn amount_checked_div_by_weight_ceil() {
 #[test]
 fn amount_checked_div_by_weight_floor() {
     let weight = Weight::from_kwu(1).unwrap();
-    let fee_rate = Amount::from_sat_unchecked(1).checked_div_by_weight_floor(weight).unwrap();
+    let fee_rate = Amount::from_sat(1).checked_div_by_weight_floor(weight).unwrap();
     // 1 sats / 1,000 wu = 1 sats/kwu
     assert_eq!(fee_rate, FeeRate::from_sat_per_kwu(1));
 
     let weight = Weight::from_wu(381);
-    let fee_rate = Amount::from_sat_unchecked(329).checked_div_by_weight_floor(weight).unwrap();
+    let fee_rate = Amount::from_sat(329).checked_div_by_weight_floor(weight).unwrap();
     // 329 sats / 381 wu = 863.5 sats/kwu
     // round down to 863
     assert_eq!(fee_rate, FeeRate::from_sat_per_kwu(863));
@@ -239,22 +246,22 @@ fn parsing() {
     #[cfg(feature = "alloc")]
     assert_eq!(p(&more_than_max, btc), Err(OutOfRangeError::too_big(false).into()));
     assert_eq!(p("0.000000042", btc), Err(TooPreciseError { position: 10 }.into()));
-    assert_eq!(p("1.0000000", sat), Ok(Amount::from_sat_unchecked(1)));
+    assert_eq!(p("1.0000000", sat), Ok(Amount::from_sat(1)));
     assert_eq!(p("1.1", sat), Err(TooPreciseError { position: 2 }.into()));
     assert_eq!(p("1000.1", sat), Err(TooPreciseError { position: 5 }.into()));
-    assert_eq!(p("1001.0000000", sat), Ok(Amount::from_sat_unchecked(1001)));
+    assert_eq!(p("1001.0000000", sat), Ok(Amount::from_sat(1001)));
     assert_eq!(p("1000.0000001", sat), Err(TooPreciseError { position: 11 }.into()));
 
-    assert_eq!(p("1", btc), Ok(Amount::from_sat_unchecked(1_000_000_00)));
-    assert_eq!(sp("-.5", btc), Ok(SignedAmount::from_sat_unchecked(-500_000_00)));
+    assert_eq!(p("1", btc), Ok(Amount::from_sat(1_000_000_00)));
+    assert_eq!(sp("-.5", btc), Ok(SignedAmount::from_sat(-500_000_00)));
     #[cfg(feature = "alloc")]
     assert_eq!(sp(&SignedAmount::MIN.to_sat().to_string(), sat), Ok(SignedAmount::MIN));
-    assert_eq!(p("1.1", btc), Ok(Amount::from_sat_unchecked(1_100_000_00)));
-    assert_eq!(p("100", sat), Ok(Amount::from_sat_unchecked(100)));
-    assert_eq!(p("55", sat), Ok(Amount::from_sat_unchecked(55)));
-    assert_eq!(p("2100000000000000", sat), Ok(Amount::from_sat_unchecked(21_000_000__000_000_00)));
-    assert_eq!(p("2100000000000000.", sat), Ok(Amount::from_sat_unchecked(21_000_000__000_000_00)));
-    assert_eq!(p("21000000", btc), Ok(Amount::from_sat_unchecked(21_000_000__000_000_00)));
+    assert_eq!(p("1.1", btc), Ok(Amount::from_sat(1_100_000_00)));
+    assert_eq!(p("100", sat), Ok(Amount::from_sat(100)));
+    assert_eq!(p("55", sat), Ok(Amount::from_sat(55)));
+    assert_eq!(p("2100000000000000", sat), Ok(Amount::from_sat(21_000_000__000_000_00)));
+    assert_eq!(p("2100000000000000.", sat), Ok(Amount::from_sat(21_000_000__000_000_00)));
+    assert_eq!(p("21000000", btc), Ok(Amount::from_sat(21_000_000__000_000_00)));
 
     // exactly 50 chars.
     assert_eq!(
@@ -277,13 +284,13 @@ fn to_string() {
     assert_eq!(format!("{:.8}", Amount::ONE_BTC.display_in(D::Bitcoin)), "1.00000000");
     assert_eq!(Amount::ONE_BTC.to_string_in(D::Satoshi), "100000000");
     assert_eq!(Amount::ONE_SAT.to_string_in(D::Bitcoin), "0.00000001");
-    assert_eq!(SignedAmount::from_sat_unchecked(-42).to_string_in(D::Bitcoin), "-0.00000042");
+    assert_eq!(SignedAmount::from_sat(-42).to_string_in(D::Bitcoin), "-0.00000042");
 
     assert_eq!(Amount::ONE_BTC.to_string_with_denomination(D::Bitcoin), "1 BTC");
     assert_eq!(SignedAmount::ONE_BTC.to_string_with_denomination(D::Satoshi), "100000000 satoshi");
     assert_eq!(Amount::ONE_SAT.to_string_with_denomination(D::Bitcoin), "0.00000001 BTC");
     assert_eq!(
-        SignedAmount::from_sat_unchecked(-42).to_string_with_denomination(D::Bitcoin),
+        SignedAmount::from_sat(-42).to_string_with_denomination(D::Bitcoin),
         "-0.00000042 BTC"
     );
 }
@@ -466,11 +473,12 @@ fn test_unsigned_signed_conversion() {
     let ua = Amount::from_sat;
     let max_sats: u64 = Amount::MAX.to_sat();
 
-    assert_eq!(ua(max_sats).to_signed(), sa(max_sats as i64));
+    assert_eq!(ua(max_sats).to_signed(), Ok(sa(max_sats as i64)));
+    assert_eq!(ua(i64::MAX as u64 + 1).to_signed(), Err(OutOfRangeError::too_big(true)));
 
     assert_eq!(sa(max_sats as i64).to_unsigned(), Ok(ua(max_sats)));
 
-    assert_eq!(sa(max_sats as i64).to_unsigned().unwrap().to_signed(), sa(max_sats as i64));
+    assert_eq!(sa(max_sats as i64).to_unsigned().unwrap().to_signed(), Ok(sa(max_sats as i64)));
 }
 
 #[test]
@@ -543,12 +551,12 @@ fn scase(s: &str, expected: Result<SignedAmount, impl Into<ParseError>>) {
     case("21000001 BTC", Err(OutOfRangeError::too_big(false)));
     case("18446744073709551616 sat", Err(OutOfRangeError::too_big(false)));
 
-    ok_case(".5 bits", Amount::from_sat_unchecked(50));
-    ok_scase("-.5 bits", SignedAmount::from_sat_unchecked(-50));
-    ok_case("0.00253583 BTC", Amount::from_sat_unchecked(253_583));
-    ok_scase("-5 satoshi", SignedAmount::from_sat_unchecked(-5));
-    ok_case("0.10000000 BTC", Amount::from_sat_unchecked(100_000_00));
-    ok_scase("-100 bits", SignedAmount::from_sat_unchecked(-10_000));
+    ok_case(".5 bits", Amount::from_sat(50));
+    ok_scase("-.5 bits", SignedAmount::from_sat(-50));
+    ok_case("0.00253583 BTC", Amount::from_sat(253_583));
+    ok_scase("-5 satoshi", SignedAmount::from_sat(-5));
+    ok_case("0.10000000 BTC", Amount::from_sat(100_000_00));
+    ok_scase("-100 bits", SignedAmount::from_sat(-10_000));
     ok_case("21000000 BTC", Amount::MAX);
     ok_scase("21000000 BTC", SignedAmount::MAX);
     ok_scase("-21000000 BTC", SignedAmount::MIN);
@@ -560,45 +568,44 @@ fn scase(s: &str, expected: Result<SignedAmount, impl Into<ParseError>>) {
 fn to_from_string_in() {
     use super::Denomination as D;
     let ua_str = Amount::from_str_in;
-    let ua_sat = Amount::from_sat_unchecked;
+    let ua_sat = Amount::from_sat;
     let sa_str = SignedAmount::from_str_in;
-    let sa_sat = SignedAmount::from_sat_unchecked;
 
-    assert_eq!("0.5", ua_sat(50).to_string_in(D::Bit));
-    assert_eq!("-0.5", sa_sat(-50).to_string_in(D::Bit));
-    assert_eq!("0.00253583", ua_sat(253_583).to_string_in(D::Bitcoin));
-    assert_eq!("-5", sa_sat(-5).to_string_in(D::Satoshi));
-    assert_eq!("0.1", ua_sat(100_000_00).to_string_in(D::Bitcoin));
-    assert_eq!("-0.1", sa_sat(-100_000_00).to_string_in(D::Bitcoin));
+    assert_eq!("0.5", Amount::from_sat(50).to_string_in(D::Bit));
+    assert_eq!("-0.5", SignedAmount::from_sat(-50).to_string_in(D::Bit));
+    assert_eq!("0.00253583", Amount::from_sat(253_583).to_string_in(D::Bitcoin));
+    assert_eq!("-5", SignedAmount::from_sat(-5).to_string_in(D::Satoshi));
+    assert_eq!("0.1", Amount::from_sat(100_000_00).to_string_in(D::Bitcoin));
+    assert_eq!("-0.1", SignedAmount::from_sat(-100_000_00).to_string_in(D::Bitcoin));
 
-    assert_eq!("0.253583", ua_sat(253_583).to_string_in(D::CentiBitcoin));
-    assert_eq!("-0.253583", sa_sat(-253_583).to_string_in(D::CentiBitcoin));
-    assert_eq!("10", ua_sat(100_000_00).to_string_in(D::CentiBitcoin));
-    assert_eq!("-10", sa_sat(-100_000_00).to_string_in(D::CentiBitcoin));
+    assert_eq!("0.253583", Amount::from_sat(253_583).to_string_in(D::CentiBitcoin));
+    assert_eq!("-0.253583", SignedAmount::from_sat(-253_583).to_string_in(D::CentiBitcoin));
+    assert_eq!("10", Amount::from_sat(100_000_00).to_string_in(D::CentiBitcoin));
+    assert_eq!("-10", SignedAmount::from_sat(-100_000_00).to_string_in(D::CentiBitcoin));
 
-    assert_eq!("2.53583", ua_sat(253_583).to_string_in(D::MilliBitcoin));
-    assert_eq!("-2.53583", sa_sat(-253_583).to_string_in(D::MilliBitcoin));
-    assert_eq!("100", ua_sat(100_000_00).to_string_in(D::MilliBitcoin));
-    assert_eq!("-100", sa_sat(-100_000_00).to_string_in(D::MilliBitcoin));
+    assert_eq!("2.53583", Amount::from_sat(253_583).to_string_in(D::MilliBitcoin));
+    assert_eq!("-2.53583", SignedAmount::from_sat(-253_583).to_string_in(D::MilliBitcoin));
+    assert_eq!("100", Amount::from_sat(100_000_00).to_string_in(D::MilliBitcoin));
+    assert_eq!("-100", SignedAmount::from_sat(-100_000_00).to_string_in(D::MilliBitcoin));
 
-    assert_eq!("2535.83", ua_sat(253_583).to_string_in(D::MicroBitcoin));
-    assert_eq!("-2535.83", sa_sat(-253_583).to_string_in(D::MicroBitcoin));
-    assert_eq!("100000", ua_sat(100_000_00).to_string_in(D::MicroBitcoin));
-    assert_eq!("-100000", sa_sat(-100_000_00).to_string_in(D::MicroBitcoin));
+    assert_eq!("2535.83", Amount::from_sat(253_583).to_string_in(D::MicroBitcoin));
+    assert_eq!("-2535.83", SignedAmount::from_sat(-253_583).to_string_in(D::MicroBitcoin));
+    assert_eq!("100000", Amount::from_sat(100_000_00).to_string_in(D::MicroBitcoin));
+    assert_eq!("-100000", SignedAmount::from_sat(-100_000_00).to_string_in(D::MicroBitcoin));
 
-    assert_eq!("0.5", ua_sat(50).to_string_in(D::Bit));
-    assert_eq!("100", ua_sat(10_000).to_string_in(D::Bit));
-    assert_eq!("-0.5", sa_sat(-50).to_string_in(D::Bit));
-    assert_eq!("-100", sa_sat(-10_000).to_string_in(D::Bit));
+    assert_eq!("0.5", Amount::from_sat(50).to_string_in(D::Bit));
+    assert_eq!("100", Amount::from_sat(10_000).to_string_in(D::Bit));
+    assert_eq!("-0.5", SignedAmount::from_sat(-50).to_string_in(D::Bit));
+    assert_eq!("-100", SignedAmount::from_sat(-10_000).to_string_in(D::Bit));
 
-    assert_eq!("5", ua_sat(5).to_string_in(D::Satoshi));
-    assert_eq!("-5", sa_sat(-5).to_string_in(D::Satoshi));
+    assert_eq!("5", Amount::from_sat(5).to_string_in(D::Satoshi));
+    assert_eq!("-5", SignedAmount::from_sat(-5).to_string_in(D::Satoshi));
 
-    assert_eq!("0.50", format!("{:.2}", ua_sat(50).display_in(D::Bit)));
-    assert_eq!("-0.50", format!("{:.2}", sa_sat(-50).display_in(D::Bit)));
+    assert_eq!("0.50", format!("{:.2}", Amount::from_sat(50).display_in(D::Bit)));
+    assert_eq!("-0.50", format!("{:.2}", SignedAmount::from_sat(-50).display_in(D::Bit)));
 
-    assert_eq!("0.10000000", format!("{:.8}", ua_sat(100_000_00).display_in(D::Bitcoin)));
-    assert_eq!("-100.00", format!("{:.2}", sa_sat(-10_000).display_in(D::Bit)));
+    assert_eq!("0.10000000", format!("{:.8}", Amount::from_sat(100_000_00).display_in(D::Bitcoin)));
+    assert_eq!("-100.00", format!("{:.2}", SignedAmount::from_sat(-10_000).display_in(D::Bit)));
 
     assert_eq!(ua_str(&ua_sat(500).to_string_in(D::Bitcoin), D::Bitcoin), Ok(ua_sat(500)));
     assert_eq!(ua_str(&ua_sat(1).to_string_in(D::CentiBitcoin), D::CentiBitcoin), Ok(ua_sat(1)));
@@ -638,7 +645,7 @@ fn to_string_with_denomination_from_str_roundtrip() {
 
     use super::Denomination as D;
 
-    let amt = Amount::from_sat_unchecked(42);
+    let amt = Amount::from_sat(42);
     let denom = Amount::to_string_with_denomination;
     assert_eq!(denom(amt, D::Bitcoin).parse::<Amount>(), Ok(amt));
     assert_eq!(denom(amt, D::CentiBitcoin).parse::<Amount>(), Ok(amt));
@@ -669,10 +676,7 @@ struct T {
     }
 
     serde_test::assert_tokens(
-        &T {
-            amt: Amount::from_sat_unchecked(123_456_789),
-            samt: SignedAmount::from_sat_unchecked(-123_456_789),
-        },
+        &T { amt: Amount::from_sat(123_456_789), samt: SignedAmount::from_sat(-123_456_789) },
         &[
             serde_test::Token::Struct { name: "T", len: 2 },
             serde_test::Token::Str("amt"),
@@ -877,8 +881,8 @@ struct T {
 
 #[test]
 fn sum_amounts() {
-    assert_eq!(Amount::ZERO, [].iter().sum::<Amount>());
-    assert_eq!(SignedAmount::ZERO, [].iter().sum::<SignedAmount>());
+    assert_eq!(Amount::from_sat(0), [].iter().sum::<Amount>());
+    assert_eq!(SignedAmount::from_sat(0), [].iter().sum::<SignedAmount>());
 
     let amounts = [Amount::from_sat(42), Amount::from_sat(1337), Amount::from_sat(21)];
     let sum = amounts.into_iter().sum::<Amount>();
@@ -892,8 +896,8 @@ fn sum_amounts() {
 
 #[test]
 fn checked_sum_amounts() {
-    assert_eq!(Some(Amount::ZERO), [].into_iter().checked_sum());
-    assert_eq!(Some(SignedAmount::ZERO), [].into_iter().checked_sum());
+    assert_eq!(Some(Amount::from_sat(0)), [].into_iter().checked_sum());
+    assert_eq!(Some(SignedAmount::from_sat(0)), [].into_iter().checked_sum());
 
     let amounts = [Amount::from_sat(42), Amount::from_sat(1337), Amount::from_sat(21)];
     let sum = amounts.into_iter().checked_sum();