Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
CWallet *GetWalletForJSONRPCRequest(const JSONRPCRequest &request) { | CWallet *GetWalletForJSONRPCRequest(const JSONRPCRequest &request) { | ||||
if (request.URI.substr(0, WALLET_ENDPOINT_BASE.size()) == | if (request.URI.substr(0, WALLET_ENDPOINT_BASE.size()) == | ||||
WALLET_ENDPOINT_BASE) { | WALLET_ENDPOINT_BASE) { | ||||
// wallet endpoint was used | // wallet endpoint was used | ||||
std::string requestedWallet = | std::string requestedWallet = | ||||
urlDecode(request.URI.substr(WALLET_ENDPOINT_BASE.size())); | urlDecode(request.URI.substr(WALLET_ENDPOINT_BASE.size())); | ||||
for (CWalletRef pwallet : ::vpwallets) { | for (CWallet *pwallet : ::vpwallets) { | ||||
if (pwallet->GetName() == requestedWallet) { | if (pwallet->GetName() == requestedWallet) { | ||||
return pwallet; | return pwallet; | ||||
} | } | ||||
} | } | ||||
throw JSONRPCError(RPC_WALLET_NOT_FOUND, | throw JSONRPCError(RPC_WALLET_NOT_FOUND, | ||||
"Requested wallet does not exist or is not loaded"); | "Requested wallet does not exist or is not loaded"); | ||||
} | } | ||||
return ::vpwallets.size() == 1 || (request.fHelp && ::vpwallets.size() > 0) | return ::vpwallets.size() == 1 || (request.fHelp && ::vpwallets.size() > 0) | ||||
▲ Show 20 Lines • Show All 3,196 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 0) { | ||||
"]\n" | "]\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("listwallets", "") + | HelpExampleCli("listwallets", "") + | ||||
HelpExampleRpc("listwallets", "")); | HelpExampleRpc("listwallets", "")); | ||||
} | } | ||||
UniValue obj(UniValue::VARR); | UniValue obj(UniValue::VARR); | ||||
for (CWalletRef pwallet : vpwallets) { | for (CWallet *pwallet : vpwallets) { | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
obj.push_back(pwallet->GetName()); | obj.push_back(pwallet->GetName()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,017 Lines • Show Last 20 Lines |