From c8d3b9ac1f9ec913eb30768439f0f5f4db9a02be Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Sun, 3 Mar 2024 11:30:27 +0100 Subject: [PATCH] fix formatting in big example --- examples/big.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/examples/big.rs b/examples/big.rs index 02492d00f..cf0bd099a 100644 --- a/examples/big.rs +++ b/examples/big.rs @@ -1,5 +1,5 @@ // SPDX-License-Identifier: CC0-1.0 -//! This is not an example and will surely panic if executed, the purpose of this is using the +//! This is not an example and will surely panic if executed, the purpose of this is using the //! compiled binary with tools like `cargo bloat` that cannot work with libraries. //! //! Ideal properties: @@ -9,9 +9,17 @@ //! * Use results so that calls are not stripped out. //! -use std::{collections::HashMap, str::FromStr}; +use std::collections::HashMap; +use std::str::FromStr; + use bitcoin::{ecdsa, XOnlyPublicKey}; -use miniscript::{descriptor::Wsh, policy::{Concrete, Liftable}, psbt::PsbtExt, translate_hash_fail, DefiniteDescriptorKey, Descriptor, DescriptorPublicKey, MiniscriptKey, TranslatePk, Translator}; +use miniscript::descriptor::Wsh; +use miniscript::policy::{Concrete, Liftable}; +use miniscript::psbt::PsbtExt; +use miniscript::{ + translate_hash_fail, DefiniteDescriptorKey, Descriptor, DescriptorPublicKey, MiniscriptKey, + TranslatePk, Translator, +}; use secp256k1::Secp256k1; fn main() { let empty = "".to_string(); @@ -24,7 +32,11 @@ fn main() { use_descriptor(Descriptor::::from_str(&i).unwrap()); use_descriptor(Descriptor::::from_str(&i).unwrap()); - let a = d.at_derivation_index(0).unwrap().address(bitcoin::Network::Bitcoin).unwrap(); + let a = d + .at_derivation_index(0) + .unwrap() + .address(bitcoin::Network::Bitcoin) + .unwrap(); println!("{}", a); let secp = Secp256k1::new(); @@ -51,7 +63,7 @@ fn main() { let pol = Concrete::::from_str(&i).unwrap(); let desc = pol.compile_tr(Some("UNSPENDABLE_KEY".to_string())).unwrap(); println!("{}", desc); - let pk_map =HashMap::new(); + let pk_map = HashMap::new(); let mut t = StrPkTranslator { pk_map }; let real_desc = desc.translate_pk(&mut t).unwrap(); println!("{}", real_desc); @@ -66,7 +78,6 @@ fn use_descriptor(d: Descriptor) { println!("{:?}", d.sanity_check()); } - struct StrPkTranslator { pk_map: HashMap, } @@ -79,4 +90,4 @@ impl Translator for StrPkTranslator { // We don't need to implement these methods as we are not using them in the policy. // Fail if we encounter any hash fragments. See also translate_hash_clone! macro. translate_hash_fail!(String, XOnlyPublicKey, ()); -} \ No newline at end of file +}