@@ -370,7 +370,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
370370 /// Return the script that exists under the given `keychain`'s `index`.
371371 ///
372372 /// This calls [`SpkTxOutIndex::spk_at_index`] internally.
373- pub fn spk_at_index ( & self , keychain : K , index : u32 ) -> Option < & Script > {
373+ pub fn spk_at_index ( & self , keychain : K , index : u32 ) -> Option < ScriptBuf > {
374374 let descriptor_id = * self . keychains_to_descriptor_ids . get ( & keychain) ?;
375375 self . inner . spk_at_index ( & ( descriptor_id, index) )
376376 }
@@ -630,7 +630,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
630630 pub fn revealed_spks (
631631 & self ,
632632 range : impl RangeBounds < K > ,
633- ) -> impl DoubleEndedIterator < Item = ( & K , u32 , & Script ) > + Clone {
633+ ) -> impl DoubleEndedIterator < Item = ( & K , u32 , ScriptBuf ) > + Clone {
634634 self . keychains_to_descriptor_ids
635635 . range ( range)
636636 . flat_map ( |( _, descriptor_id) | {
@@ -648,7 +648,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
648648 self . keychain_of_desc_id ( descriptor_id)
649649 . expect ( "must have keychain" ) ,
650650 * i,
651- spk. as_script ( ) ,
651+ spk. as_script ( ) . to_owned ( ) ,
652652 )
653653 } )
654654 } )
@@ -658,13 +658,13 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
658658 pub fn revealed_keychain_spks < ' a > (
659659 & ' a self ,
660660 keychain : & ' a K ,
661- ) -> impl DoubleEndedIterator < Item = ( u32 , & Script ) > + ' a {
661+ ) -> impl DoubleEndedIterator < Item = ( u32 , ScriptBuf ) > + ' a {
662662 self . revealed_spks ( keychain..=keychain)
663663 . map ( |( _, i, spk) | ( i, spk) )
664664 }
665665
666666 /// Iterate over revealed, but unused, spks of all keychains.
667- pub fn unused_spks ( & self ) -> impl DoubleEndedIterator < Item = ( K , u32 , & Script ) > + Clone {
667+ pub fn unused_spks ( & self ) -> impl DoubleEndedIterator < Item = ( K , u32 , ScriptBuf ) > + Clone + ' _ {
668668 self . keychains_to_descriptor_ids
669669 . keys ( )
670670 . flat_map ( |keychain| {
@@ -675,10 +675,10 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
675675
676676 /// Iterate over revealed, but unused, spks of the given `keychain`.
677677 /// Returns an empty iterator if the provided keychain doesn't exist.
678- pub fn unused_keychain_spks (
679- & self ,
678+ pub fn unused_keychain_spks < ' a > (
679+ & ' a self ,
680680 keychain : & K ,
681- ) -> impl DoubleEndedIterator < Item = ( u32 , & Script ) > + Clone {
681+ ) -> impl DoubleEndedIterator < Item = ( u32 , ScriptBuf ) > + Clone + ' a {
682682 let desc_id = self
683683 . keychains_to_descriptor_ids
684684 . get ( keychain)
@@ -909,8 +909,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
909909 let spk = self
910910 . inner
911911 . spk_at_index ( & ( descriptor_id, next_index) )
912- . expect ( "script must already be stored" )
913- . to_owned ( ) ;
912+ . expect ( "script must already be stored" ) ;
914913 ( next_index, spk)
915914 } ) ;
916915 debug_assert_eq ! ( new_spks. next( ) , None , "must only reveal one spk" ) ;
@@ -931,10 +930,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
931930 /// has used all scripts up to the derivation bounds, then the last derived script pubkey will
932931 /// be returned.
933932 pub fn next_unused_spk ( & mut self , keychain : & K ) -> ( Option < ( u32 , ScriptBuf ) > , ChangeSet < K > ) {
934- let next_unused_spk = self
935- . unused_keychain_spks ( keychain)
936- . next ( )
937- . map ( |( i, spk) | ( i, spk. to_owned ( ) ) ) ;
933+ let next_unused_spk = self . unused_keychain_spks ( keychain) . next ( ) ;
938934 if next_unused_spk. is_some ( ) {
939935 ( next_unused_spk, Default :: default ( ) )
940936 } else {
0 commit comments