@@ -331,6 +331,10 @@ pub enum Error {
331331 ///Incorrect Script pubkey Hash for the descriptor. This is used for both
332332 /// `Sh` and `Wsh` descriptors
333333 IncorrectScriptHash ,
334+ /// Recursion depth exceeded when parsing policy/miniscript from string
335+ MaxRecursiveDepthExceeded ,
336+ /// Recursion depth exceeded when parsing policy/miniscript from string
337+ ScriptSizeTooLarge ,
334338}
335339
336340#[ doc( hidden) ]
@@ -361,6 +365,11 @@ impl error::Error for Error {
361365 }
362366}
363367
368+ // https://github.com/sipa/miniscript/pull/5 for discussion on this number
369+ const MAX_RECURSION_DEPTH : u32 = 402 ;
370+ // https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki
371+ const MAX_SCRIPT_SIZE : u32 = 10000 ;
372+
364373impl fmt:: Display for Error {
365374 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
366375 match * self {
@@ -413,6 +422,12 @@ impl fmt::Display for Error {
413422 Error :: IncorrectPubkeyHash => {
414423 f. write_str ( "Incorrect pubkey hash for given descriptor pkh/wpkh" )
415424 }
425+ Error :: MaxRecursiveDepthExceeded => {
426+ write ! ( f, "Recusive depth over {} not permitted" , MAX_RECURSION_DEPTH )
427+ }
428+ Error :: ScriptSizeTooLarge => {
429+ write ! ( f, "Standardness rules imply bitcoin than {} bytes" , MAX_SCRIPT_SIZE )
430+ }
416431 }
417432 }
418433}
0 commit comments