Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
// Copyright (c) 2010 Satoshi Nakamoto | // Copyright (c) 2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "amount.h" | #include "amount.h" | ||||
#include "chain.h" | #include "chain.h" | ||||
#include "chainparams.h" // for GetConsensus. | #include "chainparams.h" // for GetConsensus. | ||||
#include "config.h" | #include "config.h" | ||||
#include "consensus/validation.h" | #include "consensus/validation.h" | ||||
#include "core_io.h" | #include "core_io.h" | ||||
#include "dstencode.h" | #include "dstencode.h" | ||||
#include "httpserver.h" | |||||
#include "init.h" | #include "init.h" | ||||
#include "net.h" | #include "net.h" | ||||
#include "policy/fees.h" | #include "policy/fees.h" | ||||
#include "policy/policy.h" | #include "policy/policy.h" | ||||
#include "rpc/mining.h" | #include "rpc/mining.h" | ||||
#include "rpc/misc.h" | #include "rpc/misc.h" | ||||
#include "rpc/server.h" | #include "rpc/server.h" | ||||
#include "timedata.h" | #include "timedata.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "utilmoneystr.h" | #include "utilmoneystr.h" | ||||
#include "validation.h" | #include "validation.h" | ||||
#include "wallet.h" | #include "wallet.h" | ||||
#include "walletdb.h" | #include "walletdb.h" | ||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <event2/http.h> | |||||
static const std::string WALLET_ENDPOINT_BASE = "/wallet/"; | static const std::string WALLET_ENDPOINT_BASE = "/wallet/"; | ||||
static std::string urlDecode(const std::string &urlEncoded) { | |||||
std::string res; | |||||
if (!urlEncoded.empty()) { | |||||
char *decoded = evhttp_uridecode(urlEncoded.c_str(), false, nullptr); | |||||
if (decoded) { | |||||
res = std::string(decoded); | |||||
free(decoded); | |||||
} | |||||
} | |||||
return res; | |||||
} | |||||
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 (CWalletRef pwallet : ::vpwallets) { | ||||
if (pwallet->GetName() == requestedWallet) { | if (pwallet->GetName() == requestedWallet) { | ||||
▲ Show 20 Lines • Show All 3,447 Lines • Show Last 20 Lines |