MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / GetWalletForJSONRPCRequest

Function GetWalletForJSONRPCRequest

src/wallet/rpc/util.cpp:62–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& request)
63{
64 CHECK_NONFATAL(request.mode == JSONRPCRequest::EXECUTE);
65 WalletContext& context = EnsureWalletContext(request.context);
66
67 if (auto wallet_name{GetWalletNameFromJSONRPCRequest(request)}) {
68 std::shared_ptr<CWallet> pwallet{GetWallet(context, *wallet_name)};
69 if (!pwallet) throw JSONRPCError(RPC_WALLET_NOT_FOUND, "Requested wallet does not exist or is not loaded");
70 return pwallet;
71 }
72
73 size_t count{0};
74 auto wallet = GetDefaultWallet(context, count);
75 if (wallet) return wallet;
76
77 if (count == 0) {
78 throw JSONRPCError(
79 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)");
80 }
81 throw JSONRPCError(RPC_WALLET_NOT_SPECIFIED,
82 "Multiple wallets are loaded. Please select which wallet to use by requesting the RPC through the /wallet/<walletname> URI path.");
83}
84
85void EnsureWalletIsUnlocked(const CWallet& wallet)
86{

Callers 15

getnewaddressFunction · 0.85
getrawchangeaddressFunction · 0.85
setlabelFunction · 0.85
listaddressgroupingsFunction · 0.85
keypoolrefillFunction · 0.85
getaddressinfoFunction · 0.85
getaddressesbylabelFunction · 0.85
listlabelsFunction · 0.85
walletdisplayaddressFunction · 0.85
importprunedfundsFunction · 0.85
removeprunedfundsFunction · 0.85
importdescriptorsFunction · 0.85

Calls 4

GetWalletFunction · 0.85
JSONRPCErrorFunction · 0.85
GetDefaultWalletFunction · 0.85

Tested by

no test coverage detected