MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetWalletForJSONRPCRequest

Function GetWalletForJSONRPCRequest

src/wallet/rpc/util.cpp:55–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& request)
56{
57 CHECK_NONFATAL(request.mode == JSONRPCRequest::EXECUTE);
58 WalletContext& context = EnsureWalletContext(request.context);
59
60 std::string wallet_name;
61 if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) {
62 const std::shared_ptr<CWallet> pwallet = GetWallet(context, wallet_name);
63 if (!pwallet) throw JSONRPCError(RPC_WALLET_NOT_FOUND, "Requested wallet does not exist or is not loaded");
64 return pwallet;
65 }
66
67 std::vector<std::shared_ptr<CWallet>> wallets = GetWallets(context);
68 if (wallets.size() == 1) {
69 return wallets[0];
70 }
71
72 if (wallets.empty()) {
73 throw JSONRPCError(
74 RPC_WALLET_NOT_FOUND, "No wallet is loaded. Load a wallet using loadwallet or create a new one with createwallet. (Note: A default wallet is no longer automatically created)");
75 }
76 throw JSONRPCError(RPC_WALLET_NOT_SPECIFIED,
77 "Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path).");
78}
79
80void EnsureWalletIsUnlocked(const CWallet& wallet)
81{

Callers 15

getnewaddressFunction · 0.85
getrawchangeaddressFunction · 0.85
setlabelFunction · 0.85
listaddressgroupingsFunction · 0.85
addmultisigaddressFunction · 0.85
keypoolrefillFunction · 0.85
newkeypoolFunction · 0.85
getaddressinfoFunction · 0.85
getaddressesbylabelFunction · 0.85
listlabelsFunction · 0.85
walletdisplayaddressFunction · 0.85
importprivkeyFunction · 0.85

Calls 6

GetWalletFunction · 0.85
JSONRPCErrorFunction · 0.85
GetWalletsFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected