@@ -39,45 +39,24 @@ pub trait WalletSourceSync {
3939 fn sign_psbt ( & self , psbt : Psbt ) -> Result < Transaction , ( ) > ;
4040}
4141
42- /// A wrapper around [`WalletSourceSync`] to allow for async calls.
43- ///
44- /// This wrapper isn't intended to be used directly, because that would risk blocking an async context. Instead, it is
45- /// built for you in [`WalletSync::new`].
46- #[ doc( hidden) ]
4742pub ( crate ) struct WalletSourceSyncWrapper < T : Deref > ( T )
4843where
4944 T :: Target : WalletSourceSync ;
5045
51- impl < T : Deref > WalletSourceSyncWrapper < T >
52- where
53- T :: Target : WalletSourceSync ,
54- {
55- /// Creates a new [`WalletSourceSyncWrapper`].
56- pub fn new ( source : T ) -> Self {
57- Self ( source)
58- }
59- }
6046impl < T : Deref > WalletSource for WalletSourceSyncWrapper < T >
6147where
6248 T :: Target : WalletSourceSync ,
6349{
64- /// Returns all UTXOs, with at least 1 confirmation each, that are available to spend. Wraps
65- /// [`WalletSourceSync::list_confirmed_utxos`].
6650 fn list_confirmed_utxos < ' a > ( & ' a self ) -> AsyncResult < ' a , Vec < Utxo > > {
6751 let utxos = self . 0 . list_confirmed_utxos ( ) ;
6852 Box :: pin ( async move { utxos } )
6953 }
7054
71- /// Returns a script to use for change above dust resulting from a successful coin selection attempt. Wraps
72- /// [`WalletSourceSync::get_change_script`].
7355 fn get_change_script < ' a > ( & ' a self ) -> AsyncResult < ' a , ScriptBuf > {
7456 let script = self . 0 . get_change_script ( ) ;
7557 Box :: pin ( async move { script } )
7658 }
7759
78- /// Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within the transaction
79- /// known to the wallet (i.e., any provided via [`WalletSource::list_confirmed_utxos`]). Wraps
80- /// [`WalletSourceSync::sign_psbt`].
8160 fn sign_psbt < ' a > ( & ' a self , psbt : Psbt ) -> AsyncResult < ' a , Transaction > {
8261 let signed_psbt = self . 0 . sign_psbt ( psbt) ;
8362 Box :: pin ( async move { signed_psbt } )
10079{
10180 /// Constructs a new [`WalletSync`] instance.
10281 pub fn new ( source : W , logger : L ) -> Self {
103- Self { wallet : Wallet :: new ( Arc :: new ( WalletSourceSyncWrapper :: new ( source) ) , logger) }
82+ Self { wallet : Wallet :: new ( Arc :: new ( WalletSourceSyncWrapper ( source) ) , logger) }
10483 }
10584}
10685
@@ -145,8 +124,7 @@ where
145124 }
146125}
147126
148- /// A synchronous helper trait that can be used to implement [`CoinSelectionSource`] in a synchronous
149- /// context.
127+ /// A synchronous version of the [`CoinSelectionSource`] trait.
150128pub trait CoinSelectionSourceSync {
151129 /// A synchronous version of [`CoinSelectionSource::select_confirmed_utxos`].
152130 fn select_confirmed_utxos (
@@ -162,16 +140,6 @@ struct CoinSelectionSourceSyncWrapper<T: Deref>(T)
162140where
163141 T :: Target : CoinSelectionSourceSync ;
164142
165- impl < T : Deref > CoinSelectionSourceSyncWrapper < T >
166- where
167- T :: Target : CoinSelectionSourceSync ,
168- {
169- #[ allow( dead_code) ]
170- pub fn new ( source : T ) -> Self {
171- Self ( source)
172- }
173- }
174-
175143impl < T : Deref > CoinSelectionSource for CoinSelectionSourceSyncWrapper < T >
176144where
177145 T :: Target : CoinSelectionSourceSync ,
0 commit comments