2025-05-25 automated rustfmt nightly

This commit is contained in:
Fmt Bot 2025-05-25 01:42:57 +00:00 committed by github-actions[bot]
parent ecf4b2bcee
commit c73131c8f0
5 changed files with 18 additions and 35 deletions

View File

@ -749,12 +749,11 @@ impl serde::Serialize for Psbt {
impl<'de> serde::Deserialize<'de> for Psbt { impl<'de> serde::Deserialize<'de> for Psbt {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where
D: serde::Deserializer<'de> D: serde::Deserializer<'de>,
{ {
struct Visitor; struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor impl<'de> serde::de::Visitor<'de> for Visitor {
{
type Value = Psbt; type Value = Psbt;
fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
@ -762,8 +761,7 @@ impl<'de> serde::Deserialize<'de> for Psbt {
} }
fn visit_bytes<E: serde::de::Error>(self, bytes: &[u8]) -> Result<Self::Value, E> { fn visit_bytes<E: serde::de::Error>(self, bytes: &[u8]) -> Result<Self::Value, E> {
Psbt::deserialize(bytes) Psbt::deserialize(bytes).map_err(|e| serde::de::Error::custom(e))
.map_err(|e| serde::de::Error::custom(e))
} }
fn visit_str<E: serde::de::Error>(self, s: &str) -> Result<Self::Value, E> { fn visit_str<E: serde::de::Error>(self, s: &str) -> Result<Self::Value, E> {
@ -1456,17 +1454,15 @@ mod tests {
Err(ABSURD_FEE_RATE) Err(ABSURD_FEE_RATE)
); );
assert_eq!( assert_eq!(
psbt.clone() psbt.clone().extract_tx_with_fee_rate_limit(JUST_BELOW_ABSURD_FEE_RATE).map_err(|e| {
.extract_tx_with_fee_rate_limit(JUST_BELOW_ABSURD_FEE_RATE) match e {
.map_err(|e| match e {
ExtractTxError::AbsurdFeeRate { fee_rate, .. } => fee_rate, ExtractTxError::AbsurdFeeRate { fee_rate, .. } => fee_rate,
_ => panic!(""), _ => panic!(""),
}
}), }),
Err(ABSURD_FEE_RATE) Err(ABSURD_FEE_RATE)
); );
assert!(psbt assert!(psbt.extract_tx_with_fee_rate_limit(ABSURD_FEE_RATE).is_ok());
.extract_tx_with_fee_rate_limit(ABSURD_FEE_RATE)
.is_ok());
// Testing that extract_tx will error at 25k sat/vbyte (6250000 sat/kwu) // Testing that extract_tx will error at 25k sat/vbyte (6250000 sat/kwu)
assert_eq!( assert_eq!(

View File

@ -30,8 +30,7 @@ use bitcoin::consensus::encode::deserialize;
use bitcoin::hashes::{hash160, ripemd160, sha256, sha256d}; use bitcoin::hashes::{hash160, ripemd160, sha256, sha256d};
use bitcoin::hex::FromHex; use bitcoin::hex::FromHex;
use bitcoin::locktime::{absolute, relative}; use bitcoin::locktime::{absolute, relative};
use bitcoin::psbt::raw; use bitcoin::psbt::{raw, Input, Output, Psbt, PsbtSighashType};
use bitcoin::psbt::{Input, Output, Psbt, PsbtSighashType};
use bitcoin::script::ScriptBufExt as _; use bitcoin::script::ScriptBufExt as _;
use bitcoin::sighash::{EcdsaSighashType, TapSighashType}; use bitcoin::sighash::{EcdsaSighashType, TapSighashType};
use bitcoin::taproot::{self, ControlBlock, LeafVersion, TapTree, TaprootBuilder}; use bitcoin::taproot::{self, ControlBlock, LeafVersion, TapTree, TaprootBuilder};

View File

@ -19,26 +19,17 @@ fn do_test(data: &[u8]) {
if let Ok(ip_addr) = IpAddr::try_from(addr_v2.clone()) { if let Ok(ip_addr) = IpAddr::try_from(addr_v2.clone()) {
let round_trip: AddrV2 = AddrV2::from(ip_addr); let round_trip: AddrV2 = AddrV2::from(ip_addr);
assert_eq!( assert_eq!(addr_v2, round_trip, "AddrV2 -> IpAddr -> AddrV2 should round-trip correctly");
addr_v2, round_trip,
"AddrV2 -> IpAddr -> AddrV2 should round-trip correctly"
);
} }
if let Ok(ip_addr) = Ipv4Addr::try_from(addr_v2.clone()) { if let Ok(ip_addr) = Ipv4Addr::try_from(addr_v2.clone()) {
let round_trip: AddrV2 = AddrV2::from(ip_addr); let round_trip: AddrV2 = AddrV2::from(ip_addr);
assert_eq!( assert_eq!(addr_v2, round_trip, "AddrV2 -> Ipv4Addr -> AddrV2 should round-trip correctly");
addr_v2, round_trip,
"AddrV2 -> Ipv4Addr -> AddrV2 should round-trip correctly"
);
} }
if let Ok(ip_addr) = Ipv6Addr::try_from(addr_v2.clone()) { if let Ok(ip_addr) = Ipv6Addr::try_from(addr_v2.clone()) {
let round_trip: AddrV2 = AddrV2::from(ip_addr); let round_trip: AddrV2 = AddrV2::from(ip_addr);
assert_eq!( assert_eq!(addr_v2, round_trip, "AddrV2 -> Ipv6Addr -> AddrV2 should round-trip correctly");
addr_v2, round_trip,
"AddrV2 -> Ipv6Addr -> AddrV2 should round-trip correctly"
);
} }
if let Ok(socket_addr) = SocketAddr::try_from(addr_v2.clone()) { if let Ok(socket_addr) = SocketAddr::try_from(addr_v2.clone()) {

View File

@ -347,7 +347,6 @@ impl fmt::Display for ParseDenominationError {
#[cfg(feature = "std")] #[cfg(feature = "std")]
impl std::error::Error for ParseDenominationError { impl std::error::Error for ParseDenominationError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match *self { match *self {
Self::Unknown(_) | Self::PossiblyConfusing(_) => None, Self::Unknown(_) | Self::PossiblyConfusing(_) => None,
} }

View File

@ -377,7 +377,6 @@ impl ParseError {
) -> fmt::Result { ) -> fmt::Result {
use core::num::IntErrorKind; use core::num::IntErrorKind;
match self { match self {
Self::ParseInt(ParseIntError { input, bits: _, is_signed: _, source }) Self::ParseInt(ParseIntError { input, bits: _, is_signed: _, source })
if *source.kind() == IntErrorKind::PosOverflow => if *source.kind() == IntErrorKind::PosOverflow =>
@ -425,7 +424,6 @@ impl ParseError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use core::num::IntErrorKind; use core::num::IntErrorKind;
match self { match self {
Self::ParseInt(ParseIntError { source, .. }) Self::ParseInt(ParseIntError { source, .. })
if *source.kind() == IntErrorKind::PosOverflow => if *source.kind() == IntErrorKind::PosOverflow =>