Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | if (request.URI.substr(0, WALLET_ENDPOINT_BASE.size()) == | ||||
urlDecode(request.URI.substr(WALLET_ENDPOINT_BASE.size())); | urlDecode(request.URI.substr(WALLET_ENDPOINT_BASE.size())); | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
std::shared_ptr<CWallet> | std::shared_ptr<CWallet> | ||||
GetWalletForJSONRPCRequest(const JSONRPCRequest &request) { | GetWalletForJSONRPCRequest(const JSONRPCRequest &request) { | ||||
CHECK_NONFATAL(!request.fHelp); | |||||
std::string wallet_name; | std::string wallet_name; | ||||
if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) { | if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) { | ||||
std::shared_ptr<CWallet> pwallet = GetWallet(wallet_name); | std::shared_ptr<CWallet> pwallet = GetWallet(wallet_name); | ||||
if (!pwallet) { | if (!pwallet) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_WALLET_NOT_FOUND, | RPC_WALLET_NOT_FOUND, | ||||
"Requested wallet does not exist or is not loaded"); | "Requested wallet does not exist or is not loaded"); | ||||
} | } | ||||
return pwallet; | return pwallet; | ||||
} | } | ||||
std::vector<std::shared_ptr<CWallet>> wallets = GetWallets(); | std::vector<std::shared_ptr<CWallet>> wallets = GetWallets(); | ||||
if (wallets.size() == 1 || (request.fHelp && wallets.size() > 0)) { | if (wallets.size() == 1) { | ||||
return wallets[0]; | return wallets[0]; | ||||
} | } | ||||
if (request.fHelp) { | |||||
return nullptr; | |||||
} | |||||
if (!HasWallets()) { | if (!HasWallets()) { | ||||
throw JSONRPCError(RPC_METHOD_NOT_FOUND, | throw JSONRPCError(RPC_METHOD_NOT_FOUND, | ||||
"Method not found (wallet method is disabled " | "Method not found (wallet method is disabled " | ||||
"because no wallet is loaded)"); | "because no wallet is loaded)"); | ||||
} | } | ||||
throw JSONRPCError(RPC_WALLET_NOT_SPECIFIED, | throw JSONRPCError(RPC_WALLET_NOT_SPECIFIED, | ||||
"Wallet file not specified (must request wallet RPC " | "Wallet file not specified (must request wallet RPC " | ||||
▲ Show 20 Lines • Show All 4,906 Lines • Show Last 20 Lines |