Page MenuHomePhabricator

D8115.diff
No OneTemporary

D8115.diff

diff --git a/src/index/base.h b/src/index/base.h
--- a/src/index/base.h
+++ b/src/index/base.h
@@ -102,7 +102,7 @@
/// 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();
diff --git a/src/index/base.cpp b/src/index/base.cpp
--- a/src/index/base.cpp
+++ b/src/index/base.cpp
@@ -281,7 +281,7 @@
Commit();
}
-bool BaseIndex::BlockUntilSyncedToCurrentChain() {
+bool BaseIndex::BlockUntilSyncedToCurrentChain() const {
AssertLockNotHeld(cs_main);
if (!m_synced) {
diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h
--- a/src/interfaces/wallet.h
+++ b/src/interfaces/wallet.h
@@ -240,7 +240,7 @@
virtual bool hdEnabled() = 0;
// Return whether the wallet is blank.
- virtual bool canGetAddresses() = 0;
+ virtual bool canGetAddresses() const = 0;
// Return whether private keys enabled.
virtual bool privateKeysDisabled() = 0;
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -394,7 +394,9 @@
OutputType getDefaultAddressType() override {
return m_wallet->m_default_address_type;
}
- bool canGetAddresses() override { return m_wallet->CanGetAddresses(); }
+ bool canGetAddresses() const override {
+ return m_wallet->CanGetAddresses();
+ }
bool privateKeysDisabled() override {
return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
}
diff --git a/src/wallet/db.h b/src/wallet/db.h
--- a/src/wallet/db.h
+++ b/src/wallet/db.h
@@ -178,7 +178,7 @@
/**
* 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.
@@ -219,7 +219,7 @@
* 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 */
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -938,7 +938,7 @@
return BerkeleyBatch::Rewrite(*this, pszSkip);
}
-bool BerkeleyDatabase::Backup(const std::string &strDest) {
+bool BerkeleyDatabase::Backup(const std::string &strDest) const {
if (IsDummy()) {
return false;
}
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -56,7 +56,7 @@
static bool
GetWalletAddressesForKey(const Config &config, LegacyScriptPubKeyMan *spk_man,
- CWallet *const pwallet, const CKeyID &keyid,
+ const CWallet *const pwallet, const CKeyID &keyid,
std::string &strAddr, std::string &strLabel)
EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
bool fLabelFound = false;
@@ -813,7 +813,7 @@
UniValue dumpprivkey(const Config &config, 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;
}
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -40,7 +40,7 @@
static const std::string WALLET_ENDPOINT_BASE = "/wallet/";
-static inline bool GetAvoidReuseFlag(CWallet *const pwallet,
+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();
@@ -505,7 +505,7 @@
static UniValue listaddressgroupings(const Config &config,
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;
@@ -567,7 +567,7 @@
static UniValue signmessage(const Config &config,
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;
@@ -689,7 +689,7 @@
static UniValue getreceivedbyaddress(const Config &config,
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;
@@ -781,7 +781,7 @@
static UniValue getbalance(const Config &config,
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;
@@ -853,7 +853,7 @@
static UniValue getunconfirmedbalance(const Config &config,
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;
@@ -1140,7 +1140,7 @@
tallyitem() {}
};
-static UniValue ListReceived(const Config &config, CWallet *const pwallet,
+static UniValue ListReceived(const Config &config, const CWallet *const pwallet,
const UniValue &params, bool by_label)
EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
// Minimum confirmations
@@ -1300,7 +1300,7 @@
static UniValue listreceivedbyaddress(const Config &config,
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;
@@ -1368,7 +1368,7 @@
static UniValue listreceivedbylabel(const Config &config,
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;
@@ -1433,7 +1433,7 @@
* @param filter_ismine The "is mine" filter flags.
* @param filter_label Optional label string to filter incoming transactions.
*/
-static void ListTransactions(CWallet *const pwallet, const CWalletTx &wtx,
+static void ListTransactions(const CWallet *const pwallet, const CWalletTx &wtx,
int nMinDepth, bool fLong, UniValue &ret,
const isminefilter &filter_ismine,
const std::string *filter_label)
@@ -1558,7 +1558,7 @@
UniValue listtransactions(const Config &config, 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;
@@ -1704,7 +1704,7 @@
static UniValue listsinceblock(const Config &config,
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;
@@ -1902,7 +1902,7 @@
static UniValue gettransaction(const Config &config,
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;
@@ -2109,7 +2109,7 @@
static UniValue backupwallet(const Config &config,
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;
@@ -2648,7 +2648,7 @@
static UniValue listlockunspent(const Config &config,
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;
@@ -2843,7 +2843,7 @@
static UniValue getwalletinfo(const Config &config,
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;
@@ -3281,7 +3281,7 @@
static UniValue listunspent(const Config &config,
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;
@@ -3773,7 +3773,7 @@
UniValue signrawtransactionwithwallet(const Config &config,
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;
@@ -4064,7 +4064,7 @@
}
};
-static UniValue DescribeWalletAddress(CWallet *pwallet,
+static UniValue DescribeWalletAddress(const CWallet *const pwallet,
const CTxDestination &dest) {
UniValue ret(UniValue::VOBJ);
UniValue detail = DescribeAddress(dest);
@@ -4092,7 +4092,7 @@
UniValue getaddressinfo(const Config &config, 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;
@@ -4278,7 +4278,8 @@
UniValue getaddressesbylabel(const Config &config,
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;
}
@@ -4339,7 +4340,8 @@
UniValue listlabels(const Config &config, 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;
}
@@ -4499,7 +4501,7 @@
static UniValue walletprocesspsbt(const Config &config,
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;
diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h
--- a/src/wallet/scriptpubkeyman.h
+++ b/src/wallet/scriptpubkeyman.h
@@ -217,9 +217,11 @@
/* Returns true if HD is enabled */
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; }
+ /**
+ * 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) const { return false; }
/** Upgrades the wallet to the specified version */
virtual bool Upgrade(int prev_version, bilingual_str &error) {
@@ -231,9 +233,9 @@
//! 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; }
@@ -435,15 +437,15 @@
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>
GetSolvingProvider(const CScript &script) const override;
@@ -540,7 +542,7 @@
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();
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -310,7 +310,7 @@
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
bool keypool_has_keys;
@@ -392,7 +392,7 @@
return keypool.nTime;
}
-int64_t LegacyScriptPubKeyMan::GetOldestKeyPoolTime() {
+int64_t LegacyScriptPubKeyMan::GetOldestKeyPoolTime() const {
LOCK(cs_KeyStore);
WalletBatch batch(m_storage.GetDatabase());
@@ -412,7 +412,7 @@
return oldestKey;
}
-size_t LegacyScriptPubKeyMan::KeypoolCountExternalKeys() {
+size_t LegacyScriptPubKeyMan::KeypoolCountExternalKeys() const {
LOCK(cs_KeyStore);
return setExternalKeyPool.size() + set_pre_split_keypool.size();
}
@@ -1017,7 +1017,7 @@
}
}
-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);
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -156,7 +156,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};
@@ -970,8 +970,8 @@
* 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;
}
@@ -1206,14 +1206,14 @@
*/
Amount 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()
+ std::set<std::set<CTxDestination>> GetAddressGroupings() const
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
- std::map<CTxDestination, Amount> GetAddressBalances();
+ std::map<CTxDestination, Amount> GetAddressBalances() const;
std::set<CTxDestination> GetLabelAddresses(const std::string &label) const;
@@ -1276,7 +1276,7 @@
//! get the current wallet format (the oldest client version guaranteed to
//! understand this wallet)
- int GetVersion() {
+ int GetVersion() const {
LOCK(cs_wallet);
return nWalletVersion;
}
@@ -1370,7 +1370,7 @@
*/
void postInitProcess();
- bool BackupWallet(const std::string &strDest);
+ bool BackupWallet(const std::string &strDest) const;
/* Returns true if HD is enabled */
bool IsHDEnabled() const;
@@ -1379,7 +1379,7 @@
* 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
@@ -1387,7 +1387,8 @@
* 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.
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1226,7 +1226,7 @@
m_best_block_time = GetTime();
}
-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
@@ -1421,7 +1421,7 @@
return result;
}
-bool CWallet::CanGetAddresses(bool internal) {
+bool CWallet::CanGetAddresses(bool internal) const {
LOCK(cs_wallet);
if (m_spk_managers.empty()) {
return false;
@@ -3614,7 +3614,7 @@
return WalletBatch(*database).EraseName(address);
}
-size_t CWallet::KeypoolCountExternalKeys() {
+size_t CWallet::KeypoolCountExternalKeys() const {
AssertLockHeld(cs_wallet);
unsigned int count = 0;
@@ -3677,7 +3677,7 @@
return true;
}
-int64_t CWallet::GetOldestKeyPoolTime() {
+int64_t CWallet::GetOldestKeyPoolTime() const {
LOCK(cs_wallet);
int64_t oldestKey = std::numeric_limits<int64_t>::max();
for (const auto &spk_man_pair : m_spk_managers) {
@@ -3707,7 +3707,7 @@
}
}
-std::map<CTxDestination, Amount> CWallet::GetAddressBalances() {
+std::map<CTxDestination, Amount> CWallet::GetAddressBalances() const {
std::map<CTxDestination, Amount> balances;
LOCK(cs_wallet);
@@ -3752,7 +3752,7 @@
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;
std::set<CTxDestination> grouping;
@@ -4624,7 +4624,7 @@
chain().requestMempoolTransactions(*this);
}
-bool CWallet::BackupWallet(const std::string &strDest) {
+bool CWallet::BackupWallet(const std::string &strDest) const {
return database->Backup(strDest);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 11:25 (6 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187592
Default Alt Text
D8115.diff (21 KB)

Event Timeline