Skip to content

Commit 26bb52e

Browse files
committed
Set struct_lit_width to 80
Set `rustfmt` config option `struct_lit_width` to true and run the formatter.
1 parent ced7d77 commit 26bb52e

28 files changed

+171
-657
lines changed

bitcoind-tests/tests/setup/test_util.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,7 @@ impl TestData {
108108
let ripemd160_pre = [0x78 as u8; 32];
109109
let ripemd160 = ripemd160::Hash::hash(&ripemd160_pre);
110110

111-
let pubdata = PubData {
112-
pks,
113-
sha256,
114-
hash256,
115-
ripemd160,
116-
hash160,
117-
x_only_pks,
118-
};
111+
let pubdata = PubData { pks, sha256, hash256, ripemd160, hash160, x_only_pks };
119112
let secretdata = SecretData {
120113
sks,
121114
sha256_pre,
@@ -124,10 +117,7 @@ impl TestData {
124117
hash160_pre,
125118
x_only_keypairs,
126119
};
127-
Self {
128-
pubdata,
129-
secretdata,
130-
}
120+
Self { pubdata, secretdata }
131121
}
132122
}
133123

bitcoind-tests/tests/test_cpp.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
132132
.get_new_address(None, Some(json::AddressType::Bech32))
133133
.unwrap()
134134
.assume_checked();
135-
psbt.unsigned_tx.output.push(TxOut {
136-
value: 99_999_000,
137-
script_pubkey: addr.script_pubkey(),
138-
});
135+
psbt.unsigned_tx
136+
.output
137+
.push(TxOut { value: 99_999_000, script_pubkey: addr.script_pubkey() });
139138
let mut input = psbt::Input::default();
140139
input.witness_utxo = Some(witness_utxo);
141140
input.witness_script = Some(desc.explicit_script().unwrap());
@@ -179,13 +178,9 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
179178
for sk in sks_reqd {
180179
let sig = secp.sign_ecdsa(&msg, &sk);
181180
let pk = pks[sks.iter().position(|&x| x == sk).unwrap()];
182-
psbts[i].inputs[0].partial_sigs.insert(
183-
pk,
184-
bitcoin::ecdsa::Signature {
185-
sig,
186-
hash_ty: sighash_ty,
187-
},
188-
);
181+
psbts[i].inputs[0]
182+
.partial_sigs
183+
.insert(pk, bitcoin::ecdsa::Signature { sig, hash_ty: sighash_ty });
189184
}
190185
// Add the hash preimages to the psbt
191186
psbts[i].inputs[0]

bitcoind-tests/tests/test_desc.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,9 @@ pub fn test_desc_satisfy(
135135
.assume_checked();
136136
// Had to decrease 'value', so that fees can be increased
137137
// (Was getting insufficient fees error, for deep script trees)
138-
psbt.unsigned_tx.output.push(TxOut {
139-
value: 99_997_000,
140-
script_pubkey: addr.script_pubkey(),
141-
});
138+
psbt.unsigned_tx
139+
.output
140+
.push(TxOut { value: 99_997_000, script_pubkey: addr.script_pubkey() });
142141
let mut input = psbt::Input::default();
143142
input
144143
.update_with_descriptor_unchecked(&definite_desc)
@@ -178,10 +177,8 @@ pub fn test_desc_satisfy(
178177
rand::thread_rng().fill_bytes(&mut aux_rand);
179178
let schnorr_sig =
180179
secp.sign_schnorr_with_aux_rand(&msg, &internal_keypair, &aux_rand);
181-
psbt.inputs[0].tap_key_sig = Some(taproot::Signature {
182-
sig: schnorr_sig,
183-
hash_ty: hash_ty,
184-
});
180+
psbt.inputs[0].tap_key_sig =
181+
Some(taproot::Signature { sig: schnorr_sig, hash_ty: hash_ty });
185182
} else {
186183
// No internal key
187184
}
@@ -206,13 +203,9 @@ pub fn test_desc_satisfy(
206203
let sig = secp.sign_schnorr_with_aux_rand(&msg, &keypair, &aux_rand);
207204
let x_only_pk =
208205
x_only_pks[xonly_keypairs.iter().position(|&x| x == keypair).unwrap()];
209-
psbt.inputs[0].tap_script_sigs.insert(
210-
(x_only_pk, leaf_hash),
211-
taproot::Signature {
212-
sig,
213-
hash_ty: hash_ty,
214-
},
215-
);
206+
psbt.inputs[0]
207+
.tap_script_sigs
208+
.insert((x_only_pk, leaf_hash), taproot::Signature { sig, hash_ty: hash_ty });
216209
}
217210
}
218211
_ => {
@@ -261,13 +254,9 @@ pub fn test_desc_satisfy(
261254
let sig = secp.sign_ecdsa(&msg, &sk);
262255
let pk = pks[sks.iter().position(|&x| x == sk).unwrap()];
263256
assert!(secp.verify_ecdsa(&msg, &sig, &pk.inner).is_ok());
264-
psbt.inputs[0].partial_sigs.insert(
265-
pk,
266-
ecdsa::Signature {
267-
sig,
268-
hash_ty: hash_ty,
269-
},
270-
);
257+
psbt.inputs[0]
258+
.partial_sigs
259+
.insert(pk, ecdsa::Signature { sig, hash_ty: hash_ty });
271260
}
272261
}
273262
}

examples/psbt_sign_finalize.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,13 @@ fn main() {
8686
txin.sequence = Sequence::from_height(26); //Sequence::MAX; //
8787
psbt.unsigned_tx.input.push(txin);
8888

89-
psbt.unsigned_tx.output.push(TxOut {
90-
script_pubkey: receiver.script_pubkey(),
91-
value: amount / 5 - 500,
92-
});
89+
psbt.unsigned_tx
90+
.output
91+
.push(TxOut { script_pubkey: receiver.script_pubkey(), value: amount / 5 - 500 });
9392

94-
psbt.unsigned_tx.output.push(TxOut {
95-
script_pubkey: bridge_descriptor.script_pubkey(),
96-
value: amount * 4 / 5,
97-
});
93+
psbt.unsigned_tx
94+
.output
95+
.push(TxOut { script_pubkey: bridge_descriptor.script_pubkey(), value: amount * 4 / 5 });
9896

9997
// Generating signatures & witness data
10098

@@ -130,13 +128,9 @@ fn main() {
130128
let pk2 = backup2_private.public_key(&secp256k1);
131129
assert!(secp256k1.verify_ecdsa(&msg, &sig2, &pk2.inner).is_ok());
132130

133-
psbt.inputs[0].partial_sigs.insert(
134-
pk1,
135-
bitcoin::ecdsa::Signature {
136-
sig: sig1,
137-
hash_ty: hash_ty,
138-
},
139-
);
131+
psbt.inputs[0]
132+
.partial_sigs
133+
.insert(pk1, bitcoin::ecdsa::Signature { sig: sig1, hash_ty: hash_ty });
140134

141135
println!("{:#?}", psbt);
142136

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ indent_style = "Block"
66
use_small_heuristics = "Default"
77
fn_call_width = 80
88
attr_fn_like_width = 70
9-
struct_lit_width = 18
9+
struct_lit_width = 80
1010
struct_variant_width = 35
1111
array_width = 60
1212
chain_width = 60

src/descriptor/bare.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,7 @@ impl Pkh<DefiniteDescriptorKey> {
333333
Witness::Unavailable
334334
};
335335

336-
Satisfaction {
337-
stack,
338-
has_sig: true,
339-
relative_timelock: None,
340-
absolute_timelock: None,
341-
}
336+
Satisfaction { stack, has_sig: true, relative_timelock: None, absolute_timelock: None }
342337
}
343338

344339
/// Returns a plan if the provided assets are sufficient to produce a malleable satisfaction

src/descriptor/checksum.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,7 @@ impl Default for Engine {
8585

8686
impl Engine {
8787
/// Construct an engine with no input
88-
pub fn new() -> Self {
89-
Engine {
90-
c: 1,
91-
cls: 0,
92-
clscount: 0,
93-
}
94-
}
88+
pub fn new() -> Self { Engine { c: 1, cls: 0, clscount: 0 } }
9589

9690
/// Checksum some data
9791
///
@@ -148,12 +142,7 @@ pub struct Formatter<'f, 'a> {
148142

149143
impl<'f, 'a> Formatter<'f, 'a> {
150144
/// Contruct a new `Formatter`, wrapping a given `fmt::Formatter`
151-
pub fn new(f: &'f mut fmt::Formatter<'a>) -> Self {
152-
Formatter {
153-
fmt: f,
154-
eng: Engine::new(),
155-
}
156-
}
145+
pub fn new(f: &'f mut fmt::Formatter<'a>) -> Self { Formatter { fmt: f, eng: Engine::new() } }
157146

158147
/// Writes the checksum into the underlying `fmt::Formatter`
159148
pub fn write_checksum(&mut self) -> fmt::Result {

src/descriptor/key.rs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,7 @@ impl SinglePriv {
196196
fn to_public<C: Signing>(&self, secp: &Secp256k1<C>) -> SinglePub {
197197
let pub_key = self.key.public_key(secp);
198198

199-
SinglePub {
200-
origin: self.origin.clone(),
201-
key: SinglePubKey::FullKey(pub_key),
202-
}
199+
SinglePub { origin: self.origin.clone(), key: SinglePubKey::FullKey(pub_key) }
203200
}
204201
}
205202

@@ -351,12 +348,7 @@ impl DescriptorSecretKey {
351348
match self {
352349
DescriptorSecretKey::Single(..) | DescriptorSecretKey::XPrv(..) => vec![self],
353350
DescriptorSecretKey::MultiXPrv(xpub) => {
354-
let DescriptorMultiXKey {
355-
origin,
356-
xkey,
357-
derivation_paths,
358-
wildcard,
359-
} = xpub;
351+
let DescriptorMultiXKey { origin, xkey, derivation_paths, wildcard } = xpub;
360352
derivation_paths
361353
.into_paths()
362354
.into_iter()
@@ -686,12 +678,7 @@ impl DescriptorPublicKey {
686678
match self {
687679
DescriptorPublicKey::Single(..) | DescriptorPublicKey::XPub(..) => vec![self],
688680
DescriptorPublicKey::MultiXPub(xpub) => {
689-
let DescriptorMultiXKey {
690-
origin,
691-
xkey,
692-
derivation_paths,
693-
wildcard,
694-
} = xpub;
681+
let DescriptorMultiXKey { origin, xkey, derivation_paths, wildcard } = xpub;
695682
derivation_paths
696683
.into_paths()
697684
.into_iter()
@@ -718,10 +705,7 @@ impl FromStr for DescriptorSecretKey {
718705
if key_part.len() <= 52 {
719706
let sk = bitcoin::PrivateKey::from_str(key_part)
720707
.map_err(|_| DescriptorKeyParseError("Error while parsing a WIF private key"))?;
721-
Ok(DescriptorSecretKey::Single(SinglePriv {
722-
key: sk,
723-
origin: None,
724-
}))
708+
Ok(DescriptorSecretKey::Single(SinglePriv { key: sk, origin: None }))
725709
} else {
726710
let (xpriv, derivation_paths, wildcard) =
727711
parse_xkey_deriv::<bip32::ExtendedPrivKey>(key_part)?;
@@ -998,8 +982,7 @@ impl MiniscriptKey for DescriptorPublicKey {
998982
fn is_uncompressed(&self) -> bool {
999983
match self {
1000984
DescriptorPublicKey::Single(SinglePub {
1001-
key: SinglePubKey::FullKey(ref key),
1002-
..
985+
key: SinglePubKey::FullKey(ref key), ..
1003986
}) => key.is_uncompressed(),
1004987
_ => false,
1005988
}
@@ -1008,10 +991,7 @@ impl MiniscriptKey for DescriptorPublicKey {
1008991
fn is_x_only_key(&self) -> bool {
1009992
matches!(
1010993
self,
1011-
DescriptorPublicKey::Single(SinglePub {
1012-
key: SinglePubKey::XOnly(ref _key),
1013-
..
1014-
})
994+
DescriptorPublicKey::Single(SinglePub { key: SinglePubKey::XOnly(ref _key), .. })
1015995
)
1016996
}
1017997

src/descriptor/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,17 +1523,11 @@ mod tests {
15231523

15241524
satisfier.insert(
15251525
a,
1526-
bitcoin::ecdsa::Signature {
1527-
sig: sig_a,
1528-
hash_ty: EcdsaSighashType::All,
1529-
},
1526+
bitcoin::ecdsa::Signature { sig: sig_a, hash_ty: EcdsaSighashType::All },
15301527
);
15311528
satisfier.insert(
15321529
b,
1533-
bitcoin::ecdsa::Signature {
1534-
sig: sig_b,
1535-
hash_ty: EcdsaSighashType::All,
1536-
},
1530+
bitcoin::ecdsa::Signature { sig: sig_b, hash_ty: EcdsaSighashType::All },
15371531
);
15381532

15391533
satisfier

src/descriptor/segwitv0.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,14 @@ impl<Pk: MiniscriptKey> Wsh<Pk> {
4141
pub fn new(ms: Miniscript<Pk, Segwitv0>) -> Result<Self, Error> {
4242
// do the top-level checks
4343
Segwitv0::top_level_checks(&ms)?;
44-
Ok(Self {
45-
inner: WshInner::Ms(ms),
46-
})
44+
Ok(Self { inner: WshInner::Ms(ms) })
4745
}
4846

4947
/// Create a new sortedmulti wsh descriptor
5048
pub fn new_sortedmulti(k: usize, pks: Vec<Pk>) -> Result<Self, Error> {
5149
// The context checks will be carried out inside new function for
5250
// sortedMultiVec
53-
Ok(Self {
54-
inner: WshInner::SortedMulti(SortedMultiVec::new(k, pks)?),
55-
})
51+
Ok(Self { inner: WshInner::SortedMulti(SortedMultiVec::new(k, pks)?) })
5652
}
5753

5854
/// Get the descriptor without the checksum
@@ -238,15 +234,11 @@ impl_from_tree!(
238234
if top.name == "wsh" && top.args.len() == 1 {
239235
let top = &top.args[0];
240236
if top.name == "sortedmulti" {
241-
return Ok(Wsh {
242-
inner: WshInner::SortedMulti(SortedMultiVec::from_tree(top)?),
243-
});
237+
return Ok(Wsh { inner: WshInner::SortedMulti(SortedMultiVec::from_tree(top)?) });
244238
}
245239
let sub = Miniscript::from_tree(top)?;
246240
Segwitv0::top_level_checks(&sub)?;
247-
Ok(Wsh {
248-
inner: WshInner::Ms(sub),
249-
})
241+
Ok(Wsh { inner: WshInner::Ms(sub) })
250242
} else {
251243
Err(Error::Unexpected(format!(
252244
"{}({} args) while parsing wsh descriptor",
@@ -448,12 +440,7 @@ impl Wpkh<DefiniteDescriptorKey> {
448440
Witness::Unavailable
449441
};
450442

451-
Satisfaction {
452-
stack,
453-
has_sig: true,
454-
relative_timelock: None,
455-
absolute_timelock: None,
456-
}
443+
Satisfaction { stack, has_sig: true, relative_timelock: None, absolute_timelock: None }
457444
}
458445

459446
/// Returns a plan if the provided assets are sufficient to produce a malleable satisfaction

0 commit comments

Comments
 (0)