Skip to content

Commit ee4564e

Browse files
committed
Run the formatter
Run `cargo +nightly fmt`, no other manual changes.
1 parent 54b2dad commit ee4564e

31 files changed

+231
-693
lines changed

bitcoind-tests/tests/test_cpp.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ where
4848
}
4949

5050
/// Quickly create a BTC amount.
51-
fn btc<F: Into<f64>>(btc: F) -> Amount {
52-
Amount::from_btc(btc.into()).unwrap()
53-
}
51+
fn btc<F: Into<f64>>(btc: F) -> Amount { Amount::from_btc(btc.into()).unwrap() }
5452

5553
// Find the Outpoint by value.
5654
// Ideally, we should find by scriptPubkey, but this
@@ -249,9 +247,7 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
249247
}
250248

251249
#[test]
252-
fn test_setup() {
253-
setup::setup();
254-
}
250+
fn test_setup() { setup::setup(); }
255251

256252
#[test]
257253
fn tests_from_cpp() {

bitcoind-tests/tests/test_desc.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ mod setup;
2525
use rand::RngCore;
2626
use setup::test_util::{self, TestData};
2727
/// Quickly create a BTC amount.
28-
fn btc<F: Into<f64>>(btc: F) -> Amount {
29-
Amount::from_btc(btc.into()).unwrap()
30-
}
28+
fn btc<F: Into<f64>>(btc: F) -> Amount { Amount::from_btc(btc.into()).unwrap() }
3129

3230
// Find the Outpoint by spk
3331
fn get_vout(cl: &Client, txid: Txid, value: u64, spk: ScriptBuf) -> (OutPoint, TxOut) {

src/descriptor/bare.rs

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,10 @@ impl<Pk: MiniscriptKey> Bare<Pk> {
4141
}
4242

4343
/// get the inner
44-
pub fn into_inner(self) -> Miniscript<Pk, BareCtx> {
45-
self.ms
46-
}
44+
pub fn into_inner(self) -> Miniscript<Pk, BareCtx> { self.ms }
4745

4846
/// get the inner
49-
pub fn as_inner(&self) -> &Miniscript<Pk, BareCtx> {
50-
&self.ms
51-
}
47+
pub fn as_inner(&self) -> &Miniscript<Pk, BareCtx> { &self.ms }
5248

5349
/// Checks whether the descriptor is safe.
5450
pub fn sanity_check(&self) -> Result<(), Error> {
@@ -94,19 +90,13 @@ impl<Pk: MiniscriptKey> Bare<Pk> {
9490

9591
impl<Pk: MiniscriptKey + ToPublicKey> Bare<Pk> {
9692
/// Obtains the corresponding script pubkey for this descriptor.
97-
pub fn script_pubkey(&self) -> ScriptBuf {
98-
self.ms.encode()
99-
}
93+
pub fn script_pubkey(&self) -> ScriptBuf { self.ms.encode() }
10094

10195
/// Obtains the underlying miniscript for this descriptor.
102-
pub fn inner_script(&self) -> ScriptBuf {
103-
self.script_pubkey()
104-
}
96+
pub fn inner_script(&self) -> ScriptBuf { self.script_pubkey() }
10597

10698
/// Obtains the pre bip-340 signature script code for this descriptor.
107-
pub fn ecdsa_sighash_script_code(&self) -> ScriptBuf {
108-
self.script_pubkey()
109-
}
99+
pub fn ecdsa_sighash_script_code(&self) -> ScriptBuf { self.script_pubkey() }
110100

111101
/// Returns satisfying non-malleable witness and scriptSig with minimum
112102
/// weight to spend an output controlled by the given descriptor if it is
@@ -136,9 +126,7 @@ impl<Pk: MiniscriptKey + ToPublicKey> Bare<Pk> {
136126
}
137127

138128
impl<Pk: MiniscriptKey> fmt::Debug for Bare<Pk> {
139-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
140-
write!(f, "{:?}", self.ms)
141-
}
129+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}", self.ms) }
142130
}
143131

144132
impl<Pk: MiniscriptKey> fmt::Display for Bare<Pk> {
@@ -151,9 +139,7 @@ impl<Pk: MiniscriptKey> fmt::Display for Bare<Pk> {
151139
}
152140

153141
impl<Pk: MiniscriptKey> Liftable<Pk> for Bare<Pk> {
154-
fn lift(&self) -> Result<semantic::Policy<Pk>, Error> {
155-
self.ms.lift()
156-
}
142+
fn lift(&self) -> Result<semantic::Policy<Pk>, Error> { self.ms.lift() }
157143
}
158144

159145
impl_from_tree!(
@@ -214,14 +200,10 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
214200
}
215201

216202
/// Get a reference to the inner key
217-
pub fn as_inner(&self) -> &Pk {
218-
&self.pk
219-
}
203+
pub fn as_inner(&self) -> &Pk { &self.pk }
220204

221205
/// Get the inner key
222-
pub fn into_inner(self) -> Pk {
223-
self.pk
224-
}
206+
pub fn into_inner(self) -> Pk { self.pk }
225207

226208
/// Computes an upper bound on the difference between a non-satisfied
227209
/// `TxIn`'s `segwit_weight` and a satisfied `TxIn`'s `segwit_weight`
@@ -250,9 +232,7 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
250232
/// Assumes all ec-signatures are 73 bytes, including push opcode and
251233
/// sighash suffix. Includes the weight of the VarInts encoding the
252234
/// scriptSig and witness stack length.
253-
pub fn max_satisfaction_weight(&self) -> usize {
254-
4 * (1 + 73 + BareCtx::pk_len(&self.pk))
255-
}
235+
pub fn max_satisfaction_weight(&self) -> usize { 4 * (1 + 73 + BareCtx::pk_len(&self.pk)) }
256236
}
257237

258238
impl<Pk: MiniscriptKey + ToPublicKey> Pkh<Pk> {
@@ -270,14 +250,10 @@ impl<Pk: MiniscriptKey + ToPublicKey> Pkh<Pk> {
270250
}
271251

272252
/// Obtains the underlying miniscript for this descriptor.
273-
pub fn inner_script(&self) -> ScriptBuf {
274-
self.script_pubkey()
275-
}
253+
pub fn inner_script(&self) -> ScriptBuf { self.script_pubkey() }
276254

277255
/// Obtains the pre bip-340 signature script code for this descriptor.
278-
pub fn ecdsa_sighash_script_code(&self) -> ScriptBuf {
279-
self.script_pubkey()
280-
}
256+
pub fn ecdsa_sighash_script_code(&self) -> ScriptBuf { self.script_pubkey() }
281257

282258
/// Returns satisfying non-malleable witness and scriptSig with minimum
283259
/// weight to spend an output controlled by the given descriptor if it is
@@ -313,9 +289,7 @@ impl<Pk: MiniscriptKey + ToPublicKey> Pkh<Pk> {
313289
}
314290

315291
impl<Pk: MiniscriptKey> fmt::Debug for Pkh<Pk> {
316-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
317-
write!(f, "pkh({:?})", self.pk)
318-
}
292+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "pkh({:?})", self.pk) }
319293
}
320294

321295
impl<Pk: MiniscriptKey> fmt::Display for Pkh<Pk> {
@@ -361,9 +335,7 @@ impl_from_str!(
361335
);
362336

363337
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Pkh<Pk> {
364-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool {
365-
pred(&self.pk)
366-
}
338+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool { pred(&self.pk) }
367339
}
368340

369341
impl<P, Q> TranslatePk<P, Q> for Pkh<P>

src/descriptor/checksum.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ pub struct Engine {
8080
}
8181

8282
impl Default for Engine {
83-
fn default() -> Engine {
84-
Engine::new()
85-
}
83+
fn default() -> Engine { Engine::new() }
8684
}
8785

8886
impl Engine {

src/descriptor/key.rs

Lines changed: 20 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,10 @@ impl DerivPaths {
8686
}
8787

8888
/// Get the list of derivation paths.
89-
pub fn paths(&self) -> &Vec<bip32::DerivationPath> {
90-
&self.0
91-
}
89+
pub fn paths(&self) -> &Vec<bip32::DerivationPath> { &self.0 }
9290

9391
/// Get the list of derivation paths.
94-
pub fn into_paths(self) -> Vec<bip32::DerivationPath> {
95-
self.0
96-
}
92+
pub fn into_paths(self) -> Vec<bip32::DerivationPath> { self.0 }
9793
}
9894

9995
/// Instance of one or more extended keys, as specified in BIP 389.
@@ -173,19 +169,15 @@ impl InnerXKey for bip32::ExtendedPubKey {
173169
self.fingerprint()
174170
}
175171

176-
fn can_derive_hardened() -> bool {
177-
false
178-
}
172+
fn can_derive_hardened() -> bool { false }
179173
}
180174

181175
impl InnerXKey for bip32::ExtendedPrivKey {
182176
fn xkey_fingerprint<C: Signing>(&self, secp: &Secp256k1<C>) -> bip32::Fingerprint {
183177
self.fingerprint(secp)
184178
}
185179

186-
fn can_derive_hardened() -> bool {
187-
true
188-
}
180+
fn can_derive_hardened() -> bool { true }
189181
}
190182

191183
/// Whether a descriptor has a wildcard in it
@@ -271,16 +263,12 @@ impl DescriptorXKey<bip32::ExtendedPrivKey> {
271263
pub struct DescriptorKeyParseError(&'static str);
272264

273265
impl fmt::Display for DescriptorKeyParseError {
274-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
275-
f.write_str(self.0)
276-
}
266+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.0) }
277267
}
278268

279269
#[cfg(feature = "std")]
280270
impl error::Error for DescriptorKeyParseError {
281-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
282-
None
283-
}
271+
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
284272
}
285273

286274
impl fmt::Display for DescriptorPublicKey {
@@ -594,9 +582,7 @@ impl DescriptorPublicKey {
594582

595583
/// Whether or not the key has a wildcard
596584
#[deprecated(note = "use has_wildcard instead")]
597-
pub fn is_deriveable(&self) -> bool {
598-
self.has_wildcard()
599-
}
585+
pub fn is_deriveable(&self) -> bool { self.has_wildcard() }
600586

601587
/// Whether or not the key has a wildcard
602588
pub fn has_wildcard(&self) -> bool {
@@ -1066,24 +1052,18 @@ impl DefiniteDescriptorKey {
10661052
}
10671053

10681054
/// The fingerprint of the master key associated with this key, `0x00000000` if none.
1069-
pub fn master_fingerprint(&self) -> bip32::Fingerprint {
1070-
self.0.master_fingerprint()
1071-
}
1055+
pub fn master_fingerprint(&self) -> bip32::Fingerprint { self.0.master_fingerprint() }
10721056

10731057
/// Full path from the master key if not a multipath extended key.
10741058
pub fn full_derivation_path(&self) -> Option<bip32::DerivationPath> {
10751059
self.0.full_derivation_path()
10761060
}
10771061

10781062
/// Reference to the underlying `DescriptorPublicKey`
1079-
pub fn as_descriptor_public_key(&self) -> &DescriptorPublicKey {
1080-
&self.0
1081-
}
1063+
pub fn as_descriptor_public_key(&self) -> &DescriptorPublicKey { &self.0 }
10821064

10831065
/// Converts the definite key into a generic one
1084-
pub fn into_descriptor_public_key(self) -> DescriptorPublicKey {
1085-
self.0
1086-
}
1066+
pub fn into_descriptor_public_key(self) -> DescriptorPublicKey { self.0 }
10871067
}
10881068

10891069
impl FromStr for DefiniteDescriptorKey {
@@ -1098,9 +1078,7 @@ impl FromStr for DefiniteDescriptorKey {
10981078
}
10991079

11001080
impl fmt::Display for DefiniteDescriptorKey {
1101-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1102-
self.0.fmt(f)
1103-
}
1081+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.0.fmt(f) }
11041082
}
11051083

11061084
impl MiniscriptKey for DefiniteDescriptorKey {
@@ -1109,17 +1087,11 @@ impl MiniscriptKey for DefiniteDescriptorKey {
11091087
type Ripemd160 = ripemd160::Hash;
11101088
type Hash160 = hash160::Hash;
11111089

1112-
fn is_uncompressed(&self) -> bool {
1113-
self.0.is_uncompressed()
1114-
}
1090+
fn is_uncompressed(&self) -> bool { self.0.is_uncompressed() }
11151091

1116-
fn is_x_only_key(&self) -> bool {
1117-
self.0.is_x_only_key()
1118-
}
1092+
fn is_x_only_key(&self) -> bool { self.0.is_x_only_key() }
11191093

1120-
fn num_der_paths(&self) -> usize {
1121-
self.0.num_der_paths()
1122-
}
1094+
fn num_der_paths(&self) -> usize { self.0.num_der_paths() }
11231095
}
11241096

11251097
impl ToPublicKey for DefiniteDescriptorKey {
@@ -1128,33 +1100,21 @@ impl ToPublicKey for DefiniteDescriptorKey {
11281100
self.derive_public_key(&secp).unwrap()
11291101
}
11301102

1131-
fn to_sha256(hash: &sha256::Hash) -> sha256::Hash {
1132-
*hash
1133-
}
1103+
fn to_sha256(hash: &sha256::Hash) -> sha256::Hash { *hash }
11341104

1135-
fn to_hash256(hash: &hash256::Hash) -> hash256::Hash {
1136-
*hash
1137-
}
1105+
fn to_hash256(hash: &hash256::Hash) -> hash256::Hash { *hash }
11381106

1139-
fn to_ripemd160(hash: &ripemd160::Hash) -> ripemd160::Hash {
1140-
*hash
1141-
}
1107+
fn to_ripemd160(hash: &ripemd160::Hash) -> ripemd160::Hash { *hash }
11421108

1143-
fn to_hash160(hash: &hash160::Hash) -> hash160::Hash {
1144-
*hash
1145-
}
1109+
fn to_hash160(hash: &hash160::Hash) -> hash160::Hash { *hash }
11461110
}
11471111

11481112
impl From<DefiniteDescriptorKey> for DescriptorPublicKey {
1149-
fn from(d: DefiniteDescriptorKey) -> Self {
1150-
d.0
1151-
}
1113+
fn from(d: DefiniteDescriptorKey) -> Self { d.0 }
11521114
}
11531115

11541116
impl Borrow<DescriptorPublicKey> for DefiniteDescriptorKey {
1155-
fn borrow(&self) -> &DescriptorPublicKey {
1156-
&self.0
1157-
}
1117+
fn borrow(&self) -> &DescriptorPublicKey { &self.0 }
11581118
}
11591119

11601120
#[cfg(feature = "serde")]

0 commit comments

Comments
 (0)