File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -384,6 +384,27 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
384384 ) ) ,
385385 }
386386 }
387+
388+ /// Whether the descriptor is safe
389+ /// Checks whether all the spend paths in the descriptor are possible
390+ /// on the bitcoin network under the current standardness and consensus rules
391+ /// Also checks whether the descriptor requires signauture on all spend paths
392+ /// And whether the script is malleable.
393+ /// In general, all the guarantees of miniscript hold only for safe scripts.
394+ /// All the analysis gurantees of miniscript only hold safe scripts.
395+ /// The signer may not be able to find satisfactions even if one exists
396+ pub fn check_safety ( & self ) -> Result < ( ) , Error > {
397+ match * self {
398+ Descriptor :: Bare ( ref ms) => ms. check_safety ( ) ?,
399+ Descriptor :: Pk ( ref _pk)
400+ | Descriptor :: Pkh ( ref _pk)
401+ | Descriptor :: Wpkh ( ref _pk)
402+ | Descriptor :: ShWpkh ( ref _pk) => { }
403+ Descriptor :: Wsh ( ref ms) | Descriptor :: ShWsh ( ref ms) => ms. check_safety ( ) ?,
404+ Descriptor :: Sh ( ref ms) => ms. check_safety ( ) ?,
405+ }
406+ Ok ( ( ) )
407+ }
387408}
388409
389410impl < Pk : MiniscriptKey + ToPublicKey > Descriptor < Pk > {
You can’t perform that action at this time.
0 commit comments