Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 3,951 Lines • ▼ Show 20 Lines | static UniValue unloadwallet(const Config &config, | ||||
} | } | ||||
// Release the "main" shared pointer and prevent further notifications. | // Release the "main" shared pointer and prevent further notifications. | ||||
// Note that any attempt to load the same wallet would fail until the wallet | // Note that any attempt to load the same wallet would fail until the wallet | ||||
// is destroyed (see CheckUniqueFileid). | // is destroyed (see CheckUniqueFileid). | ||||
if (!RemoveWallet(wallet)) { | if (!RemoveWallet(wallet)) { | ||||
throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded"); | throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded"); | ||||
} | } | ||||
UnregisterValidationInterface(wallet.get()); | |||||
// The wallet can be in use so it's not possible to explicitly unload here. | UnloadWallet(std::move(wallet)); | ||||
// Just notify the unload intent so that all shared pointers are released. | |||||
// The wallet will be destroyed once the last shared pointer is released. | |||||
wallet->NotifyUnload(); | |||||
// There's no point in waiting for the wallet to unload. | |||||
// At this point this method should never fail. The unloading could only | |||||
// fail due to an unexpected error which would cause a process termination. | |||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static UniValue resendwallettransactions(const Config &config, | static UniValue resendwallettransactions(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
▲ Show 20 Lines • Show All 1,571 Lines • Show Last 20 Lines |