@@ -251,15 +251,9 @@ impl<'a> ParsedPolicy<'a> {
251
251
/// - At least one of the keys is ours
252
252
/// - There are no duplicate or missing xpubs
253
253
/// - No duplicate keys in the policy
254
- fn validate ( & self , coin : BtcCoin ) -> Result < ( ) , Error > {
255
- check_enabled ( coin) ?;
256
-
254
+ fn validate ( & self ) -> Result < ( ) , Error > {
257
255
let policy = self . policy ;
258
256
259
- if policy. keys . len ( ) > MAX_KEYS {
260
- return Err ( Error :: InvalidInput ) ;
261
- }
262
-
263
257
self . validate_keys ( ) ?;
264
258
265
259
let our_root_fingerprint = crate :: keystore:: root_fingerprint ( ) ?;
@@ -368,6 +362,11 @@ impl<'a> ParsedPolicy<'a> {
368
362
/// The parsed output keeps the key strings as is (e.g. "@0/**"). They will be processed and
369
363
/// replaced with actual pubkeys in a later step.
370
364
pub fn parse ( policy : & Policy , coin : BtcCoin ) -> Result < ParsedPolicy , Error > {
365
+ check_enabled ( coin) ?;
366
+ if policy. keys . len ( ) > MAX_KEYS {
367
+ return Err ( Error :: InvalidInput ) ;
368
+ }
369
+
371
370
let desc = policy. policy . as_str ( ) ;
372
371
let parsed = match desc. as_bytes ( ) {
373
372
// Match wsh(...).
@@ -383,7 +382,7 @@ pub fn parse(policy: &Policy, coin: BtcCoin) -> Result<ParsedPolicy, Error> {
383
382
}
384
383
_ => return Err ( Error :: InvalidInput ) ,
385
384
} ;
386
- parsed. validate ( coin ) ?;
385
+ parsed. validate ( ) ?;
387
386
Ok ( parsed)
388
387
}
389
388
0 commit comments