Merge rust-bitcoin/rust-bitcoin#3432: fmt: Use style_edition = 2021
323e706113
Add rustfmt config option style_edition (Tobin C. Harding)2e4179ed0f
Run the formatter (Tobin C. Harding)2c40b4f4ec
Configure formmater to skip read_compact_size (Tobin C. Harding) Pull request description: `rustfmt` is emitting: Warning: the `version` option is deprecated. Use `style_edition` instead. As suggested add a config option and set it to 2021. - Patch 1: Manually configure rustfmt to skip some code - Patch 2: Run the formmater with current configuration - Patch 3: Add the new config option (remove old one), introduces no new formatting requirements ACKs for top commit: apoelstra: ACK323e706113
successfully ran local tests Tree-SHA512: 7f80cc89f86d2d50936e51704344955fa00532424c29c0ee3fae1a6836e24030f909b770d28da13e1c5efde3d49ad7d52c6d909d120fb09c33abf1755f62cd38
This commit is contained in:
commit
03715872cd
|
@ -297,7 +297,8 @@ fn generate_bip86_key_spend_tx(
|
|||
.get(&input.tap_internal_key.ok_or("internal key missing in PSBT")?)
|
||||
.ok_or("missing Taproot key origin")?;
|
||||
|
||||
let secret_key = master_xpriv.derive_xpriv(secp, &derivation_path).to_private_key().inner;
|
||||
let secret_key =
|
||||
master_xpriv.derive_xpriv(secp, &derivation_path).to_private_key().inner;
|
||||
sign_psbt_taproot(
|
||||
secret_key,
|
||||
input.tap_internal_key.unwrap(),
|
||||
|
@ -484,8 +485,10 @@ impl BenefactorWallet {
|
|||
.master_xpriv
|
||||
.derive_xpriv(&self.secp, &new_derivation_path)
|
||||
.to_keypair(&self.secp);
|
||||
let beneficiary_key =
|
||||
self.beneficiary_xpub.derive_xpub(&self.secp, &new_derivation_path)?.to_x_only_public_key();
|
||||
let beneficiary_key = self
|
||||
.beneficiary_xpub
|
||||
.derive_xpub(&self.secp, &new_derivation_path)?
|
||||
.to_x_only_public_key();
|
||||
|
||||
// Build up the leaf script and combine with internal key into a Taproot commitment
|
||||
let lock_time = absolute::LockTime::from_height(
|
||||
|
@ -530,8 +533,11 @@ impl BenefactorWallet {
|
|||
.tap_key_origins
|
||||
.get(&input.tap_internal_key.ok_or("internal key missing in PSBT")?)
|
||||
.ok_or("missing Taproot key origin")?;
|
||||
let secret_key =
|
||||
self.master_xpriv.derive_xpriv(&self.secp, &derivation_path).to_private_key().inner;
|
||||
let secret_key = self
|
||||
.master_xpriv
|
||||
.derive_xpriv(&self.secp, &derivation_path)
|
||||
.to_private_key()
|
||||
.inner;
|
||||
sign_psbt_taproot(
|
||||
secret_key,
|
||||
spend_info.internal_key(),
|
||||
|
|
|
@ -12,7 +12,7 @@ use hashes::{sha256, siphash24};
|
|||
use internals::{impl_array_newtype, ToU64 as _};
|
||||
use io::{BufRead, Write};
|
||||
|
||||
use crate::consensus::encode::{self, Decodable, Encodable, WriteExt, ReadExt};
|
||||
use crate::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
|
||||
use crate::internal_macros::{impl_array_newtype_stringify, impl_consensus_encoding};
|
||||
use crate::prelude::Vec;
|
||||
use crate::transaction::TxIdentifier;
|
||||
|
|
|
@ -593,9 +593,7 @@ impl Xpriv {
|
|||
|
||||
/// Constructs ECDSA compressed private key matching internal secret key representation.
|
||||
#[deprecated(since = "TBD", note = "use `to_private_key()`")]
|
||||
pub fn to_priv(self) -> PrivateKey {
|
||||
self.to_private_key()
|
||||
}
|
||||
pub fn to_priv(self) -> PrivateKey { self.to_private_key() }
|
||||
|
||||
/// Constructs ECDSA compressed private key matching internal secret key representation.
|
||||
pub fn to_private_key(self) -> PrivateKey {
|
||||
|
@ -603,7 +601,7 @@ impl Xpriv {
|
|||
}
|
||||
|
||||
/// Creates new extended public key from this extended private key.
|
||||
pub fn to_xpub<C: secp256k1::Signing>(&self, secp: &Secp256k1<C>,) -> Xpub {
|
||||
pub fn to_xpub<C: secp256k1::Signing>(&self, secp: &Secp256k1<C>) -> Xpub {
|
||||
Xpub::from_xpriv(secp, self)
|
||||
}
|
||||
|
||||
|
@ -775,7 +773,6 @@ impl Xpub {
|
|||
secp: &Secp256k1<C>,
|
||||
path: &P,
|
||||
) -> Result<Xpub, Error> {
|
||||
|
||||
self.derive_xpub(secp, path)
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ crate::internal_macros::define_extension_trait! {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Bitcoin transaction input.
|
||||
///
|
||||
/// It contains the location of the previous transaction's output,
|
||||
|
@ -1267,13 +1266,16 @@ impl InputWeightPrediction {
|
|||
T: IntoIterator,
|
||||
T::Item: Borrow<usize>,
|
||||
{
|
||||
let (count, total_size) =
|
||||
witness_element_lengths.into_iter().fold((0usize, 0), |(count, total_size), elem_len| {
|
||||
let (count, total_size) = witness_element_lengths.into_iter().fold(
|
||||
(0usize, 0),
|
||||
|(count, total_size), elem_len| {
|
||||
let elem_len = *elem_len.borrow();
|
||||
let elem_size = elem_len + compact_size::encoded_size(elem_len);
|
||||
(count + 1, total_size + elem_size)
|
||||
});
|
||||
let witness_size = if count > 0 { total_size + compact_size::encoded_size(count) } else { 0 };
|
||||
},
|
||||
);
|
||||
let witness_size =
|
||||
if count > 0 { total_size + compact_size::encoded_size(count) } else { 0 };
|
||||
let script_size = input_script_len + compact_size::encoded_size(input_script_len);
|
||||
|
||||
InputWeightPrediction { script_size, witness_size }
|
||||
|
@ -1299,7 +1301,8 @@ impl InputWeightPrediction {
|
|||
} else {
|
||||
0
|
||||
};
|
||||
let script_size = input_script_len + compact_size::encoded_size_const(input_script_len as u64);
|
||||
let script_size =
|
||||
input_script_len + compact_size::encoded_size_const(input_script_len as u64);
|
||||
|
||||
InputWeightPrediction { script_size, witness_size }
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use arbitrary::{Arbitrary, Unstructured};
|
|||
use internals::compact_size;
|
||||
use io::{BufRead, Write};
|
||||
|
||||
use crate::consensus::encode::{self, Error, MAX_VEC_SIZE, ReadExt, WriteExt};
|
||||
use crate::consensus::encode::{self, Error, ReadExt, WriteExt, MAX_VEC_SIZE};
|
||||
use crate::consensus::{Decodable, Encodable};
|
||||
use crate::crypto::ecdsa;
|
||||
use crate::prelude::Vec;
|
||||
|
@ -185,7 +185,8 @@ impl Decodable for Witness {
|
|||
encode_cursor(&mut content, 0, i, cursor - witness_index_space);
|
||||
|
||||
resize_if_needed(&mut content, required_len);
|
||||
cursor += (&mut content[cursor..cursor + element_size_len]).emit_compact_size(element_size)?;
|
||||
cursor += (&mut content[cursor..cursor + element_size_len])
|
||||
.emit_compact_size(element_size)?;
|
||||
r.read_exact(&mut content[cursor..cursor + element_size])?;
|
||||
cursor += element_size;
|
||||
}
|
||||
|
@ -629,7 +630,7 @@ mod test {
|
|||
use hex::test_hex_unwrap as hex;
|
||||
|
||||
use super::*;
|
||||
use crate::consensus::{encode, deserialize, serialize};
|
||||
use crate::consensus::{deserialize, encode, serialize};
|
||||
use crate::hex::DisplayHex;
|
||||
use crate::sighash::EcdsaSighashType;
|
||||
use crate::Transaction;
|
||||
|
@ -649,11 +650,7 @@ mod test {
|
|||
// The last four bytes represent start at index 0.
|
||||
let content = [0_u8; 5];
|
||||
|
||||
Witness {
|
||||
witness_elements: 1,
|
||||
content: content.to_vec(),
|
||||
indices_start: 1,
|
||||
}
|
||||
Witness { witness_elements: 1, content: content.to_vec(), indices_start: 1 }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -960,7 +957,6 @@ mod test {
|
|||
let ser = serde_json::to_string(&original).unwrap();
|
||||
let rinsed: Witness = serde_json::from_str(&ser).unwrap();
|
||||
assert_eq!(rinsed, original);
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -323,6 +323,7 @@ impl<R: Read + ?Sized> ReadExt for R {
|
|||
self.read_exact(slice).map_err(Error::Io)
|
||||
}
|
||||
#[inline]
|
||||
#[rustfmt::skip] // Formatter munges code comments below.
|
||||
fn read_compact_size(&mut self) -> Result<u64, Error> {
|
||||
match self.read_u8()? {
|
||||
0xFF => {
|
||||
|
@ -492,9 +493,7 @@ pub const fn varint_size_u64(v: u64) -> usize {
|
|||
|
||||
/// Returns 1 for 0..=0xFC, 3 for 0xFD..=(2^16-1), 5 for 0x10000..=(2^32-1), and 9 otherwise.
|
||||
#[inline]
|
||||
pub fn varint_size(v: impl ToU64) -> usize {
|
||||
varint_size_u64(v.to_u64())
|
||||
}
|
||||
pub fn varint_size(v: impl ToU64) -> usize { varint_size_u64(v.to_u64()) }
|
||||
|
||||
impl Encodable for bool {
|
||||
#[inline]
|
||||
|
@ -935,14 +934,8 @@ mod tests {
|
|||
assert_eq!(encode(0xFD), [0xFDu8, 0xFD, 0]);
|
||||
assert_eq!(encode(0xFFF), [0xFDu8, 0xFF, 0xF]);
|
||||
assert_eq!(encode(0xF0F0F0F), [0xFEu8, 0xF, 0xF, 0xF, 0xF]);
|
||||
assert_eq!(
|
||||
encode(0xF0F0F0F0F0E0),
|
||||
vec![0xFFu8, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0, 0],
|
||||
);
|
||||
assert_eq!(
|
||||
test_varint_encode(0xFF, &0x100000000_u64.to_le_bytes()).unwrap(),
|
||||
0x100000000,
|
||||
);
|
||||
assert_eq!(encode(0xF0F0F0F0F0E0), vec![0xFFu8, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0, 0],);
|
||||
assert_eq!(test_varint_encode(0xFF, &0x100000000_u64.to_le_bytes()).unwrap(), 0x100000000,);
|
||||
assert_eq!(test_varint_encode(0xFE, &0x10000_u64.to_le_bytes()).unwrap(), 0x10000);
|
||||
assert_eq!(test_varint_encode(0xFD, &0xFD_u64.to_le_bytes()).unwrap(), 0xFD);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use io::{BufRead, Write};
|
|||
|
||||
use self::MerkleBlockError::*;
|
||||
use crate::block::{self, Block};
|
||||
use crate::consensus::encode::{self, Decodable, Encodable, MAX_VEC_SIZE, WriteExt, ReadExt};
|
||||
use crate::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt, MAX_VEC_SIZE};
|
||||
use crate::merkle_tree::{MerkleNode as _, TxMerkleNode};
|
||||
use crate::prelude::Vec;
|
||||
use crate::transaction::{Transaction, Txid};
|
||||
|
|
|
@ -11,7 +11,7 @@ use hashes::sha256d;
|
|||
use internals::ToU64 as _;
|
||||
use io::{BufRead, Write};
|
||||
|
||||
use crate::consensus::encode::{self, CheckedData, Decodable, Encodable, WriteExt, ReadExt};
|
||||
use crate::consensus::encode::{self, CheckedData, Decodable, Encodable, ReadExt, WriteExt};
|
||||
use crate::merkle_tree::MerkleBlock;
|
||||
use crate::p2p::address::{AddrV2Message, Address};
|
||||
use crate::p2p::{
|
||||
|
|
|
@ -29,9 +29,7 @@ const MAX_ENCODING_SIZE: usize = 9;
|
|||
/// - 5 for 0x10000..=(2^32-1)
|
||||
/// - 9 otherwise.
|
||||
#[inline]
|
||||
pub fn encoded_size(value: impl ToU64) -> usize {
|
||||
encoded_size_const(value.to_u64())
|
||||
}
|
||||
pub fn encoded_size(value: impl ToU64) -> usize { encoded_size_const(value.to_u64()) }
|
||||
|
||||
/// Returns the number of bytes used to encode this `CompactSize` value (in const context).
|
||||
///
|
||||
|
|
|
@ -32,8 +32,8 @@ extern crate serde;
|
|||
pub mod block;
|
||||
#[cfg(feature = "alloc")]
|
||||
pub mod locktime;
|
||||
pub mod opcodes;
|
||||
pub mod merkle_tree;
|
||||
pub mod opcodes;
|
||||
pub mod pow;
|
||||
pub mod sequence;
|
||||
pub mod transaction;
|
||||
|
|
|
@ -197,10 +197,7 @@ impl fmt::Display for Version {
|
|||
#[cfg(feature = "arbitrary")]
|
||||
impl<'a> Arbitrary<'a> for OutPoint {
|
||||
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
|
||||
Ok(OutPoint{
|
||||
txid: Txid::arbitrary(u)?,
|
||||
vout: u32::arbitrary(u)?
|
||||
})
|
||||
Ok(OutPoint { txid: Txid::arbitrary(u)?, vout: u32::arbitrary(u)? })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ match_block_trailing_comma = false
|
|||
blank_lines_upper_bound = 1
|
||||
blank_lines_lower_bound = 0
|
||||
edition = "2021"
|
||||
version = "One"
|
||||
style_edition = "2021"
|
||||
inline_attribute_width = 0
|
||||
format_generated_files = true
|
||||
merge_derives = true
|
||||
|
|
Loading…
Reference in New Issue