mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-19 05:45:05 +01:00
Merge #18241: wallet/refactor: refer to CWallet immutably when possible
79facb11e9
wallet: use constant CWallets in rpcwallet.cpp (Karl-Johan Alm)d9b0ebc1da
wallet: make ReserveDestination pwallet ivar const (Karl-Johan Alm)57c569e4d9
wallet: make BackupWallet() const (Karl-Johan Alm)df3a818d2a
wallet: make getters const (Karl-Johan Alm)227b9dd2d6
wallet/spkm: make GetOldestKeyPoolTime() const (Karl-Johan Alm)22d329ad0e
wallet: use constant CWallets in rpcdump.cpp (Karl-Johan Alm)7b3587b29d
wallet/db: make IsDummy() const (Karl-Johan Alm)d366795d18
wallet/db: make Backup() const (Karl-Johan Alm)8cd0b86340
wallet: make CanGetAddresses() const (Karl-Johan Alm)037fa770eb
wallet: make KeypoolCountExternalKeys() const (Karl-Johan Alm)ddc93557ad
wallet: make CanGenerateKeys() const (Karl-Johan Alm)dc2d0650fd
make BlockUntilSyncedToCurrentChain() const (Karl-Johan Alm) Pull request description: A lot of places refer to `CWallet*`'s as `CWallet * const`, which translates to *"an immutable pointer to a mutable `CWallet` instance"*; this is 1. often not what the author meant, especially as a lot of these places do not at all modify the wallet object, and 2. confusing, as it tends to suggest that this is a proper way to refer to a constant `CWallet` instance. This PR changes references to wallets to `const CWallet* const` whenever immutability is expected. This should result in no behavioral changes at all, and improved compile-time error checking. Note from irc: > <sipa> sounds good to me; this is the sort of change that as long as it compiles, the behavior shouldn't change > <sipa> though in general it may lead to introducing automatic copying of objects sometimes (e.g. trying to std::move a const object will work, but generally result in a copy rather than an efficient move) > <sipa> CWallet objects aren't copied or moved though ACKs for top commit: laanwj: ACK79facb11e9
Empact: ACK79facb11e9
promag: ACK79facb11e9
. fjahr: ACK79facb11e9
Tree-SHA512: 80a80c1a52f0f788d0ccb268b53bc0f46c796643a3c5a22b55bbbde4ffa6c7e347784e5e53b1e488a3b4e14399e31d5be9417ad5b6319c74a462609e9b1a98e8
This commit is contained in:
commit
4d80274b99
@ -270,7 +270,7 @@ void BaseIndex::ChainStateFlushed(const CBlockLocator& locator)
|
||||
Commit();
|
||||
}
|
||||
|
||||
bool BaseIndex::BlockUntilSyncedToCurrentChain()
|
||||
bool BaseIndex::BlockUntilSyncedToCurrentChain() const
|
||||
{
|
||||
AssertLockNotHeld(cs_main);
|
||||
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
/// sync once and only needs to process blocks in the ValidationInterface
|
||||
/// queue. If the index is catching up from far behind, this method does
|
||||
/// not block and immediately returns false.
|
||||
bool BlockUntilSyncedToCurrentChain();
|
||||
bool BlockUntilSyncedToCurrentChain() const;
|
||||
|
||||
void Interrupt();
|
||||
|
||||
|
@ -468,7 +468,7 @@ public:
|
||||
}
|
||||
unsigned int getConfirmTarget() override { return m_wallet->m_confirm_target; }
|
||||
bool hdEnabled() override { return m_wallet->IsHDEnabled(); }
|
||||
bool canGetAddresses() override { return m_wallet->CanGetAddresses(); }
|
||||
bool canGetAddresses() const override { return m_wallet->CanGetAddresses(); }
|
||||
bool IsWalletFlagSet(uint64_t flag) override { return m_wallet->IsWalletFlagSet(flag); }
|
||||
OutputType getDefaultAddressType() override { return m_wallet->m_default_address_type; }
|
||||
OutputType getDefaultChangeType() override { return m_wallet->m_default_change_type; }
|
||||
|
@ -246,7 +246,7 @@ public:
|
||||
virtual bool hdEnabled() = 0;
|
||||
|
||||
// Return whether the wallet is blank.
|
||||
virtual bool canGetAddresses() = 0;
|
||||
virtual bool canGetAddresses() const = 0;
|
||||
|
||||
// check if a certain wallet flag is set.
|
||||
virtual bool IsWalletFlagSet(uint64_t flag) = 0;
|
||||
|
@ -850,7 +850,7 @@ bool BerkeleyDatabase::Rewrite(const char* pszSkip)
|
||||
return BerkeleyBatch::Rewrite(*this, pszSkip);
|
||||
}
|
||||
|
||||
bool BerkeleyDatabase::Backup(const std::string& strDest)
|
||||
bool BerkeleyDatabase::Backup(const std::string& strDest) const
|
||||
{
|
||||
if (IsDummy()) {
|
||||
return false;
|
||||
|
@ -157,7 +157,7 @@ public:
|
||||
|
||||
/** Back up the entire database to a file.
|
||||
*/
|
||||
bool Backup(const std::string& strDest);
|
||||
bool Backup(const std::string& strDest) const;
|
||||
|
||||
/** Make sure all changes are flushed to disk.
|
||||
*/
|
||||
@ -193,7 +193,7 @@ private:
|
||||
* Only to be used at a low level, application should ideally not care
|
||||
* about this.
|
||||
*/
|
||||
bool IsDummy() { return env == nullptr; }
|
||||
bool IsDummy() const { return env == nullptr; }
|
||||
};
|
||||
|
||||
/** RAII class that provides access to a Berkeley database */
|
||||
|
@ -54,7 +54,7 @@ static std::string DecodeDumpString(const std::string &str) {
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
static bool GetWalletAddressesForKey(LegacyScriptPubKeyMan* spk_man, CWallet* const pwallet, const CKeyID& keyid, std::string& strAddr, std::string& strLabel) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
||||
static bool GetWalletAddressesForKey(LegacyScriptPubKeyMan* spk_man, const CWallet* const pwallet, const CKeyID& keyid, std::string& strAddr, std::string& strLabel) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
||||
{
|
||||
bool fLabelFound = false;
|
||||
CKey key;
|
||||
@ -65,7 +65,7 @@ static bool GetWalletAddressesForKey(LegacyScriptPubKeyMan* spk_man, CWallet* co
|
||||
strAddr += ",";
|
||||
}
|
||||
strAddr += EncodeDestination(dest);
|
||||
strLabel = EncodeDumpString(pwallet->mapAddressBook[dest].name);
|
||||
strLabel = EncodeDumpString(pwallet->mapAddressBook.at(dest).name);
|
||||
fLabelFound = true;
|
||||
}
|
||||
}
|
||||
@ -676,7 +676,7 @@ UniValue importwallet(const JSONRPCRequest& request)
|
||||
UniValue dumpprivkey(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
}
|
||||
@ -724,7 +724,7 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
|
||||
UniValue dumpwallet(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
static const std::string WALLET_ENDPOINT_BASE = "/wallet/";
|
||||
|
||||
static inline bool GetAvoidReuseFlag(CWallet * const pwallet, const UniValue& param) {
|
||||
static inline bool GetAvoidReuseFlag(const CWallet* const pwallet, const UniValue& param) {
|
||||
bool can_avoid_reuse = pwallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE);
|
||||
bool avoid_reuse = param.isNull() ? can_avoid_reuse : param.get_bool();
|
||||
|
||||
@ -458,7 +458,7 @@ static UniValue sendtoaddress(const JSONRPCRequest& request)
|
||||
static UniValue listaddressgroupings(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -520,7 +520,7 @@ static UniValue listaddressgroupings(const JSONRPCRequest& request)
|
||||
static UniValue signmessage(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -590,7 +590,7 @@ static UniValue signmessage(const JSONRPCRequest& request)
|
||||
static UniValue getreceivedbyaddress(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -660,7 +660,7 @@ static UniValue getreceivedbyaddress(const JSONRPCRequest& request)
|
||||
static UniValue getreceivedbylabel(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -728,7 +728,7 @@ static UniValue getreceivedbylabel(const JSONRPCRequest& request)
|
||||
static UniValue getbalance(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -786,7 +786,7 @@ static UniValue getbalance(const JSONRPCRequest& request)
|
||||
static UniValue getunconfirmedbalance(const JSONRPCRequest &request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -1041,7 +1041,7 @@ struct tallyitem
|
||||
}
|
||||
};
|
||||
|
||||
static UniValue ListReceived(interfaces::Chain::Lock& locked_chain, CWallet * const pwallet, const UniValue& params, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
||||
static UniValue ListReceived(interfaces::Chain::Lock& locked_chain, const CWallet* const pwallet, const UniValue& params, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
||||
{
|
||||
// Minimum confirmations
|
||||
int nMinDepth = 1;
|
||||
@ -1190,7 +1190,7 @@ static UniValue ListReceived(interfaces::Chain::Lock& locked_chain, CWallet * co
|
||||
static UniValue listreceivedbyaddress(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -1242,7 +1242,7 @@ static UniValue listreceivedbyaddress(const JSONRPCRequest& request)
|
||||
static UniValue listreceivedbylabel(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -1302,7 +1302,7 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
|
||||
* @param filter_ismine The "is mine" filter flags.
|
||||
* @param filter_label Optional label string to filter incoming transactions.
|
||||
*/
|
||||
static void ListTransactions(interfaces::Chain::Lock& locked_chain, CWallet* const pwallet, const CWalletTx& wtx, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter_ismine, const std::string* filter_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
||||
static void ListTransactions(interfaces::Chain::Lock& locked_chain, const CWallet* const pwallet, const CWalletTx& wtx, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter_ismine, const std::string* filter_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
||||
{
|
||||
CAmount nFee;
|
||||
std::list<COutputEntry> listReceived;
|
||||
@ -1325,7 +1325,7 @@ static void ListTransactions(interfaces::Chain::Lock& locked_chain, CWallet* con
|
||||
entry.pushKV("category", "send");
|
||||
entry.pushKV("amount", ValueFromAmount(-s.amount));
|
||||
if (pwallet->mapAddressBook.count(s.destination)) {
|
||||
entry.pushKV("label", pwallet->mapAddressBook[s.destination].name);
|
||||
entry.pushKV("label", pwallet->mapAddressBook.at(s.destination).name);
|
||||
}
|
||||
entry.pushKV("vout", s.vout);
|
||||
entry.pushKV("fee", ValueFromAmount(-nFee));
|
||||
@ -1342,7 +1342,7 @@ static void ListTransactions(interfaces::Chain::Lock& locked_chain, CWallet* con
|
||||
{
|
||||
std::string label;
|
||||
if (pwallet->mapAddressBook.count(r.destination)) {
|
||||
label = pwallet->mapAddressBook[r.destination].name;
|
||||
label = pwallet->mapAddressBook.at(r.destination).name;
|
||||
}
|
||||
if (filter_label && label != *filter_label) {
|
||||
continue;
|
||||
@ -1402,7 +1402,7 @@ static const std::vector<RPCResult> TransactionDescriptionString()
|
||||
UniValue listtransactions(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -1516,7 +1516,7 @@ UniValue listtransactions(const JSONRPCRequest& request)
|
||||
static UniValue listsinceblock(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -1658,7 +1658,7 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
|
||||
static UniValue gettransaction(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -1817,7 +1817,7 @@ static UniValue abandontransaction(const JSONRPCRequest& request)
|
||||
static UniValue backupwallet(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -2266,7 +2266,7 @@ static UniValue lockunspent(const JSONRPCRequest& request)
|
||||
static UniValue listlockunspent(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -2432,7 +2432,7 @@ static UniValue getbalances(const JSONRPCRequest& request)
|
||||
static UniValue getwalletinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -2814,7 +2814,7 @@ static UniValue unloadwallet(const JSONRPCRequest& request)
|
||||
static UniValue listunspent(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -3248,7 +3248,7 @@ static UniValue fundrawtransaction(const JSONRPCRequest& request)
|
||||
UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -3728,7 +3728,7 @@ public:
|
||||
UniValue operator()(const WitnessUnknown& id) const { return UniValue(UniValue::VOBJ); }
|
||||
};
|
||||
|
||||
static UniValue DescribeWalletAddress(CWallet* pwallet, const CTxDestination& dest)
|
||||
static UniValue DescribeWalletAddress(const CWallet* const pwallet, const CTxDestination& dest)
|
||||
{
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
UniValue detail = DescribeAddress(dest);
|
||||
@ -3756,7 +3756,7 @@ static UniValue AddressBookDataToJSON(const CAddressBookData& data, const bool v
|
||||
UniValue getaddressinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -3858,7 +3858,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
|
||||
// be associated with an address, so the label should be equivalent to the
|
||||
// value of the name key/value pair in the labels array below.
|
||||
if ((pwallet->chain().rpcEnableDeprecated("label")) && (pwallet->mapAddressBook.count(dest))) {
|
||||
ret.pushKV("label", pwallet->mapAddressBook[dest].name);
|
||||
ret.pushKV("label", pwallet->mapAddressBook.at(dest).name);
|
||||
}
|
||||
|
||||
ret.pushKV("ischange", pwallet->IsChange(scriptPubKey));
|
||||
@ -3881,7 +3881,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
|
||||
// stable if we allow multiple labels to be associated with an address in
|
||||
// the future.
|
||||
UniValue labels(UniValue::VARR);
|
||||
std::map<CTxDestination, CAddressBookData>::iterator mi = pwallet->mapAddressBook.find(dest);
|
||||
std::map<CTxDestination, CAddressBookData>::const_iterator mi = pwallet->mapAddressBook.find(dest);
|
||||
if (mi != pwallet->mapAddressBook.end()) {
|
||||
// DEPRECATED: The previous behavior of returning an array containing a
|
||||
// JSON object of `name` and `purpose` key/value pairs is deprecated.
|
||||
@ -3899,7 +3899,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
|
||||
static UniValue getaddressesbylabel(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -3958,7 +3958,7 @@ static UniValue getaddressesbylabel(const JSONRPCRequest& request)
|
||||
static UniValue listlabels(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
@ -4091,7 +4091,7 @@ UniValue sethdseed(const JSONRPCRequest& request)
|
||||
UniValue walletprocesspsbt(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
|
@ -358,7 +358,7 @@ bool LegacyScriptPubKeyMan::IsHDEnabled() const
|
||||
return !hdChain.seed_id.IsNull();
|
||||
}
|
||||
|
||||
bool LegacyScriptPubKeyMan::CanGetAddresses(bool internal)
|
||||
bool LegacyScriptPubKeyMan::CanGetAddresses(bool internal) const
|
||||
{
|
||||
LOCK(cs_KeyStore);
|
||||
// Check if the keypool has keys
|
||||
@ -441,7 +441,7 @@ static int64_t GetOldestKeyTimeInPool(const std::set<int64_t>& setKeyPool, Walle
|
||||
return keypool.nTime;
|
||||
}
|
||||
|
||||
int64_t LegacyScriptPubKeyMan::GetOldestKeyPoolTime()
|
||||
int64_t LegacyScriptPubKeyMan::GetOldestKeyPoolTime() const
|
||||
{
|
||||
LOCK(cs_KeyStore);
|
||||
|
||||
@ -459,7 +459,7 @@ int64_t LegacyScriptPubKeyMan::GetOldestKeyPoolTime()
|
||||
return oldestKey;
|
||||
}
|
||||
|
||||
size_t LegacyScriptPubKeyMan::KeypoolCountExternalKeys()
|
||||
size_t LegacyScriptPubKeyMan::KeypoolCountExternalKeys() const
|
||||
{
|
||||
LOCK(cs_KeyStore);
|
||||
return setExternalKeyPool.size() + set_pre_split_keypool.size();
|
||||
@ -973,7 +973,7 @@ void LegacyScriptPubKeyMan::LoadKeyPool(int64_t nIndex, const CKeyPool &keypool)
|
||||
mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime);
|
||||
}
|
||||
|
||||
bool LegacyScriptPubKeyMan::CanGenerateKeys()
|
||||
bool LegacyScriptPubKeyMan::CanGenerateKeys() const
|
||||
{
|
||||
// A wallet can generate keys if it has an HD seed (IsHDEnabled) or it is a non-HD wallet (pre FEATURE_HD)
|
||||
LOCK(cs_KeyStore);
|
||||
|
@ -184,7 +184,7 @@ public:
|
||||
virtual bool IsHDEnabled() const { return false; }
|
||||
|
||||
/* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
|
||||
virtual bool CanGetAddresses(bool internal = false) { return false; }
|
||||
virtual bool CanGetAddresses(bool internal = false) const { return false; }
|
||||
|
||||
/** Upgrades the wallet to the specified version */
|
||||
virtual bool Upgrade(int prev_version, std::string& error) { return false; }
|
||||
@ -194,9 +194,9 @@ public:
|
||||
//! The action to do when the DB needs rewrite
|
||||
virtual void RewriteDB() {}
|
||||
|
||||
virtual int64_t GetOldestKeyPoolTime() { return GetTime(); }
|
||||
virtual int64_t GetOldestKeyPoolTime() const { return GetTime(); }
|
||||
|
||||
virtual size_t KeypoolCountExternalKeys() { return 0; }
|
||||
virtual size_t KeypoolCountExternalKeys() const { return 0; }
|
||||
virtual unsigned int GetKeyPoolSize() const { return 0; }
|
||||
|
||||
virtual int64_t GetTimeFirstKey() const { return 0; }
|
||||
@ -336,15 +336,15 @@ public:
|
||||
|
||||
void RewriteDB() override;
|
||||
|
||||
int64_t GetOldestKeyPoolTime() override;
|
||||
size_t KeypoolCountExternalKeys() override;
|
||||
int64_t GetOldestKeyPoolTime() const override;
|
||||
size_t KeypoolCountExternalKeys() const override;
|
||||
unsigned int GetKeyPoolSize() const override;
|
||||
|
||||
int64_t GetTimeFirstKey() const override;
|
||||
|
||||
const CKeyMetadata* GetMetadata(const CTxDestination& dest) const override;
|
||||
|
||||
bool CanGetAddresses(bool internal = false) override;
|
||||
bool CanGetAddresses(bool internal = false) const override;
|
||||
|
||||
std::unique_ptr<SigningProvider> GetSigningProvider(const CScript& script) const override;
|
||||
|
||||
@ -410,7 +410,7 @@ public:
|
||||
bool ImportScriptPubKeys(const std::set<CScript>& script_pub_keys, const bool have_solving_data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
|
||||
|
||||
/* Returns true if the wallet can generate new keys */
|
||||
bool CanGenerateKeys();
|
||||
bool CanGenerateKeys() const;
|
||||
|
||||
/* Generates a new HD seed (will not be activated) */
|
||||
CPubKey GenerateNewSeed();
|
||||
|
@ -1150,7 +1150,7 @@ void CWallet::UpdatedBlockTip()
|
||||
}
|
||||
|
||||
|
||||
void CWallet::BlockUntilSyncedToCurrentChain() {
|
||||
void CWallet::BlockUntilSyncedToCurrentChain() const {
|
||||
AssertLockNotHeld(cs_wallet);
|
||||
// Skip the queue-draining stuff if we know we're caught up with
|
||||
// ::ChainActive().Tip(), otherwise put a callback in the validation interface queue and wait
|
||||
@ -1333,7 +1333,7 @@ bool CWallet::IsHDEnabled() const
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CWallet::CanGetAddresses(bool internal)
|
||||
bool CWallet::CanGetAddresses(bool internal) const
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
if (m_spk_managers.empty()) return false;
|
||||
@ -3112,7 +3112,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
|
||||
return WalletBatch(*database).EraseName(EncodeDestination(address));
|
||||
}
|
||||
|
||||
size_t CWallet::KeypoolCountExternalKeys()
|
||||
size_t CWallet::KeypoolCountExternalKeys() const
|
||||
{
|
||||
AssertLockHeld(cs_wallet);
|
||||
|
||||
@ -3177,7 +3177,7 @@ bool CWallet::GetNewChangeDestination(const OutputType type, CTxDestination& des
|
||||
return true;
|
||||
}
|
||||
|
||||
int64_t CWallet::GetOldestKeyPoolTime()
|
||||
int64_t CWallet::GetOldestKeyPoolTime() const
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
int64_t oldestKey = std::numeric_limits<int64_t>::max();
|
||||
@ -3201,7 +3201,7 @@ void CWallet::MarkDestinationsDirty(const std::set<CTxDestination>& destinations
|
||||
}
|
||||
}
|
||||
|
||||
std::map<CTxDestination, CAmount> CWallet::GetAddressBalances(interfaces::Chain::Lock& locked_chain)
|
||||
std::map<CTxDestination, CAmount> CWallet::GetAddressBalances(interfaces::Chain::Lock& locked_chain) const
|
||||
{
|
||||
std::map<CTxDestination, CAmount> balances;
|
||||
|
||||
@ -3242,7 +3242,7 @@ std::map<CTxDestination, CAmount> CWallet::GetAddressBalances(interfaces::Chain:
|
||||
return balances;
|
||||
}
|
||||
|
||||
std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
||||
std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings() const
|
||||
{
|
||||
AssertLockHeld(cs_wallet);
|
||||
std::set< std::set<CTxDestination> > groupings;
|
||||
@ -4004,7 +4004,7 @@ void CWallet::postInitProcess()
|
||||
chain().requestMempoolTransactions(*this);
|
||||
}
|
||||
|
||||
bool CWallet::BackupWallet(const std::string& strDest)
|
||||
bool CWallet::BackupWallet(const std::string& strDest) const
|
||||
{
|
||||
return database->Backup(strDest);
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ class ReserveDestination
|
||||
{
|
||||
protected:
|
||||
//! The wallet to reserve from
|
||||
CWallet* const pwallet;
|
||||
const CWallet* const pwallet;
|
||||
//! The ScriptPubKeyMan to reserve from. Based on type when GetReservedDestination is called
|
||||
ScriptPubKeyMan* m_spk_man{nullptr};
|
||||
OutputType const type;
|
||||
@ -832,8 +832,8 @@ public:
|
||||
* Rescan abort properties
|
||||
*/
|
||||
void AbortRescan() { fAbortRescan = true; }
|
||||
bool IsAbortingRescan() { return fAbortRescan; }
|
||||
bool IsScanning() { return fScanningWallet; }
|
||||
bool IsAbortingRescan() const { return fAbortRescan; }
|
||||
bool IsScanning() const { return fScanningWallet; }
|
||||
int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; }
|
||||
double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; }
|
||||
|
||||
@ -968,13 +968,13 @@ public:
|
||||
/** Absolute maximum transaction fee (in satoshis) used by default for the wallet */
|
||||
CAmount m_default_max_tx_fee{DEFAULT_TRANSACTION_MAXFEE};
|
||||
|
||||
size_t KeypoolCountExternalKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
bool TopUpKeyPool(unsigned int kpSize = 0);
|
||||
|
||||
int64_t GetOldestKeyPoolTime();
|
||||
int64_t GetOldestKeyPoolTime() const;
|
||||
|
||||
std::set<std::set<CTxDestination>> GetAddressGroupings() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
std::map<CTxDestination, CAmount> GetAddressBalances(interfaces::Chain::Lock& locked_chain);
|
||||
std::set<std::set<CTxDestination>> GetAddressGroupings() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
std::map<CTxDestination, CAmount> GetAddressBalances(interfaces::Chain::Lock& locked_chain) const;
|
||||
|
||||
std::set<CTxDestination> GetLabelAddresses(const std::string& label) const;
|
||||
|
||||
@ -1027,7 +1027,7 @@ public:
|
||||
bool SetMaxVersion(int nVersion);
|
||||
|
||||
//! get the current wallet format (the oldest client version guaranteed to understand this wallet)
|
||||
int GetVersion() { LOCK(cs_wallet); return nWalletVersion; }
|
||||
int GetVersion() const { LOCK(cs_wallet); return nWalletVersion; }
|
||||
|
||||
//! Get wallet transactions that conflict with given transaction (spend same outputs)
|
||||
std::set<uint256> GetConflicts(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
@ -1098,13 +1098,13 @@ public:
|
||||
*/
|
||||
void postInitProcess();
|
||||
|
||||
bool BackupWallet(const std::string& strDest);
|
||||
bool BackupWallet(const std::string& strDest) const;
|
||||
|
||||
/* Returns true if HD is enabled */
|
||||
bool IsHDEnabled() const;
|
||||
|
||||
/* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
|
||||
bool CanGetAddresses(bool internal = false);
|
||||
bool CanGetAddresses(bool internal = false) const;
|
||||
|
||||
/**
|
||||
* Blocks until the wallet state is up-to-date to /at least/ the current
|
||||
@ -1112,7 +1112,7 @@ public:
|
||||
* Obviously holding cs_main/cs_wallet when going into this call may cause
|
||||
* deadlock
|
||||
*/
|
||||
void BlockUntilSyncedToCurrentChain() LOCKS_EXCLUDED(cs_main, cs_wallet);
|
||||
void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(cs_main, cs_wallet);
|
||||
|
||||
/** set a single wallet flag */
|
||||
void SetWalletFlag(uint64_t flags);
|
||||
|
Loading…
Reference in New Issue
Block a user