2929//!
3030
3131#![ cfg_attr( all( not( feature = "std" ) , not( test) ) , no_std) ]
32-
3332// Experimental features we need.
3433#![ cfg_attr( bench, feature( test) ) ]
3534#![ cfg_attr( docsrs, feature( doc_cfg) ) ]
36-
3735// Coding conventions
3836#![ forbid( unsafe_code) ]
3937#![ deny( non_upper_case_globals) ]
@@ -55,7 +53,8 @@ compile_error!(
5553 know if you want 16-bit support. Note that we do NOT guarantee that we will implement it!"
5654) ;
5755
58- #[ cfg( bench) ] extern crate test;
56+ #[ cfg( bench) ]
57+ extern crate test;
5958
6059#[ cfg( feature = "no-std" ) ]
6160#[ macro_use]
@@ -64,9 +63,10 @@ extern crate alloc;
6463extern crate core2;
6564
6665// Re-exported dependencies.
67- #[ macro_use] pub extern crate bitcoin_hashes as hashes ;
68- pub extern crate secp256k1 ;
66+ #[ macro_use]
67+ pub extern crate bitcoin_hashes as hashes ;
6968pub extern crate bech32;
69+ pub extern crate secp256k1;
7070
7171#[ cfg( feature = "no-std" ) ]
7272extern crate hashbrown;
@@ -75,12 +75,19 @@ extern crate hashbrown;
7575#[ cfg_attr( docsrs, doc( cfg( feature = "base64" ) ) ) ]
7676pub extern crate base64;
7777
78- #[ cfg( feature="bitcoinconsensus" ) ] extern crate bitcoinconsensus;
79- #[ cfg( feature = "serde" ) ] #[ macro_use] extern crate actual_serde as serde;
80- #[ cfg( all( test, feature = "serde" ) ) ] extern crate serde_json;
81- #[ cfg( all( test, feature = "serde" ) ) ] extern crate serde_test;
82- #[ cfg( all( test, feature = "serde" ) ) ] extern crate bincode;
83- #[ cfg( all( test, feature = "unstable" ) ) ] extern crate test;
78+ #[ cfg( feature = "bitcoinconsensus" ) ]
79+ extern crate bitcoinconsensus;
80+ #[ cfg( feature = "serde" ) ]
81+ #[ macro_use]
82+ extern crate actual_serde as serde;
83+ #[ cfg( all( test, feature = "serde" ) ) ]
84+ extern crate bincode;
85+ #[ cfg( all( test, feature = "serde" ) ) ]
86+ extern crate serde_json;
87+ #[ cfg( all( test, feature = "serde" ) ) ]
88+ extern crate serde_test;
89+ #[ cfg( all( test, feature = "unstable" ) ) ]
90+ extern crate test;
8491
8592#[ cfg( test) ]
8693#[ macro_use]
@@ -93,44 +100,36 @@ mod serde_utils;
93100#[ macro_use]
94101pub mod network;
95102pub mod blockdata;
96- pub mod util;
97103pub mod consensus;
98104pub mod hash_types;
99105pub mod policy;
106+ pub mod util;
100107
101- pub use crate :: hash_types:: * ;
102- pub use crate :: blockdata:: block:: Block ;
103- pub use crate :: blockdata:: block:: BlockHeader ;
108+ #[ cfg( feature = "std" ) ]
109+ use std:: io;
110+
111+ #[ cfg( not( feature = "std" ) ) ]
112+ use core2:: io;
113+
114+ pub use crate :: blockdata:: block:: { Block , BlockHeader } ;
104115pub use crate :: blockdata:: script:: Script ;
105- pub use crate :: blockdata:: transaction:: Transaction ;
106- pub use crate :: blockdata:: transaction:: TxIn ;
107- pub use crate :: blockdata:: transaction:: Sequence ;
108- pub use crate :: blockdata:: transaction:: TxOut ;
109- pub use crate :: blockdata:: transaction:: OutPoint ;
110- pub use crate :: blockdata:: transaction:: EcdsaSighashType ;
116+ #[ allow( deprecated) ]
117+ pub use crate :: blockdata:: transaction:: SigHashType ;
118+ pub use crate :: blockdata:: transaction:: {
119+ EcdsaSighashType , OutPoint , Sequence , Transaction , TxIn , TxOut ,
120+ } ;
111121pub use crate :: blockdata:: witness:: Witness ;
112122pub use crate :: consensus:: encode:: VarInt ;
123+ pub use crate :: hash_types:: * ;
113124pub use crate :: network:: constants:: Network ;
114- pub use crate :: util:: Error ;
115- pub use crate :: util:: address:: Address ;
116- pub use crate :: util:: address:: AddressType ;
117- pub use crate :: util:: amount:: Amount ;
118- pub use crate :: util:: amount:: Denomination ;
119- pub use crate :: util:: amount:: SignedAmount ;
120- pub use crate :: util:: merkleblock:: MerkleBlock ;
121- pub use crate :: util:: sighash:: SchnorrSighashType ;
122-
125+ pub use crate :: util:: address:: { Address , AddressType } ;
126+ pub use crate :: util:: amount:: { Amount , Denomination , SignedAmount } ;
123127pub use crate :: util:: ecdsa:: { self , EcdsaSig , EcdsaSigError } ;
128+ pub use crate :: util:: key:: { KeyPair , PrivateKey , PublicKey , XOnlyPublicKey } ;
129+ pub use crate :: util:: merkleblock:: MerkleBlock ;
124130pub use crate :: util:: schnorr:: { self , SchnorrSig , SchnorrSigError } ;
125- pub use crate :: util:: key:: { PrivateKey , PublicKey , XOnlyPublicKey , KeyPair } ;
126- pub use crate :: util:: psbt;
127- #[ allow( deprecated) ]
128- pub use crate :: blockdata:: transaction:: SigHashType ;
129-
130- #[ cfg( feature = "std" ) ]
131- use std:: io;
132- #[ cfg( not( feature = "std" ) ) ]
133- use core2:: io;
131+ pub use crate :: util:: sighash:: SchnorrSighashType ;
132+ pub use crate :: util:: { psbt, Error } ;
134133
135134#[ cfg( not( feature = "std" ) ) ]
136135mod io_extras {
@@ -140,20 +139,14 @@ mod io_extras {
140139 }
141140
142141 /// Creates an instance of a writer which will successfully consume all data.
143- pub const fn sink ( ) -> Sink {
144- Sink { _priv : ( ) }
145- }
142+ pub const fn sink ( ) -> Sink { Sink { _priv : ( ) } }
146143
147144 impl core2:: io:: Write for Sink {
148145 #[ inline]
149- fn write ( & mut self , buf : & [ u8 ] ) -> core2:: io:: Result < usize > {
150- Ok ( buf. len ( ) )
151- }
146+ fn write ( & mut self , buf : & [ u8 ] ) -> core2:: io:: Result < usize > { Ok ( buf. len ( ) ) }
152147
153148 #[ inline]
154- fn flush ( & mut self ) -> core2:: io:: Result < ( ) > {
155- Ok ( ( ) )
156- }
149+ fn flush ( & mut self ) -> core2:: io:: Result < ( ) > { Ok ( ( ) ) }
157150 }
158151}
159152
@@ -184,32 +177,26 @@ mod prelude {
184177 pub use std:: collections:: HashSet ;
185178}
186179
187- #[ cfg( bench) ] use bench:: EmptyWrite ;
180+ #[ cfg( bench) ]
181+ use bench:: EmptyWrite ;
188182
189183#[ cfg( bench) ]
190184mod bench {
191185 use core:: fmt:: Arguments ;
186+
192187 use crate :: io:: { IoSlice , Result , Write } ;
193188
194189 #[ derive( Default , Clone , Debug , PartialEq , Eq ) ]
195190 pub struct EmptyWrite ;
196191
197192 impl Write for EmptyWrite {
198- fn write ( & mut self , buf : & [ u8 ] ) -> Result < usize > {
199- Ok ( buf. len ( ) )
200- }
193+ fn write ( & mut self , buf : & [ u8 ] ) -> Result < usize > { Ok ( buf. len ( ) ) }
201194 fn write_vectored ( & mut self , bufs : & [ IoSlice ] ) -> Result < usize > {
202195 Ok ( bufs. iter ( ) . map ( |s| s. len ( ) ) . sum ( ) )
203196 }
204- fn flush ( & mut self ) -> Result < ( ) > {
205- Ok ( ( ) )
206- }
197+ fn flush ( & mut self ) -> Result < ( ) > { Ok ( ( ) ) }
207198
208- fn write_all ( & mut self , _: & [ u8 ] ) -> Result < ( ) > {
209- Ok ( ( ) )
210- }
211- fn write_fmt ( & mut self , _: Arguments ) -> Result < ( ) > {
212- Ok ( ( ) )
213- }
199+ fn write_all ( & mut self , _: & [ u8 ] ) -> Result < ( ) > { Ok ( ( ) ) }
200+ fn write_fmt ( & mut self , _: Arguments ) -> Result < ( ) > { Ok ( ( ) ) }
214201 }
215202}
0 commit comments