@@ -176,7 +176,7 @@ impl<K: Clone + Ord + Debug> Indexer for KeychainTxOutIndex<K> {
176
176
}
177
177
}
178
178
179
- fn apply_changeset ( & mut self , changeset : Self :: ChangeSet ) -> Result < ( ) , InsertDescriptorError > {
179
+ fn apply_changeset ( & mut self , changeset : Self :: ChangeSet ) {
180
180
self . apply_changeset ( changeset)
181
181
}
182
182
@@ -361,6 +361,23 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
361
361
keychain : K ,
362
362
descriptor : Descriptor < DescriptorPublicKey > ,
363
363
) -> Result < bool , InsertDescriptorError < K > > {
364
+ // Ensure the keys don't contain any hardened derivation steps or hardened wildcards
365
+ let descriptor_contains_hardened_steps = descriptor. for_any_key ( |k| {
366
+ if let DescriptorPublicKey :: XPub ( DescriptorXKey {
367
+ derivation_path,
368
+ wildcard,
369
+ ..
370
+ } ) = k
371
+ {
372
+ return * wildcard == Wildcard :: Hardened
373
+ || derivation_path. into_iter ( ) . any ( ChildNumber :: is_hardened) ;
374
+ }
375
+ false
376
+ } ) ;
377
+ if descriptor_contains_hardened_steps {
378
+ return Err ( InsertDescriptorError :: HardenedDerivationXpub ) ;
379
+ }
380
+ descriptor. sanity_check ( ) ?;
364
381
let did = descriptor. descriptor_id ( ) ;
365
382
if !self . keychain_to_descriptor_id . contains_key ( & keychain)
366
383
&& !self . descriptor_id_to_keychain . contains_key ( & did)
@@ -773,32 +790,12 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
773
790
}
774
791
775
792
/// Applies the `ChangeSet<K>` to the [`KeychainTxOutIndex<K>`]
776
- pub fn apply_changeset ( & mut self , changeset : ChangeSet ) -> Result < ( ) , InsertDescriptorError > {
793
+ pub fn apply_changeset ( & mut self , changeset : ChangeSet ) {
777
794
for ( & desc_id, & index) in & changeset. last_revealed {
778
- let descriptor = self . descriptors . get ( & desc_id) . expect ( "invariant" ) ;
779
- // Ensure the keys don't contain any hardened derivation steps or hardened wildcards
780
- let descriptor_contains_hardened_steps = descriptor. for_any_key ( |k| {
781
- if let DescriptorPublicKey :: XPub ( DescriptorXKey {
782
- derivation_path,
783
- wildcard,
784
- ..
785
- } ) = k
786
- {
787
- return * wildcard == Wildcard :: Hardened
788
- || derivation_path. into_iter ( ) . any ( ChildNumber :: is_hardened) ;
789
- }
790
-
791
- false
792
- } ) ;
793
- if descriptor_contains_hardened_steps {
794
- return Err ( InsertDescriptorError :: HardenedDerivationXpub ) ;
795
- }
796
- descriptor. sanity_check ( ) ?;
797
795
let v = self . last_revealed . entry ( desc_id) . or_default ( ) ;
798
796
* v = index. max ( * v) ;
799
797
self . replenish_inner_index_did ( desc_id, self . lookahead ) ;
800
798
}
801
- Ok ( ( ) )
802
799
}
803
800
}
804
801
@@ -825,7 +822,7 @@ pub enum InsertDescriptorError<K = ()> {
825
822
HardenedDerivationXpub ,
826
823
}
827
824
828
- impl From < miniscript:: Error > for InsertDescriptorError {
825
+ impl < K > From < miniscript:: Error > for InsertDescriptorError < K > {
829
826
fn from ( err : miniscript:: Error ) -> Self {
830
827
InsertDescriptorError :: Miniscript ( err)
831
828
}
0 commit comments