@@ -766,8 +766,9 @@ impl<A: Anchor> TxGraph<A> {
766766 /// Get a filtered list of outputs from the given `outpoints` that are in `chain` with
767767 /// `chain_tip`.
768768 ///
769- /// `outpoints` is a list of outpoints we are interested in, coupled with the associated txout's
770- /// script pubkey index (`S`).
769+ /// `outpoints` is a list of outpoints we are interested in, coupled with an outpoint identifier
770+ /// (`OI`) for convenience. If `OI` is not necessary, the caller can use `()`, or
771+ /// [`Iterator::enumerate`] over a list of [`OutPoint`]s.
771772 ///
772773 /// Floating outputs are ignored.
773774 ///
@@ -780,16 +781,16 @@ impl<A: Anchor> TxGraph<A> {
780781 /// instead.
781782 ///
782783 /// [`filter_chain_txouts`]: Self::filter_chain_txouts
783- pub fn try_filter_chain_txouts < ' a , C : ChainOracle + ' a , S : Clone + ' a > (
784+ pub fn try_filter_chain_txouts < ' a , C : ChainOracle + ' a , OI : Clone + ' a > (
784785 & ' a self ,
785786 chain : & ' a C ,
786787 chain_tip : BlockId ,
787- outpoints : impl IntoIterator < Item = ( S , OutPoint ) > + ' a ,
788- ) -> impl Iterator < Item = Result < ( S , FullTxOut < ObservedAs < A > > ) , C :: Error > > + ' a {
788+ outpoints : impl IntoIterator < Item = ( OI , OutPoint ) > + ' a ,
789+ ) -> impl Iterator < Item = Result < ( OI , FullTxOut < ObservedAs < A > > ) , C :: Error > > + ' a {
789790 outpoints
790791 . into_iter ( )
791792 . map (
792- move |( spk_i, op) | -> Result < Option < ( S , FullTxOut < _ > ) > , C :: Error > {
793+ move |( spk_i, op) | -> Result < Option < ( OI , FullTxOut < _ > ) > , C :: Error > {
793794 let tx_node = match self . get_tx_node ( op. txid ) {
794795 Some ( n) => n,
795796 None => return Ok ( None ) ,
@@ -831,21 +832,22 @@ impl<A: Anchor> TxGraph<A> {
831832 /// This is the infallible version of [`try_filter_chain_txouts`].
832833 ///
833834 /// [`try_filter_chain_txouts`]: Self::try_filter_chain_txouts
834- pub fn filter_chain_txouts < ' a , C : ChainOracle < Error = Infallible > + ' a , S : Clone + ' a > (
835+ pub fn filter_chain_txouts < ' a , C : ChainOracle < Error = Infallible > + ' a , OI : Clone + ' a > (
835836 & ' a self ,
836837 chain : & ' a C ,
837838 chain_tip : BlockId ,
838- outpoints : impl IntoIterator < Item = ( S , OutPoint ) > + ' a ,
839- ) -> impl Iterator < Item = ( S , FullTxOut < ObservedAs < A > > ) > + ' a {
839+ outpoints : impl IntoIterator < Item = ( OI , OutPoint ) > + ' a ,
840+ ) -> impl Iterator < Item = ( OI , FullTxOut < ObservedAs < A > > ) > + ' a {
840841 self . try_filter_chain_txouts ( chain, chain_tip, outpoints)
841842 . map ( |r| r. expect ( "oracle is infallible" ) )
842843 }
843844
844845 /// Get a filtered list of unspent outputs (UTXOs) from the given `outpoints` that are in
845846 /// `chain` with `chain_tip`.
846847 ///
847- /// `outpoints` is a list of outpoints we are interested in, coupled with the associated txout's
848- /// script pubkey index (`S`).
848+ /// `outpoints` is a list of outpoints we are interested in, coupled with an outpoint identifier
849+ /// (`OI`) for convenience. If `OI` is not necessary, the caller can use `()`, or
850+ /// [`Iterator::enumerate`] over a list of [`OutPoint`]s.
849851 ///
850852 /// Floating outputs are ignored.
851853 ///
@@ -858,12 +860,12 @@ impl<A: Anchor> TxGraph<A> {
858860 /// instead.
859861 ///
860862 /// [`filter_chain_unspents`]: Self::filter_chain_unspents
861- pub fn try_filter_chain_unspents < ' a , C : ChainOracle + ' a , S : Clone + ' a > (
863+ pub fn try_filter_chain_unspents < ' a , C : ChainOracle + ' a , OI : Clone + ' a > (
862864 & ' a self ,
863865 chain : & ' a C ,
864866 chain_tip : BlockId ,
865- outpoints : impl IntoIterator < Item = ( S , OutPoint ) > + ' a ,
866- ) -> impl Iterator < Item = Result < ( S , FullTxOut < ObservedAs < A > > ) , C :: Error > > + ' a {
867+ outpoints : impl IntoIterator < Item = ( OI , OutPoint ) > + ' a ,
868+ ) -> impl Iterator < Item = Result < ( OI , FullTxOut < ObservedAs < A > > ) , C :: Error > > + ' a {
867869 self . try_filter_chain_txouts ( chain, chain_tip, outpoints)
868870 . filter ( |r| match r {
869871 // keep unspents, drop spents
@@ -879,12 +881,12 @@ impl<A: Anchor> TxGraph<A> {
879881 /// This is the infallible version of [`try_filter_chain_unspents`].
880882 ///
881883 /// [`try_filter_chain_unspents`]: Self::try_filter_chain_unspents
882- pub fn filter_chain_unspents < ' a , C : ChainOracle < Error = Infallible > + ' a , S : Clone + ' a > (
884+ pub fn filter_chain_unspents < ' a , C : ChainOracle < Error = Infallible > + ' a , OI : Clone + ' a > (
883885 & ' a self ,
884886 chain : & ' a C ,
885887 chain_tip : BlockId ,
886- txouts : impl IntoIterator < Item = ( S , OutPoint ) > + ' a ,
887- ) -> impl Iterator < Item = ( S , FullTxOut < ObservedAs < A > > ) > + ' a {
888+ txouts : impl IntoIterator < Item = ( OI , OutPoint ) > + ' a ,
889+ ) -> impl Iterator < Item = ( OI , FullTxOut < ObservedAs < A > > ) > + ' a {
888890 self . try_filter_chain_unspents ( chain, chain_tip, txouts)
889891 . map ( |r| r. expect ( "oracle is infallible" ) )
890892 }
@@ -893,16 +895,20 @@ impl<A: Anchor> TxGraph<A> {
893895 ///
894896 /// The output of `trust_predicate` should return `true` for scripts that we trust.
895897 ///
898+ /// `outpoints` is a list of outpoints we are interested in, coupled with an outpoint identifier
899+ /// (`OI`) for convenience. If `OI` is not necessary, the caller can use `()`, or
900+ /// [`Iterator::enumerate`] over a list of [`OutPoint`]s.
901+ ///
896902 /// If the provided [`ChainOracle`] implementation (`chain`) is infallible, [`balance`] can be
897903 /// used instead.
898904 ///
899905 /// [`balance`]: Self::balance
900- pub fn try_balance < C : ChainOracle , S : Clone > (
906+ pub fn try_balance < C : ChainOracle , OI : Clone > (
901907 & self ,
902908 chain : & C ,
903909 chain_tip : BlockId ,
904- outpoints : impl IntoIterator < Item = ( S , OutPoint ) > ,
905- mut trust_predicate : impl FnMut ( & S , & Script ) -> bool ,
910+ outpoints : impl IntoIterator < Item = ( OI , OutPoint ) > ,
911+ mut trust_predicate : impl FnMut ( & OI , & Script ) -> bool ,
906912 ) -> Result < Balance , C :: Error > {
907913 let mut immature = 0 ;
908914 let mut trusted_pending = 0 ;
@@ -943,12 +949,12 @@ impl<A: Anchor> TxGraph<A> {
943949 /// This is the infallible version of [`try_balance`].
944950 ///
945951 /// [`try_balance`]: Self::try_balance
946- pub fn balance < C : ChainOracle < Error = Infallible > , S : Clone > (
952+ pub fn balance < C : ChainOracle < Error = Infallible > , OI : Clone > (
947953 & self ,
948954 chain : & C ,
949955 chain_tip : BlockId ,
950- outpoints : impl IntoIterator < Item = ( S , OutPoint ) > ,
951- trust_predicate : impl FnMut ( & S , & Script ) -> bool ,
956+ outpoints : impl IntoIterator < Item = ( OI , OutPoint ) > ,
957+ trust_predicate : impl FnMut ( & OI , & Script ) -> bool ,
952958 ) -> Balance {
953959 self . try_balance ( chain, chain_tip, outpoints, trust_predicate)
954960 . expect ( "oracle is infallible" )
0 commit comments