1212use std:: fmt:: { self , Display , Formatter } ;
1313use std:: str:: FromStr ;
1414
15- use amplify:: Wrapper ;
1615use bitcoin:: hashes:: Hash ;
1716use bitcoin:: schnorr:: { TweakedPublicKey , UntweakedPublicKey } ;
1817use bitcoin:: secp256k1:: { self , Secp256k1 , Verification } ;
@@ -30,9 +29,11 @@ use miniscript::descriptor::DescriptorType;
3029use miniscript:: policy:: compiler:: CompilerError ;
3130#[ cfg( feature = "miniscript" ) ]
3231use miniscript:: { Descriptor , MiniscriptKey , Terminal } ;
32+ #[ cfg( feature = "strict_encoding" ) ]
33+ use strict_encoding:: { self , StrictDecode , StrictEncode } ;
3334
3435#[ derive( Copy , Clone , Ord , PartialOrd , Eq , PartialEq , Hash , Debug ) ]
35- #[ derive( StrictEncode , StrictDecode ) ]
36+ #[ cfg_attr ( feature = "strict_encoding" , derive( StrictEncode , StrictDecode ) ) ]
3637#[ cfg_attr(
3738 feature = "serde" ,
3839 derive( Serialize , Deserialize ) ,
@@ -97,7 +98,7 @@ impl DescriptorClass {
9798#[ derive(
9899 Clone , Copy , Ord , PartialOrd , Eq , PartialEq , Hash , Default , Debug , Display
99100) ]
100- #[ derive( StrictEncode , StrictDecode ) ]
101+ #[ cfg_attr ( feature = "strict_encoding" , derive( StrictEncode , StrictDecode ) ) ]
101102#[ repr( u8 ) ]
102103pub enum SpkClass {
103104 #[ display( "bare" ) ]
@@ -203,7 +204,7 @@ impl FromStr for SpkClass {
203204 serde( crate = "serde_crate" )
204205) ]
205206#[ derive( Clone , Copy , Ord , PartialOrd , Eq , PartialEq , Hash , Debug , Display ) ]
206- #[ derive( StrictEncode , StrictDecode ) ]
207+ #[ cfg_attr ( feature = "strict_encoding" , derive( StrictEncode , StrictDecode ) ) ]
207208#[ repr( u8 ) ]
208209pub enum CompositeDescrType {
209210 #[ display( "bare" ) ]
@@ -328,7 +329,7 @@ impl FromStr for CompositeDescrType {
328329 serde( crate = "serde_crate" )
329330) ]
330331#[ derive( Clone , Copy , Ord , PartialOrd , Eq , PartialEq , Hash , Debug , Display ) ]
331- #[ derive( StrictEncode , StrictDecode ) ]
332+ #[ cfg_attr ( feature = "strict_encoding" , derive( StrictEncode , StrictDecode ) ) ]
332333#[ repr( u8 ) ]
333334pub enum OuterDescrType {
334335 #[ display( "bare" ) ]
@@ -410,8 +411,8 @@ impl FromStr for OuterDescrType {
410411 derive( Serialize , Deserialize ) ,
411412 serde( crate = "serde_crate" )
412413) ]
414+ #[ cfg_attr( feature = "strict_encoding" , derive( StrictEncode , StrictDecode ) ) ]
413415#[ derive( Clone , Copy , Ord , PartialOrd , Eq , PartialEq , Hash , Debug , Display ) ]
414- #[ derive( StrictEncode , StrictDecode ) ]
415416#[ repr( u8 ) ]
416417pub enum InnerDescrType {
417418 #[ display( "bare" ) ]
@@ -494,7 +495,7 @@ impl FromStr for InnerDescrType {
494495 serde( crate = "serde_crate" )
495496) ]
496497#[ derive( Clone , Copy , Ord , PartialOrd , Eq , PartialEq , Hash , Debug , Default ) ]
497- #[ derive( StrictEncode , StrictDecode ) ]
498+ #[ cfg_attr ( feature = "strict_encoding" , derive( StrictEncode , StrictDecode ) ) ]
498499#[ repr( C ) ]
499500pub struct DescrVariants {
500501 pub bare : bool ,
@@ -566,7 +567,7 @@ impl DescrVariants {
566567}
567568
568569#[ derive( Clone , PartialOrd , Ord , PartialEq , Eq , Hash , Debug , Display ) ]
569- #[ derive( StrictEncode , StrictDecode ) ]
570+ #[ cfg_attr ( feature = "strict_encoding" , derive( StrictEncode , StrictDecode ) ) ]
570571#[ non_exhaustive]
571572pub enum ScriptPubkeyDescr {
572573 #[ display( "bare({0})" , alt = "bare({0:#})" ) ]
@@ -663,7 +664,7 @@ impl TryFrom<PubkeyScript> for ScriptPubkeyDescr {
663664 type Error = UnsupportedScriptPubkey ;
664665
665666 fn try_from ( spk : PubkeyScript ) -> Result < Self , Self :: Error > {
666- let script = spk. as_inner ( ) ;
667+ let script = spk. clone ( ) ;
667668 let bytes = script. as_bytes ( ) ;
668669 match ( & spk, spk. witness_version ( ) ) {
669670 ( spk, _) if spk. is_p2pk ( ) && script. len ( ) == 67 => Ok ( ScriptPubkeyDescr :: Pk (
@@ -707,7 +708,7 @@ impl TryFrom<PubkeyScript> for ScriptPubkeyDescr {
707708/// Descriptors exposing bare scripts (unlike [`miniscript::Descriptor`] which
708709/// uses miniscript representation of the scripts).
709710#[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
710- #[ derive( StrictEncode , StrictDecode ) ]
711+ #[ cfg_attr ( feature = "strict_encoding" , derive( StrictEncode , StrictDecode ) ) ]
711712#[ non_exhaustive]
712713pub enum BareDescriptor {
713714 Bare ( PubkeyScript ) ,
0 commit comments