Bitcoin Core 30.99.0
P2P Digital Currency
util.h
Go to the documentation of this file.
1// Copyright (c) 2017-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_WALLET_RPC_UTIL_H
6#define BITCOIN_WALLET_RPC_UTIL_H
7
8#include <rpc/util.h>
9#include <script/script.h>
10#include <wallet/wallet.h>
11
12#include <any>
13#include <memory>
14#include <optional>
15#include <string>
16#include <string_view>
17#include <vector>
18
19class JSONRPCRequest;
20class UniValue;
21struct bilingual_str;
22
23namespace wallet {
24class LegacyScriptPubKeyMan;
25enum class DatabaseStatus;
26struct WalletContext;
27
28extern const std::string HELP_REQUIRING_PASSPHRASE;
29
30static const RPCResult RESULT_LAST_PROCESSED_BLOCK { RPCResult::Type::OBJ, "lastprocessedblock", "hash and height of the block this information was generated on",{
31 {RPCResult::Type::STR_HEX, "hash", "hash of the block this information was generated on"},
32 {RPCResult::Type::NUM, "height", "height of the block this information was generated on"}}
33};
34
41std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& request);
42bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest& request, std::string& wallet_name);
47std::string EnsureUniqueWalletName(const JSONRPCRequest& request, std::optional<std::string_view> wallet_name);
48
49void EnsureWalletIsUnlocked(const CWallet&);
50WalletContext& EnsureWalletContext(const std::any& context);
51
52bool GetAvoidReuseFlag(const CWallet& wallet, const UniValue& param);
53std::string LabelFromValue(const UniValue& value);
55void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey, UniValue& entry);
56
57void HandleWalletError(const std::shared_ptr<CWallet> wallet, DatabaseStatus& status, bilingual_str& error);
58void AppendLastProcessedBlock(UniValue& entry, const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
59} // namespace wallet
60
61#endif // BITCOIN_WALLET_RPC_UTIL_H
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:413
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
Definition: util.cpp:64
static const RPCResult RESULT_LAST_PROCESSED_BLOCK
Definition: util.h:30
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, std::string &wallet_name)
Definition: util.cpp:54
void HandleWalletError(const std::shared_ptr< CWallet > wallet, DatabaseStatus &status, bilingual_str &error)
Definition: util.cpp:127
void EnsureWalletIsUnlocked(const CWallet &wallet)
Definition: util.cpp:88
std::string EnsureUniqueWalletName(const JSONRPCRequest &request, std::optional< std::string_view > wallet_name)
Ensures that a wallet name is specified across the endpoint and wallet_name.
Definition: util.cpp:33
const std::string HELP_REQUIRING_PASSPHRASE
Definition: util.cpp:20
void PushParentDescriptors(const CWallet &wallet, const CScript &script_pubkey, UniValue &entry)
Fetch parent descriptors of this scriptPubKey.
Definition: util.cpp:115
WalletContext & EnsureWalletContext(const std::any &context)
Definition: util.cpp:95
std::string LabelFromValue(const UniValue &value)
Definition: util.cpp:104
void AppendLastProcessedBlock(UniValue &entry, const CWallet &wallet)
Definition: util.cpp:155
bool GetAvoidReuseFlag(const CWallet &wallet, const UniValue &param)
Definition: util.cpp:22
DatabaseStatus
Definition: db.h:186
@ STR_HEX
Special string with only hex chars.
Bilingual messages:
Definition: translation.h:24
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51