@@ -131,58 +131,6 @@ bool WalletInit::ParameterInteraction() const
131
131
return true ;
132
132
}
133
133
134
- bool VerifyWallets (interfaces::Chain& chain, const std::vector<std::string>& wallet_files)
135
- {
136
- if (gArgs .IsArgSet (" -walletdir" )) {
137
- fs::path wallet_dir = gArgs .GetArg (" -walletdir" , " " );
138
- boost::system ::error_code error;
139
- // The canonical path cleans the path, preventing >1 Berkeley environment instances for the same directory
140
- fs::path canonical_wallet_dir = fs::canonical (wallet_dir, error);
141
- if (error || !fs::exists (wallet_dir)) {
142
- chain.initError (strprintf (_ (" Specified -walletdir \" %s\" does not exist" ), wallet_dir.string ()));
143
- return false ;
144
- } else if (!fs::is_directory (wallet_dir)) {
145
- chain.initError (strprintf (_ (" Specified -walletdir \" %s\" is not a directory" ), wallet_dir.string ()));
146
- return false ;
147
- // The canonical path transforms relative paths into absolute ones, so we check the non-canonical version
148
- } else if (!wallet_dir.is_absolute ()) {
149
- chain.initError (strprintf (_ (" Specified -walletdir \" %s\" is a relative path" ), wallet_dir.string ()));
150
- return false ;
151
- }
152
- gArgs .ForceSetArg (" -walletdir" , canonical_wallet_dir.string ());
153
- }
154
-
155
- LogPrintf (" Using wallet directory %s\n " , GetWalletDir ().string ());
156
-
157
- chain.initMessage (_ (" Verifying wallet(s)..." ));
158
-
159
- // Parameter interaction code should have thrown an error if -salvagewallet
160
- // was enabled with more than wallet file, so the wallet_files size check
161
- // here should have no effect.
162
- bool salvage_wallet = gArgs .GetBoolArg (" -salvagewallet" , false ) && wallet_files.size () <= 1 ;
163
-
164
- // Keep track of each wallet absolute path to detect duplicates.
165
- std::set<fs::path> wallet_paths;
166
-
167
- for (const auto & wallet_file : wallet_files) {
168
- WalletLocation location (wallet_file);
169
-
170
- if (!wallet_paths.insert (location.GetPath ()).second ) {
171
- chain.initError (strprintf (_ (" Error loading wallet %s. Duplicate -wallet filename specified." ), wallet_file));
172
- return false ;
173
- }
174
-
175
- std::string error_string;
176
- std::string warning_string;
177
- bool verify_success = CWallet::Verify (chain, location, salvage_wallet, error_string, warning_string);
178
- if (!error_string.empty ()) chain.initError (error_string);
179
- if (!warning_string.empty ()) chain.initWarning (warning_string);
180
- if (!verify_success) return false ;
181
- }
182
-
183
- return true ;
184
- }
185
-
186
134
void WalletInit::Construct (InitInterfaces& interfaces) const
187
135
{
188
136
if (gArgs .GetBoolArg (" -disablewallet" , DEFAULT_DISABLE_WALLET)) {
@@ -192,52 +140,3 @@ void WalletInit::Construct(InitInterfaces& interfaces) const
192
140
gArgs .SoftSetArg (" -wallet" , " " );
193
141
interfaces.chain_clients .emplace_back (interfaces::MakeWalletClient (*interfaces.chain , gArgs .GetArgs (" -wallet" )));
194
142
}
195
-
196
- bool LoadWallets (interfaces::Chain& chain, const std::vector<std::string>& wallet_files)
197
- {
198
- for (const std::string& walletFile : wallet_files) {
199
- std::shared_ptr<CWallet> pwallet = CWallet::CreateWalletFromFile (chain, WalletLocation (walletFile));
200
- if (!pwallet) {
201
- return false ;
202
- }
203
- AddWallet (pwallet);
204
- }
205
-
206
- return true ;
207
- }
208
-
209
- void StartWallets (CScheduler& scheduler)
210
- {
211
- for (const std::shared_ptr<CWallet>& pwallet : GetWallets ()) {
212
- pwallet->postInitProcess ();
213
- }
214
-
215
- // Schedule periodic wallet flushes and tx rebroadcasts
216
- scheduler.scheduleEvery (MaybeCompactWalletDB, 500 );
217
- scheduler.scheduleEvery (MaybeResendWalletTxs, 1000 );
218
- }
219
-
220
- void FlushWallets ()
221
- {
222
- for (const std::shared_ptr<CWallet>& pwallet : GetWallets ()) {
223
- pwallet->Flush (false );
224
- }
225
- }
226
-
227
- void StopWallets ()
228
- {
229
- for (const std::shared_ptr<CWallet>& pwallet : GetWallets ()) {
230
- pwallet->Flush (true );
231
- }
232
- }
233
-
234
- void UnloadWallets ()
235
- {
236
- auto wallets = GetWallets ();
237
- while (!wallets.empty ()) {
238
- auto wallet = wallets.back ();
239
- wallets.pop_back ();
240
- RemoveWallet (wallet);
241
- UnloadWallet (std::move (wallet));
242
- }
243
- }
0 commit comments