2025-05-18 automated rustfmt nightly
This commit is contained in:
parent
e541221950
commit
d9ec934251
|
@ -23,7 +23,9 @@ impl Builder {
|
||||||
|
|
||||||
/// Constructs a new empty script builder with at least the specified capacity.
|
/// Constructs a new empty script builder with at least the specified capacity.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_capacity(capacity: usize) -> Self { Builder(ScriptBuf::with_capacity(capacity), None) }
|
pub fn with_capacity(capacity: usize) -> Self {
|
||||||
|
Builder(ScriptBuf::with_capacity(capacity), None)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the length in bytes of the script.
|
/// Returns the length in bytes of the script.
|
||||||
pub fn len(&self) -> usize { self.0.len() }
|
pub fn len(&self) -> usize { self.0.len() }
|
||||||
|
|
|
@ -16,6 +16,7 @@ use hashes::sha256d;
|
||||||
use internals::{compact_size, write_err, ToU64};
|
use internals::{compact_size, write_err, ToU64};
|
||||||
use io::{BufRead, Write};
|
use io::{BufRead, Write};
|
||||||
use primitives::Sequence;
|
use primitives::Sequence;
|
||||||
|
use units::NumOpResult;
|
||||||
|
|
||||||
use super::Weight;
|
use super::Weight;
|
||||||
use crate::consensus::{self, encode, Decodable, Encodable};
|
use crate::consensus::{self, encode, Decodable, Encodable};
|
||||||
|
@ -27,7 +28,6 @@ use crate::script::{Script, ScriptBuf, ScriptExt as _, ScriptExtPriv as _};
|
||||||
use crate::sighash::{EcdsaSighashType, TapSighashType};
|
use crate::sighash::{EcdsaSighashType, TapSighashType};
|
||||||
use crate::witness::Witness;
|
use crate::witness::Witness;
|
||||||
use crate::{Amount, FeeRate, SignedAmount};
|
use crate::{Amount, FeeRate, SignedAmount};
|
||||||
use units::NumOpResult;
|
|
||||||
|
|
||||||
#[rustfmt::skip] // Keep public re-exports separate.
|
#[rustfmt::skip] // Keep public re-exports separate.
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
|
@ -786,10 +786,7 @@ pub fn effective_value(
|
||||||
) -> NumOpResult<SignedAmount> {
|
) -> NumOpResult<SignedAmount> {
|
||||||
let weight = input_weight_prediction.total_weight();
|
let weight = input_weight_prediction.total_weight();
|
||||||
|
|
||||||
fee_rate
|
fee_rate.to_fee(weight).map(Amount::to_signed).and_then(|fee| value.to_signed() - fee) // Cannot overflow.
|
||||||
.to_fee(weight)
|
|
||||||
.map(Amount::to_signed)
|
|
||||||
.and_then(|fee| value.to_signed() - fee) // Cannot overflow.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Predicts the weight of a to-be-constructed transaction.
|
/// Predicts the weight of a to-be-constructed transaction.
|
||||||
|
@ -1943,7 +1940,7 @@ mod tests {
|
||||||
// needless_borrows_for_generic_args incorrecctly identifies &[] as a needless borrow
|
// needless_borrows_for_generic_args incorrecctly identifies &[] as a needless borrow
|
||||||
#[allow(clippy::needless_borrows_for_generic_args)]
|
#[allow(clippy::needless_borrows_for_generic_args)]
|
||||||
fn weight_prediction_new() {
|
fn weight_prediction_new() {
|
||||||
let p2wpkh_max = InputWeightPrediction::new(0, [72,33]);
|
let p2wpkh_max = InputWeightPrediction::new(0, [72, 33]);
|
||||||
assert_eq!(p2wpkh_max.script_size, 1);
|
assert_eq!(p2wpkh_max.script_size, 1);
|
||||||
assert_eq!(p2wpkh_max.witness_size, 108);
|
assert_eq!(p2wpkh_max.witness_size, 108);
|
||||||
assert_eq!(p2wpkh_max.total_weight(), Weight::from_wu(272));
|
assert_eq!(p2wpkh_max.total_weight(), Weight::from_wu(272));
|
||||||
|
|
|
@ -165,7 +165,6 @@ impl fmt::Display for AddrV2ConversionError {
|
||||||
|
|
||||||
impl std::error::Error for AddrV2ConversionError {}
|
impl std::error::Error for AddrV2ConversionError {}
|
||||||
|
|
||||||
|
|
||||||
impl From<SocketAddr> for AddrV2 {
|
impl From<SocketAddr> for AddrV2 {
|
||||||
fn from(addr: SocketAddr) -> Self {
|
fn from(addr: SocketAddr) -> Self {
|
||||||
match addr {
|
match addr {
|
||||||
|
|
|
@ -852,11 +852,11 @@ impl GetKey for $map<PublicKey, PrivateKey> {
|
||||||
KeyRequest::XOnlyPubkey(xonly) => {
|
KeyRequest::XOnlyPubkey(xonly) => {
|
||||||
let pubkey_even = xonly.public_key(secp256k1::Parity::Even);
|
let pubkey_even = xonly.public_key(secp256k1::Parity::Even);
|
||||||
let key = self.get(&pubkey_even).cloned();
|
let key = self.get(&pubkey_even).cloned();
|
||||||
|
|
||||||
if key.is_some() {
|
if key.is_some() {
|
||||||
return Ok(key);
|
return Ok(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
let pubkey_odd = xonly.public_key(secp256k1::Parity::Odd);
|
let pubkey_odd = xonly.public_key(secp256k1::Parity::Odd);
|
||||||
if let Some(priv_key) = self.get(&pubkey_odd).copied() {
|
if let Some(priv_key) = self.get(&pubkey_odd).copied() {
|
||||||
let negated_priv_key = priv_key.negate();
|
let negated_priv_key = priv_key.negate();
|
||||||
|
@ -889,18 +889,18 @@ impl GetKey for $map<XOnlyPublicKey, PrivateKey> {
|
||||||
KeyRequest::XOnlyPubkey(xonly) => Ok(self.get(xonly).cloned()),
|
KeyRequest::XOnlyPubkey(xonly) => Ok(self.get(xonly).cloned()),
|
||||||
KeyRequest::Pubkey(pk) => {
|
KeyRequest::Pubkey(pk) => {
|
||||||
let (xonly, parity) = pk.inner.x_only_public_key();
|
let (xonly, parity) = pk.inner.x_only_public_key();
|
||||||
|
|
||||||
if let Some(mut priv_key) = self.get(&XOnlyPublicKey::from(xonly)).cloned() {
|
if let Some(mut priv_key) = self.get(&XOnlyPublicKey::from(xonly)).cloned() {
|
||||||
let computed_pk = priv_key.public_key(&secp);
|
let computed_pk = priv_key.public_key(&secp);
|
||||||
let (_, computed_parity) = computed_pk.inner.x_only_public_key();
|
let (_, computed_parity) = computed_pk.inner.x_only_public_key();
|
||||||
|
|
||||||
if computed_parity != parity {
|
if computed_parity != parity {
|
||||||
priv_key = priv_key.negate();
|
priv_key = priv_key.negate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(Some(priv_key));
|
return Ok(Some(priv_key));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
},
|
},
|
||||||
KeyRequest::Bip32(_) => Err(GetKeyError::NotSupported),
|
KeyRequest::Bip32(_) => Err(GetKeyError::NotSupported),
|
||||||
|
|
|
@ -161,7 +161,7 @@ crate::internal_macros::impl_op_for_references! {
|
||||||
|
|
||||||
impl ops::Div<NonZeroU64> for FeeRate {
|
impl ops::Div<NonZeroU64> for FeeRate {
|
||||||
type Output = FeeRate;
|
type Output = FeeRate;
|
||||||
|
|
||||||
fn div(self, rhs: NonZeroU64) -> Self::Output{ Self::from_sat_per_kwu(self.to_sat_per_kwu() / rhs.get()) }
|
fn div(self, rhs: NonZeroU64) -> Self::Output{ Self::from_sat_per_kwu(self.to_sat_per_kwu() / rhs.get()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,9 +204,10 @@ impl<'a> Arbitrary<'a> for FeeRate {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use core::num::NonZeroU64;
|
use core::num::NonZeroU64;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sanity_check() {
|
fn sanity_check() {
|
||||||
let fee_rate: u64 = u64::from(FeeRate::from_sat_per_kwu(100));
|
let fee_rate: u64 = u64::from(FeeRate::from_sat_per_kwu(100));
|
||||||
|
|
|
@ -88,7 +88,6 @@ pub enum NumOpResult<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> NumOpResult<T> {
|
impl<T> NumOpResult<T> {
|
||||||
|
|
||||||
/// Maps a `NumOpResult<T>` to `NumOpResult<U>` by applying a function to a
|
/// Maps a `NumOpResult<T>` to `NumOpResult<U>` by applying a function to a
|
||||||
/// contained [`NumOpResult::Valid`] value, leaving a [`NumOpResult::Error`] value untouched.
|
/// contained [`NumOpResult::Valid`] value, leaving a [`NumOpResult::Error`] value untouched.
|
||||||
///
|
///
|
||||||
|
|
|
@ -293,9 +293,10 @@ impl<'a> Arbitrary<'a> for Weight {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use core::num::NonZeroU64;
|
use core::num::NonZeroU64;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
const ONE: Weight = Weight::from_wu(1);
|
const ONE: Weight = Weight::from_wu(1);
|
||||||
const TWO: Weight = Weight::from_wu(2);
|
const TWO: Weight = Weight::from_wu(2);
|
||||||
const FOUR: Weight = Weight::from_wu(4);
|
const FOUR: Weight = Weight::from_wu(4);
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
use bitcoin_units::locktime::{absolute, relative};
|
use bitcoin_units::locktime::{absolute, relative};
|
||||||
use bitcoin_units::{amount, fee_rate, Amount, BlockHeight, BlockInterval, FeeRate, SignedAmount, Weight};
|
use bitcoin_units::{
|
||||||
|
amount, fee_rate, Amount, BlockHeight, BlockInterval, FeeRate, SignedAmount, Weight,
|
||||||
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A struct that includes all the types that implement or support `serde` traits.
|
/// A struct that includes all the types that implement or support `serde` traits.
|
||||||
|
|
Loading…
Reference in New Issue