mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Select wallet based on the given endpoint
This commit is contained in:
parent
32c9710c50
commit
76603b1325
@ -9,6 +9,7 @@
|
|||||||
#include "consensus/validation.h"
|
#include "consensus/validation.h"
|
||||||
#include "core_io.h"
|
#include "core_io.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
#include "httpserver.h"
|
||||||
#include "validation.h"
|
#include "validation.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "policy/feerate.h"
|
#include "policy/feerate.h"
|
||||||
@ -30,10 +31,21 @@
|
|||||||
|
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
|
||||||
|
static const std::string WALLET_ENDPOINT_BASE = "/wallet/";
|
||||||
|
|
||||||
CWallet *GetWalletForJSONRPCRequest(const JSONRPCRequest& request)
|
CWallet *GetWalletForJSONRPCRequest(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
// TODO: Some way to access secondary wallets
|
if (request.URI.substr(0, WALLET_ENDPOINT_BASE.size()) == WALLET_ENDPOINT_BASE) {
|
||||||
return vpwallets.empty() ? nullptr : vpwallets[0];
|
// wallet endpoint was used
|
||||||
|
std::string requestedWallet = urlDecode(request.URI.substr(WALLET_ENDPOINT_BASE.size()));
|
||||||
|
for (CWalletRef pwallet : ::vpwallets) {
|
||||||
|
if (pwallet->GetName() == requestedWallet) {
|
||||||
|
return pwallet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Requested wallet does not exist or is not loaded");
|
||||||
|
}
|
||||||
|
return ::vpwallets.size() == 1 || (request.fHelp && ::vpwallets.size() > 0) ? ::vpwallets[0] : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string HelpRequiringPassphrase(CWallet * const pwallet)
|
std::string HelpRequiringPassphrase(CWallet * const pwallet)
|
||||||
|
Loading…
Reference in New Issue
Block a user