@@ -338,7 +338,11 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
338338 } ;
339339 Ok ( ms)
340340 }
341+ }
341342
343+ impl_block_str ! (
344+ ; Ctx ; ScriptContext ,
345+ Miniscript <Pk , Ctx >,
342346 /// Attempt to parse an insane(scripts don't clear sanity checks)
343347 /// from string into a Miniscript representation.
344348 /// Use this to parse scripts with repeated pubkeys, timelock mixing, malleable
@@ -347,11 +351,6 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
347351 /// insane scripts. In general, in a multi-party setting users should only
348352 /// accept sane scripts.
349353 pub fn from_str_insane( s: & str ) -> Result <Miniscript <Pk , Ctx >, Error >
350- where
351- Pk : str:: FromStr ,
352- Pk :: Hash : str:: FromStr ,
353- <Pk as str:: FromStr >:: Err : ToString ,
354- <<Pk as MiniscriptKey >:: Hash as str:: FromStr >:: Err : ToString ,
355354 {
356355 // This checks for invalid ASCII chars
357356 let top = expression:: Tree :: from_str( s) ?;
@@ -363,7 +362,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
363362 Ok ( ms)
364363 }
365364 }
366- }
365+ ) ;
367366
368367impl < Pk : MiniscriptKey , Ctx : ScriptContext > Miniscript < Pk , Ctx > {
369368 /// Attempt to produce non-malleable satisfying witness for the
@@ -475,8 +474,7 @@ mod tests {
475474 use crate :: policy:: Liftable ;
476475 use crate :: prelude:: * ;
477476 use crate :: {
478- hex_script, DummyKey , DummyKeyHash , MiniscriptKey , Satisfier , ToPublicKey , TranslatePk ,
479- TranslatePk1 , TranslatePk2 ,
477+ hex_script, DummyKey , DummyKeyHash , Satisfier , ToPublicKey , TranslatePk , TranslatePk2 ,
480478 } ;
481479
482480 type Segwitv0Script = Miniscript < bitcoin:: PublicKey , Segwitv0 > ;
@@ -503,19 +501,11 @@ mod tests {
503501 ret
504502 }
505503
506- fn string_rtt < Pk , Ctx , Str1 , Str2 > (
507- script : Miniscript < Pk , Ctx > ,
508- expected_debug : Str1 ,
509- expected_display : Str2 ,
510- ) where
511- Pk : MiniscriptKey + str:: FromStr ,
512- Pk :: Hash : str:: FromStr ,
513- Ctx : ScriptContext ,
514- <Pk as str:: FromStr >:: Err : ToString ,
515- <<Pk as MiniscriptKey >:: Hash as str:: FromStr >:: Err : ToString ,
516- Str1 : Into < Option < & ' static str > > ,
517- Str2 : Into < Option < & ' static str > > ,
518- {
504+ fn string_rtt < Ctx : ScriptContext > (
505+ script : Miniscript < bitcoin:: PublicKey , Ctx > ,
506+ expected_debug : & str ,
507+ expected_display : & str ,
508+ ) {
519509 assert_eq ! ( script. ty. corr. base, types:: Base :: B ) ;
520510 let debug = format ! ( "{:?}" , script) ;
521511 let display = format ! ( "{}" , script) ;
@@ -527,12 +517,24 @@ mod tests {
527517 }
528518 let roundtrip = Miniscript :: from_str ( & display) . expect ( "parse string serialization" ) ;
529519 assert_eq ! ( roundtrip, script) ;
520+ }
530521
531- let translated = script. translate_pk_infallible ( Pk :: clone, Pk :: Hash :: clone) ;
532- assert_eq ! ( translated, script) ;
533-
534- let translated = script. translate_pk1_infallible ( Pk :: clone) ;
535- assert_eq ! ( translated, script) ;
522+ fn dummy_string_rtt < Ctx : ScriptContext > (
523+ script : Miniscript < DummyKey , Ctx > ,
524+ expected_debug : & str ,
525+ expected_display : & str ,
526+ ) {
527+ assert_eq ! ( script. ty. corr. base, types:: Base :: B ) ;
528+ let debug = format ! ( "{:?}" , script) ;
529+ let display = format ! ( "{}" , script) ;
530+ if let Some ( expected) = expected_debug. into ( ) {
531+ assert_eq ! ( debug, expected) ;
532+ }
533+ if let Some ( expected) = expected_display. into ( ) {
534+ assert_eq ! ( display, expected) ;
535+ }
536+ let roundtrip = Miniscript :: from_str ( & display) . expect ( "parse string serialization" ) ;
537+ assert_eq ! ( roundtrip, script) ;
536538 }
537539
538540 fn script_rtt < Str1 : Into < Option < & ' static str > > > ( script : Segwitv0Script , expected_hex : Str1 ) {
@@ -648,7 +650,7 @@ mod tests {
648650 ext : ExtData :: cast_check ( ExtData :: from_pk_k :: < Segwitv0 > ( ) ) . unwrap ( ) ,
649651 phantom : PhantomData ,
650652 } ;
651- string_rtt ( pkk_ms, "[B/onduesm]c:[K/onduesm]pk_k(DummyKey)" , "pk()" ) ;
653+ dummy_string_rtt ( pkk_ms, "[B/onduesm]c:[K/onduesm]pk_k(DummyKey)" , "pk()" ) ;
652654
653655 let pkh_ms: Miniscript < DummyKey , Segwitv0 > = Miniscript {
654656 node : Terminal :: Check ( Arc :: new ( Miniscript {
@@ -661,7 +663,7 @@ mod tests {
661663 ext : ExtData :: cast_check ( ExtData :: from_pk_h :: < Segwitv0 > ( ) ) . unwrap ( ) ,
662664 phantom : PhantomData ,
663665 } ;
664- string_rtt ( pkh_ms, "[B/nduesm]c:[K/nduesm]pk_h(DummyKeyHash)" , "pkh()" ) ;
666+ dummy_string_rtt ( pkh_ms, "[B/nduesm]c:[K/nduesm]pk_h(DummyKeyHash)" , "pkh()" ) ;
665667
666668 let pkk_ms: Segwitv0Script = Miniscript {
667669 node : Terminal :: Check ( Arc :: new ( Miniscript {
0 commit comments