1717//! of wsh, wpkh and sortedmulti inside wsh.
1818
1919use core:: fmt;
20- use core:: str:: FromStr ;
2120
2221use bitcoin:: { self , Address , Network , Script } ;
2322
@@ -194,13 +193,8 @@ impl<Pk: MiniscriptKey> Liftable<Pk> for Wsh<Pk> {
194193 }
195194}
196195
197- impl < Pk > FromTree for Wsh < Pk >
198- where
199- Pk : MiniscriptKey + FromStr ,
200- Pk :: Hash : FromStr ,
201- <Pk as FromStr >:: Err : ToString ,
202- <<Pk as MiniscriptKey >:: Hash as FromStr >:: Err : ToString ,
203- {
196+ impl_from_tree ! (
197+ Wsh <Pk >,
204198 fn from_tree( top: & expression:: Tree ) -> Result <Self , Error > {
205199 if top. name == "wsh" && top. args. len( ) == 1 {
206200 let top = & top. args[ 0 ] ;
@@ -222,7 +216,8 @@ where
222216 ) ) )
223217 }
224218 }
225- }
219+ ) ;
220+
226221impl < Pk : MiniscriptKey > fmt:: Debug for Wsh < Pk > {
227222 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
228223 match self . inner {
@@ -240,21 +235,15 @@ impl<Pk: MiniscriptKey> fmt::Display for Wsh<Pk> {
240235 }
241236}
242237
243- impl < Pk > FromStr for Wsh < Pk >
244- where
245- Pk : MiniscriptKey + FromStr ,
246- Pk :: Hash : FromStr ,
247- <Pk as FromStr >:: Err : ToString ,
248- <<Pk as MiniscriptKey >:: Hash as FromStr >:: Err : ToString ,
249- {
250- type Err = Error ;
251-
238+ impl_from_str ! (
239+ Wsh <Pk >,
240+ type Err = Error ; ,
252241 fn from_str( s: & str ) -> Result <Self , Self :: Err > {
253242 let desc_str = verify_checksum( s) ?;
254243 let top = expression:: Tree :: from_str( desc_str) ?;
255244 Wsh :: <Pk >:: from_tree( & top)
256245 }
257- }
246+ ) ;
258247
259248impl < Pk : MiniscriptKey > ForEachKey < Pk > for Wsh < Pk > {
260249 fn for_each_key < ' a , F : FnMut ( ForEach < ' a , Pk > ) -> bool > ( & ' a self , pred : F ) -> bool
@@ -423,13 +412,8 @@ impl<Pk: MiniscriptKey> Liftable<Pk> for Wpkh<Pk> {
423412 }
424413}
425414
426- impl < Pk > FromTree for Wpkh < Pk >
427- where
428- Pk : MiniscriptKey + FromStr ,
429- Pk :: Hash : FromStr ,
430- <Pk as FromStr >:: Err : ToString ,
431- <<Pk as MiniscriptKey >:: Hash as FromStr >:: Err : ToString ,
432- {
415+ impl_from_tree ! (
416+ Wpkh <Pk >,
433417 fn from_tree( top: & expression:: Tree ) -> Result <Self , Error > {
434418 if top. name == "wpkh" && top. args. len( ) == 1 {
435419 Ok ( Wpkh :: new( expression:: terminal( & top. args[ 0 ] , |pk| {
@@ -443,23 +427,17 @@ where
443427 ) ) )
444428 }
445429 }
446- }
447-
448- impl < Pk > FromStr for Wpkh < Pk >
449- where
450- Pk : MiniscriptKey + FromStr ,
451- Pk :: Hash : FromStr ,
452- <Pk as FromStr >:: Err : ToString ,
453- <<Pk as MiniscriptKey >:: Hash as FromStr >:: Err : ToString ,
454- {
455- type Err = Error ;
430+ ) ;
456431
432+ impl_from_str ! (
433+ Wpkh <Pk >,
434+ type Err = Error ; ,
457435 fn from_str( s: & str ) -> Result <Self , Self :: Err > {
458436 let desc_str = verify_checksum( s) ?;
459437 let top = expression:: Tree :: from_str( desc_str) ?;
460438 Self :: from_tree( & top)
461439 }
462- }
440+ ) ;
463441
464442impl < Pk : MiniscriptKey > ForEachKey < Pk > for Wpkh < Pk > {
465443 fn for_each_key < ' a , F : FnMut ( ForEach < ' a , Pk > ) -> bool > ( & ' a self , mut pred : F ) -> bool
0 commit comments