@@ -39,45 +39,24 @@ pub trait WalletSourceSync {
39
39
fn sign_psbt ( & self , psbt : Psbt ) -> Result < Transaction , ( ) > ;
40
40
}
41
41
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) ]
47
42
pub ( crate ) struct WalletSourceSyncWrapper < T : Deref > ( T )
48
43
where
49
44
T :: Target : WalletSourceSync ;
50
45
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
- }
60
46
impl < T : Deref > WalletSource for WalletSourceSyncWrapper < T >
61
47
where
62
48
T :: Target : WalletSourceSync ,
63
49
{
64
- /// Returns all UTXOs, with at least 1 confirmation each, that are available to spend. Wraps
65
- /// [`WalletSourceSync::list_confirmed_utxos`].
66
50
fn list_confirmed_utxos < ' a > ( & ' a self ) -> AsyncResult < ' a , Vec < Utxo > > {
67
51
let utxos = self . 0 . list_confirmed_utxos ( ) ;
68
52
Box :: pin ( async move { utxos } )
69
53
}
70
54
71
- /// Returns a script to use for change above dust resulting from a successful coin selection attempt. Wraps
72
- /// [`WalletSourceSync::get_change_script`].
73
55
fn get_change_script < ' a > ( & ' a self ) -> AsyncResult < ' a , ScriptBuf > {
74
56
let script = self . 0 . get_change_script ( ) ;
75
57
Box :: pin ( async move { script } )
76
58
}
77
59
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`].
81
60
fn sign_psbt < ' a > ( & ' a self , psbt : Psbt ) -> AsyncResult < ' a , Transaction > {
82
61
let signed_psbt = self . 0 . sign_psbt ( psbt) ;
83
62
Box :: pin ( async move { signed_psbt } )
100
79
{
101
80
/// Constructs a new [`WalletSync`] instance.
102
81
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) }
104
83
}
105
84
}
106
85
@@ -145,8 +124,7 @@ where
145
124
}
146
125
}
147
126
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.
150
128
pub trait CoinSelectionSourceSync {
151
129
/// A synchronous version of [`CoinSelectionSource::select_confirmed_utxos`].
152
130
fn select_confirmed_utxos (
@@ -162,16 +140,6 @@ struct CoinSelectionSourceSyncWrapper<T: Deref>(T)
162
140
where
163
141
T :: Target : CoinSelectionSourceSync ;
164
142
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
-
175
143
impl < T : Deref > CoinSelectionSource for CoinSelectionSourceSyncWrapper < T >
176
144
where
177
145
T :: Target : CoinSelectionSourceSync ,
0 commit comments