@@ -7,11 +7,13 @@ use crate::{
77 spk_client:: { FullScanRequestBuilder , SyncRequestBuilder } ,
88 spk_iter:: BIP32_MAX_INDEX ,
99 spk_txout:: SpkTxOutIndex ,
10- DescriptorExt , DescriptorId , Indexed , Indexer , KeychainIndexed , SpkIterator ,
10+ Anchor , CanonicalIter , CanonicalReason , ChainOracle , DescriptorExt , DescriptorId , Indexed ,
11+ Indexer , KeychainIndexed , SpkIterator ,
1112} ;
1213use alloc:: { borrow:: ToOwned , vec:: Vec } ;
1314use bitcoin:: { Amount , OutPoint , ScriptBuf , SignedAmount , Transaction , TxOut , Txid } ;
1415use core:: {
16+ convert:: Infallible ,
1517 fmt:: Debug ,
1618 ops:: { Bound , RangeBounds } ,
1719} ;
@@ -879,6 +881,20 @@ pub trait SyncRequestBuilderExt<K> {
879881
880882 /// Add [`Script`](bitcoin::Script)s that are revealed by the `indexer` but currently unused.
881883 fn unused_spks_from_indexer ( self , indexer : & KeychainTxOutIndex < K > ) -> Self ;
884+
885+ /// Add unconfirmed txids and their associated spks.
886+ ///
887+ /// We expect that the chain source should include these txids in their spk histories. If not,
888+ /// the transaction has been evicted for some reason and we will inform the receiving
889+ /// structures in the response.
890+ fn check_unconfirmed_statuses < A , C > (
891+ self ,
892+ indexer : & KeychainTxOutIndex < K > ,
893+ canonical_iter : CanonicalIter < A , C > ,
894+ ) -> Self
895+ where
896+ A : Anchor ,
897+ C : ChainOracle < Error = Infallible > ;
882898}
883899
884900impl < K : Clone + Ord + core:: fmt:: Debug > SyncRequestBuilderExt < K > for SyncRequestBuilder < ( K , u32 ) > {
@@ -892,6 +908,29 @@ impl<K: Clone + Ord + core::fmt::Debug> SyncRequestBuilderExt<K> for SyncRequest
892908 fn unused_spks_from_indexer ( self , indexer : & KeychainTxOutIndex < K > ) -> Self {
893909 self . spks_with_indexes ( indexer. unused_spks ( ) )
894910 }
911+
912+ fn check_unconfirmed_statuses < A , C > (
913+ self ,
914+ indexer : & KeychainTxOutIndex < K > ,
915+ canonical_iter : CanonicalIter < A , C > ,
916+ ) -> Self
917+ where
918+ A : Anchor ,
919+ C : ChainOracle < Error = Infallible > ,
920+ {
921+ self . expected_txs (
922+ canonical_iter
923+ . map ( |res| res. expect ( "infallible" ) )
924+ . filter ( |( _, _, reason) | matches ! ( reason, CanonicalReason :: ObservedIn { .. } ) )
925+ . flat_map ( |( txid, tx, _) | {
926+ indexer
927+ . inner
928+ . relevant_spks_of_tx ( tx. as_ref ( ) )
929+ . into_iter ( )
930+ . map ( move |spk| ( txid, spk) )
931+ } ) ,
932+ )
933+ }
895934}
896935
897936/// Trait to extend [`FullScanRequestBuilder`].
0 commit comments