Skip to content

Commit 6af27b1

Browse files
committed
Run the formatter
All these issues were introduced by the `use_self` change. Fixed separately to make review of that change easier since its 12000 lines long.
1 parent 7063e4a commit 6af27b1

16 files changed

Lines changed: 67 additions & 171 deletions

File tree

src/descriptor/key.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,7 @@ impl DescriptorSecretKey {
630630
let pk = match self {
631631
Self::Single(prv) => DescriptorPublicKey::Single(prv.to_public(secp)),
632632
Self::XPrv(xprv) => DescriptorPublicKey::XPub(xprv.to_public(secp)?),
633-
Self::MultiXPrv(xprv) => {
634-
DescriptorPublicKey::MultiXPub(xprv.to_public(secp)?)
635-
}
633+
Self::MultiXPrv(xprv) => DescriptorPublicKey::MultiXPub(xprv.to_public(secp)?),
636634
};
637635

638636
Ok(pk)
@@ -851,13 +849,11 @@ impl DescriptorPublicKey {
851849
};
852850
Some(origin_path.extend(&xpub.derivation_path))
853851
}
854-
Self::Single(ref single) => {
855-
Some(if let Some((_, ref path)) = single.origin {
856-
path.clone()
857-
} else {
858-
bip32::DerivationPath::from(vec![])
859-
})
860-
}
852+
Self::Single(ref single) => Some(if let Some((_, ref path)) = single.origin {
853+
path.clone()
854+
} else {
855+
bip32::DerivationPath::from(vec![])
856+
}),
861857
Self::MultiXPub(_) => None,
862858
}
863859
}

src/descriptor/key_map.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,7 @@ impl GetKey for DescriptorSecretKey {
128128
Ok(None)
129129
}
130130
}
131-
(
132-
Self::XPrv(descriptor_xkey),
133-
ref key_request @ KeyRequest::Bip32(ref key_source),
134-
) => {
131+
(Self::XPrv(descriptor_xkey), ref key_request @ KeyRequest::Bip32(ref key_source)) => {
135132
if let Some(key) = descriptor_xkey.xkey.get_key(key_request.clone(), secp)? {
136133
return Ok(Some(key));
137134
}
@@ -152,13 +149,8 @@ impl GetKey for DescriptorSecretKey {
152149

153150
Ok(None)
154151
}
155-
(Self::XPrv(_), KeyRequest::XOnlyPubkey(_)) => {
156-
Err(GetKeyError::NotSupported)
157-
}
158-
(
159-
desc_multi_sk @ Self::MultiXPrv(_descriptor_multi_xkey),
160-
key_request,
161-
) => {
152+
(Self::XPrv(_), KeyRequest::XOnlyPubkey(_)) => Err(GetKeyError::NotSupported),
153+
(desc_multi_sk @ Self::MultiXPrv(_descriptor_multi_xkey), key_request) => {
162154
for desc_sk in &desc_multi_sk.clone().into_single_keys() {
163155
// If any key is an error, then all of them will, so here we propagate errors with ?.
164156
if let Some(pk) = desc_sk.get_key(key_request.clone(), secp)? {

src/descriptor/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,7 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
172172
/// Create a new sh for a given redeem script
173173
/// Errors when miniscript exceeds resource limits under p2sh context
174174
/// or does not type check at the top level
175-
pub fn new_sh(ms: Miniscript<Pk, Legacy>) -> Result<Self, Error> {
176-
Ok(Self::Sh(Sh::new(ms)?))
177-
}
175+
pub fn new_sh(ms: Miniscript<Pk, Legacy>) -> Result<Self, Error> { Ok(Self::Sh(Sh::new(ms)?)) }
178176

179177
/// Create a new wsh descriptor from witness script
180178
/// Errors when miniscript exceeds resource limits under p2sh context

src/descriptor/wallet_policy/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,7 @@ pub enum WalletPolicyError {
253253
}
254254

255255
impl From<WalletPolicyError> for DescriptorKeyParseError {
256-
fn from(err: WalletPolicyError) -> Self {
257-
Self::XKeyParseError(XKeyParseError::Bip388(err))
258-
}
256+
fn from(err: WalletPolicyError) -> Self { Self::XKeyParseError(XKeyParseError::Bip388(err)) }
259257
}
260258

261259
#[cfg(feature = "std")]

src/expression/error.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,7 @@ impl fmt::Display for ParseTreeError {
138138
write!(f, "expected node '{}', found '{}'", expected, actual)
139139
}
140140
}
141-
Self::IncorrectNumberOfChildren {
142-
description,
143-
n_children,
144-
minimum,
145-
maximum,
146-
} => {
141+
Self::IncorrectNumberOfChildren { description, n_children, minimum, maximum } => {
147142
write!(f, "{} must have ", description)?;
148143
match (minimum, maximum) {
149144
(_, Some(0)) => f.write_str("no children"),

src/interpreter/error.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ impl fmt::Display for Error {
128128
),
129129
Self::CannotInferTrDescriptors => write!(f, "Cannot infer taproot descriptors"),
130130
Self::ControlBlockParse(ref e) => write!(f, "Control block parse error {}", e),
131-
Self::ControlBlockVerificationError => {
132-
f.write_str("Control block verification failed")
133-
}
131+
Self::ControlBlockVerificationError => f.write_str("Control block verification failed"),
134132
Self::EcdsaSig(ref s) => write!(f, "Ecdsa sig error: {}", s),
135133
Self::ExpectedPush => f.write_str("expected push in script"),
136134
Self::CouldNotEvaluate => f.write_str("Interpreter Error: Could not evaluate"),
@@ -172,17 +170,13 @@ impl fmt::Display for Error {
172170
Self::SchnorrSig(ref s) => write!(f, "Schnorr sig error: {}", s),
173171
Self::SighashError(ref e) => fmt::Display::fmt(e, f),
174172
Self::TapAnnexUnsupported => f.write_str("Encountered annex element"),
175-
Self::UncompressedPubkey => {
176-
f.write_str("uncompressed pubkey in non-legacy descriptor")
177-
}
173+
Self::UncompressedPubkey => f.write_str("uncompressed pubkey in non-legacy descriptor"),
178174
Self::UnexpectedStackBoolean => {
179175
f.write_str("Expected Stack Push operation, found stack bool")
180176
}
181177
Self::UnexpectedStackElementPush => write!(f, "Got {}, expected Stack Boolean", 1),
182178
Self::UnexpectedStackEnd => f.write_str("unexpected end of stack"),
183-
Self::VerifyFailed => {
184-
f.write_str("Expected Satisfied Boolean at stack top for VERIFY")
185-
}
179+
Self::VerifyFailed => f.write_str("Expected Satisfied Boolean at stack top for VERIFY"),
186180
}
187181
}
188182
}

src/miniscript/decode.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,13 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Clone for Terminal<Pk, Ctx> {
184184
Self::DupIf(ref sub) => Self::DupIf(Arc::new(Miniscript::clone(sub))),
185185
Self::Verify(ref sub) => Self::Verify(Arc::new(Miniscript::clone(sub))),
186186
Self::NonZero(ref sub) => Self::NonZero(Arc::new(Miniscript::clone(sub))),
187-
Self::ZeroNotEqual(ref sub) => {
188-
Self::ZeroNotEqual(Arc::new(Miniscript::clone(sub)))
187+
Self::ZeroNotEqual(ref sub) => Self::ZeroNotEqual(Arc::new(Miniscript::clone(sub))),
188+
Self::AndV(ref left, ref right) => {
189+
Self::AndV(Arc::new(Miniscript::clone(left)), Arc::new(Miniscript::clone(right)))
190+
}
191+
Self::AndB(ref left, ref right) => {
192+
Self::AndB(Arc::new(Miniscript::clone(left)), Arc::new(Miniscript::clone(right)))
189193
}
190-
Self::AndV(ref left, ref right) => Self::AndV(
191-
Arc::new(Miniscript::clone(left)),
192-
Arc::new(Miniscript::clone(right)),
193-
),
194-
Self::AndB(ref left, ref right) => Self::AndB(
195-
Arc::new(Miniscript::clone(left)),
196-
Arc::new(Miniscript::clone(right)),
197-
),
198194
Self::AndOr(ref a, ref b, ref c) => Self::AndOr(
199195
Arc::new(Miniscript::clone(a)),
200196
Arc::new(Miniscript::clone(b)),
@@ -237,13 +233,9 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> PartialEq for Terminal<Pk, Ctx> {
237233
(Self::Ripemd160(h1), Self::Ripemd160(h2)) if h1 != h2 => return false,
238234
(Self::Hash160(h1), Self::Hash160(h2)) if h1 != h2 => return false,
239235
(Self::Multi(th1), Self::Multi(th2)) if th1 != th2 => return false,
240-
(Self::SortedMulti(th1), Self::SortedMulti(th2)) if th1 != th2 => {
241-
return false
242-
}
236+
(Self::SortedMulti(th1), Self::SortedMulti(th2)) if th1 != th2 => return false,
243237
(Self::MultiA(th1), Self::MultiA(th2)) if th1 != th2 => return false,
244-
(Self::SortedMultiA(th1), Self::SortedMultiA(th2)) if th1 != th2 => {
245-
return false
246-
}
238+
(Self::SortedMultiA(th1), Self::SortedMultiA(th2)) if th1 != th2 => return false,
247239
_ => {
248240
if mem::discriminant(me) != mem::discriminant(you) {
249241
return false;

src/miniscript/display.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
256256
Self::Swap(..) => "s",
257257
Self::Check(ref sub) if matches!(sub.as_inner(), Self::PkK(..)) => "pk",
258258
Self::Check(ref sub) if matches!(sub.as_inner(), Self::PkH(..)) => "pkh",
259-
Self::Check(ref sub) if matches!(sub.as_inner(), Self::RawPkH(..)) => {
260-
"expr_raw_pkh"
261-
}
259+
Self::Check(ref sub) if matches!(sub.as_inner(), Self::RawPkH(..)) => "expr_raw_pkh",
262260
Self::Check(..) => "c",
263261
Self::DupIf(..) => "d",
264262
Self::Verify(..) => "v",

src/miniscript/mod.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,7 @@ impl<Ctx: ScriptContext> Miniscript<Ctx::Key, Ctx> {
796796
///
797797
/// The type information and extra properties are implied by the AST.
798798
impl<Pk: MiniscriptKey, Ctx: ScriptContext> PartialOrd for Miniscript<Pk, Ctx> {
799-
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
800-
Some(self.cmp(other))
801-
}
799+
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> { Some(self.cmp(other)) }
802800
}
803801

804802
/// `Ord` of `Miniscript` must depend only on node and not the type information.
@@ -1108,14 +1106,8 @@ impl<Pk: FromStrKey, Ctx: ScriptContext> FromTree for Miniscript<Pk, Ctx> {
11081106
.verify_terminal_parent("pk_h", "public key")
11091107
.map(Self::pk_h)
11101108
.map_err(Error::Parse),
1111-
"after" => node
1112-
.verify_after()
1113-
.map(Self::after)
1114-
.map_err(Error::Parse),
1115-
"older" => node
1116-
.verify_older()
1117-
.map(Self::older)
1118-
.map_err(Error::Parse),
1109+
"after" => node.verify_after().map(Self::after).map_err(Error::Parse),
1110+
"older" => node.verify_older().map(Self::older).map_err(Error::Parse),
11191111
"sha256" => node
11201112
.verify_terminal_parent("sha256", "hash")
11211113
.map(Self::sha256)

src/miniscript/satisfy/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,7 @@ impl<Pk: MiniscriptKey + ToPublicKey> Placeholder<Pk> {
763763
Self::Hash160Preimage(h) => sat.lookup_hash160(h).map(|p| p.to_vec()),
764764
Self::Ripemd160Preimage(h) => sat.lookup_ripemd160(h).map(|p| p.to_vec()),
765765
Self::EcdsaSigPk(pk) => sat.lookup_ecdsa_sig(pk).map(|s| s.to_vec()),
766-
Self::EcdsaSigPkHash(pkh) => {
767-
sat.lookup_raw_pkh_ecdsa_sig(pkh).map(|(_, s)| s.to_vec())
768-
}
766+
Self::EcdsaSigPkHash(pkh) => sat.lookup_raw_pkh_ecdsa_sig(pkh).map(|(_, s)| s.to_vec()),
769767
Self::SchnorrSigPk(pk, SchnorrSigType::ScriptSpend { leaf_hash }, size) => sat
770768
.lookup_tap_leaf_script_sig(pk, leaf_hash)
771769
.map(|s| s.to_vec())

0 commit comments

Comments
 (0)