Skip to content

Commit

Permalink
Merge rust-bitcoin#3685: Automated nightly rustfmt (2024-12-01)
Browse files Browse the repository at this point in the history
0990b30 2024-12-01 automated rustfmt nightly (Fmt Bot)

Pull request description:

  Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  apoelstra:
    ACK 0990b30; successfully ran local tests

Tree-SHA512: 56e2f0de98868d4ce958764924a6a0f7c245ffa8c7898638b7d316b5b56d4fd2c9f5e01fe5e3da5ebcec44d135d44fdf99be5d912a7b1dbd93da8a6b1d82b14d
  • Loading branch information
apoelstra committed Dec 1, 2024
2 parents 230b9e5 + 0990b30 commit a4ad864
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
6 changes: 2 additions & 4 deletions bitcoin/src/blockdata/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,9 +1133,7 @@ impl InputWeightPrediction {
/// Computes the **signature weight** added to a transaction by an input with this weight prediction,
/// not counting the prevout (txid, index), sequence, potential witness flag bytes or the witness count varint.
#[deprecated(since = "TBD", note = "use `InputWeightPrediction::witness_weight()` instead")]
pub const fn weight(&self) -> Weight {
Self::witness_weight(self)
}
pub const fn weight(&self) -> Weight { Self::witness_weight(self) }

/// Computes the signature, prevout (txid, index), and sequence weights of this weight
/// prediction.
Expand Down Expand Up @@ -1972,7 +1970,7 @@ mod tests {
InputWeightPrediction::P2PKH_COMPRESSED_MAX,
InputWeightPrediction::P2PKH_UNCOMPRESSED_MAX,
InputWeightPrediction::P2TR_KEY_DEFAULT_SIGHASH,
InputWeightPrediction::P2TR_KEY_NON_DEFAULT_SIGHASH
InputWeightPrediction::P2TR_KEY_NON_DEFAULT_SIGHASH,
];

let weight = predict_weight_from_slices(&predict, &[1]);
Expand Down
4 changes: 2 additions & 2 deletions bitcoin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ pub mod parse {
#[doc(inline)]
pub use units::parse::{
hex_check_unprefixed, hex_remove_prefix, hex_u128, hex_u128_unchecked, hex_u128_unprefixed,
hex_u32, hex_u32_unchecked, hex_u32_unprefixed, int,
ParseIntError, PrefixedHexError, UnprefixedHexError,
hex_u32, hex_u32_unchecked, hex_u32_unprefixed, int, ParseIntError, PrefixedHexError,
UnprefixedHexError,
};
}

Expand Down
9 changes: 5 additions & 4 deletions bitcoin/src/psbt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ impl Psbt {
{
continue;
} else if derivation2.len() <= derivation1.len()
&& derivation2[..]
== derivation1[derivation1.len() - derivation2.len()..]
&& derivation2[..] == derivation1[derivation1.len() - derivation2.len()..]
{
entry.insert((fingerprint1, derivation1));
continue;
Expand Down Expand Up @@ -2117,14 +2116,16 @@ mod tests {
assert_eq!(psbt1, psbt2);
}


// https://github.com/rust-bitcoin/rust-bitcoin/issues/3628
#[test]
fn test_combine_psbt_fuzz_3628() {
let mut psbt1 = hex_psbt(include_str!("../../tests/data/psbt_fuzz1.hex")).unwrap();
let psbt2 = hex_psbt(include_str!("../../tests/data/psbt_fuzz2.hex")).unwrap();

assert!(matches!(psbt1.combine(psbt2).unwrap_err(), Error::CombineInconsistentKeySources(_)));
assert!(matches!(
psbt1.combine(psbt2).unwrap_err(),
Error::CombineInconsistentKeySources(_)
));
}

#[cfg(feature = "rand-std")]
Expand Down
16 changes: 4 additions & 12 deletions units/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,11 @@ impl std::error::Error for PrefixedHexError {
}

impl From<MissingPrefixError> for PrefixedHexError {
fn from(e: MissingPrefixError) -> Self {
Self(PrefixedHexErrorInner::MissingPrefix(e))
}
fn from(e: MissingPrefixError) -> Self { Self(PrefixedHexErrorInner::MissingPrefix(e)) }
}

impl From<ParseIntError> for PrefixedHexError {
fn from(e: ParseIntError) -> Self {
Self(PrefixedHexErrorInner::ParseInt(e))
}
fn from(e: ParseIntError) -> Self { Self(PrefixedHexErrorInner::ParseInt(e)) }
}

/// Error returned when parsing an integer from a hex string that is not supposed to contain a prefix.
Expand Down Expand Up @@ -381,15 +377,11 @@ impl std::error::Error for UnprefixedHexError {
}

impl From<ContainsPrefixError> for UnprefixedHexError {
fn from(e: ContainsPrefixError) -> Self {
Self(UnprefixedHexErrorInner::ContainsPrefix(e))
}
fn from(e: ContainsPrefixError) -> Self { Self(UnprefixedHexErrorInner::ContainsPrefix(e)) }
}

impl From<ParseIntError> for UnprefixedHexError {
fn from(e: ParseIntError) -> Self {
Self(UnprefixedHexErrorInner::ParseInt(e))
}
fn from(e: ParseIntError) -> Self { Self(UnprefixedHexErrorInner::ParseInt(e)) }
}

/// Error returned when a hex string is missing a prefix (e.g. `0x`).
Expand Down
6 changes: 2 additions & 4 deletions units/tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct CommonTraits {
}

/// A struct that includes all types that implement `Default`.
#[derive(Default)] // C-COMMON-TRAITS: `Default`
#[derive(Default)] // C-COMMON-TRAITS: `Default`
struct Default {
a: Amount,
b: SignedAmount,
Expand Down Expand Up @@ -196,9 +196,7 @@ fn api_can_use_all_types_from_module_locktime_relative() {

#[test]
fn api_can_use_all_types_from_module_parse() {
use bitcoin_units::parse::{
ParseIntError, PrefixedHexError, UnprefixedHexError,
};
use bitcoin_units::parse::{ParseIntError, PrefixedHexError, UnprefixedHexError};
}

#[test]
Expand Down

0 comments on commit a4ad864

Please sign in to comment.