Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | GetWalletForJSONRPCRequest(const JSONRPCRequest &request) { | ||||
std::vector<std::shared_ptr<CWallet>> wallets = GetWallets(); | std::vector<std::shared_ptr<CWallet>> wallets = GetWallets(); | ||||
return wallets.size() == 1 || (request.fHelp && wallets.size() > 0) | return wallets.size() == 1 || (request.fHelp && wallets.size() > 0) | ||||
? wallets[0] | ? wallets[0] | ||||
: nullptr; | : nullptr; | ||||
} | } | ||||
std::string HelpRequiringPassphrase(CWallet *const pwallet) { | std::string HelpRequiringPassphrase(CWallet *const pwallet) { | ||||
return pwallet && pwallet->IsCrypted() ? "\nRequires wallet passphrase to " | return pwallet && pwallet->IsCrypted() | ||||
"be set with walletpassphrase " | ? "\nRequires wallet passphrase to be set with walletpassphrase " | ||||
"call." | "call." | ||||
: ""; | : ""; | ||||
} | } | ||||
bool EnsureWalletIsAvailable(CWallet *const pwallet, bool avoidException) { | bool EnsureWalletIsAvailable(CWallet *const pwallet, bool avoidException) { | ||||
if (pwallet) { | if (pwallet) { | ||||
return true; | return true; | ||||
} | } | ||||
if (avoidException) { | if (avoidException) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!HasWallets()) { | if (!HasWallets()) { | ||||
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (wallet " | throw JSONRPCError(RPC_METHOD_NOT_FOUND, | ||||
"method is disabled because " | "Method not found (wallet method is disabled " | ||||
"no wallet is loaded)"); | "because no wallet is loaded)"); | ||||
} | } | ||||
throw JSONRPCError(RPC_WALLET_NOT_SPECIFIED, | throw JSONRPCError(RPC_WALLET_NOT_SPECIFIED, | ||||
"Wallet file not specified (must request wallet RPC " | "Wallet file not specified (must request wallet RPC " | ||||
"through /wallet/<filename> uri-path)."); | "through /wallet/<filename> uri-path)."); | ||||
} | } | ||||
void EnsureWalletIsUnlocked(CWallet *const pwallet) { | void EnsureWalletIsUnlocked(CWallet *const pwallet) { | ||||
if (pwallet->IsLocked()) { | if (pwallet->IsLocked()) { | ||||
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the " | throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, | ||||
"wallet passphrase with " | "Error: Please enter the wallet passphrase with " | ||||
"walletpassphrase first."); | "walletpassphrase first."); | ||||
} | } | ||||
} | } | ||||
static void WalletTxToJSON(const CWalletTx &wtx, UniValue &entry) | static void WalletTxToJSON(const CWalletTx &wtx, UniValue &entry) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||||
int confirms = wtx.GetDepthInMainChain(); | int confirms = wtx.GetDepthInMainChain(); | ||||
entry.pushKV("confirmations", confirms); | entry.pushKV("confirmations", confirms); | ||||
if (wtx.IsCoinBase()) { | if (wtx.IsCoinBase()) { | ||||
▲ Show 20 Lines • Show All 5,331 Lines • Show Last 20 Lines |