Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (!urlEncoded.empty()) { | ||||
if (decoded) { | if (decoded) { | ||||
res = std::string(decoded); | res = std::string(decoded); | ||||
free(decoded); | free(decoded); | ||||
} | } | ||||
} | } | ||||
return res; | return res; | ||||
} | } | ||||
std::shared_ptr<CWallet> | bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, | ||||
GetWalletForJSONRPCRequest(const JSONRPCRequest &request) { | std::string &wallet_name) { | ||||
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 = | wallet_name = | ||||
urlDecode(request.URI.substr(WALLET_ENDPOINT_BASE.size())); | urlDecode(request.URI.substr(WALLET_ENDPOINT_BASE.size())); | ||||
std::shared_ptr<CWallet> pwallet = GetWallet(requestedWallet); | return true; | ||||
} | |||||
return false; | |||||
} | |||||
std::shared_ptr<CWallet> | |||||
GetWalletForJSONRPCRequest(const JSONRPCRequest &request) { | |||||
std::string wallet_name; | |||||
if (GetWalletNameFromJSONRPCRequest(request, 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; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 4,521 Lines • Show Last 20 Lines |