File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 9
9
#include " consensus/validation.h"
10
10
#include " core_io.h"
11
11
#include " init.h"
12
+ #include " httpserver.h"
12
13
#include " validation.h"
13
14
#include " net.h"
14
15
#include " policy/feerate.h"
30
31
31
32
#include < univalue.h>
32
33
34
+ static const std::string WALLET_ENDPOINT_BASE = " /wallet/" ;
35
+
33
36
CWallet *GetWalletForJSONRPCRequest (const JSONRPCRequest& request)
34
37
{
35
- // TODO: Some way to access secondary wallets
36
- return vpwallets.empty () ? nullptr : vpwallets[0 ];
38
+ if (request.URI .substr (0 , WALLET_ENDPOINT_BASE.size ()) == WALLET_ENDPOINT_BASE) {
39
+ // wallet endpoint was used
40
+ std::string requestedWallet = urlDecode (request.URI .substr (WALLET_ENDPOINT_BASE.size ()));
41
+ for (CWalletRef pwallet : ::vpwallets) {
42
+ if (pwallet->GetName () == requestedWallet) {
43
+ return pwallet;
44
+ }
45
+ }
46
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Requested wallet does not exist or is not loaded" );
47
+ }
48
+ return ::vpwallets.size () == 1 || (request.fHelp && ::vpwallets.size () > 0 ) ? ::vpwallets[0 ] : nullptr ;
37
49
}
38
50
39
51
std::string HelpRequiringPassphrase (CWallet * const pwallet)
You can’t perform that action at this time.
0 commit comments