Skip to content

Commit b9219b2

Browse files
committed
Merge #590: refactor: Declare WalletModel member functions with const
f70ee34 qt, refactor: Declare `WalletModel` member functions with `const` (Hennadii Stepanov) Pull request description: After bitcoin/bitcoin#12830 the `WalletModel` class has two member functions: https://github.com/bitcoin-core/gui/blob/be7a5f2fc400e7a3ef72dedbdcf49dd6c96d4f9e/src/qt/walletmodel.h#L81 and https://github.com/bitcoin-core/gui/blob/be7a5f2fc400e7a3ef72dedbdcf49dd6c96d4f9e/src/qt/walletmodel.h#L154 This PR drops the former one as redundant, and declares `WalletModel` member functions with the `const` qualifier where appropriate. ACKs for top commit: promag: Code review ACK f70ee34. kristapsk: cr ACK f70ee34 w0xlt: Code Review ACK f70ee34 Tree-SHA512: 43e6661822c667229ea860fb94c2e3154c33773dbd9fca1f6f76cc31c5875a1a0e8caa65ddfc20dec2a43e29e7b2469b3b6fa148fe7ec000ded518b4958b2b38
2 parents 3dd95cb + f70ee34 commit b9219b2

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

src/qt/walletmodel.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
145145
Q_EMIT notifyWatchonlyChanged(fHaveWatchonly);
146146
}
147147

148-
bool WalletModel::validateAddress(const QString &address)
148+
bool WalletModel::validateAddress(const QString& address) const
149149
{
150150
return IsValidDestinationString(address.toStdString());
151151
}
@@ -284,22 +284,22 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
284284
return SendCoinsReturn(OK);
285285
}
286286

287-
OptionsModel *WalletModel::getOptionsModel()
287+
OptionsModel* WalletModel::getOptionsModel() const
288288
{
289289
return optionsModel;
290290
}
291291

292-
AddressTableModel *WalletModel::getAddressTableModel()
292+
AddressTableModel* WalletModel::getAddressTableModel() const
293293
{
294294
return addressTableModel;
295295
}
296296

297-
TransactionTableModel *WalletModel::getTransactionTableModel()
297+
TransactionTableModel* WalletModel::getTransactionTableModel() const
298298
{
299299
return transactionTableModel;
300300
}
301301

302-
RecentRequestsTableModel *WalletModel::getRecentRequestsTableModel()
302+
RecentRequestsTableModel* WalletModel::getRecentRequestsTableModel() const
303303
{
304304
return recentRequestsTableModel;
305305
}
@@ -557,7 +557,7 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
557557
return true;
558558
}
559559

560-
bool WalletModel::displayAddress(std::string sAddress)
560+
bool WalletModel::displayAddress(std::string sAddress) const
561561
{
562562
CTxDestination dest = DecodeDestination(sAddress);
563563
bool res = false;
@@ -585,7 +585,7 @@ QString WalletModel::getDisplayName() const
585585
return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
586586
}
587587

588-
bool WalletModel::isMultiwallet()
588+
bool WalletModel::isMultiwallet() const
589589
{
590590
return m_node.walletLoader().getWallets().size() > 1;
591591
}

src/qt/walletmodel.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ class WalletModel : public QObject
7777
Unlocked // wallet->IsCrypted() && !wallet->IsLocked()
7878
};
7979

80-
OptionsModel *getOptionsModel();
81-
AddressTableModel *getAddressTableModel();
82-
TransactionTableModel *getTransactionTableModel();
83-
RecentRequestsTableModel *getRecentRequestsTableModel();
80+
OptionsModel* getOptionsModel() const;
81+
AddressTableModel* getAddressTableModel() const;
82+
TransactionTableModel* getTransactionTableModel() const;
83+
RecentRequestsTableModel* getRecentRequestsTableModel() const;
8484

8585
EncryptionStatus getEncryptionStatus() const;
8686

8787
// Check address for validity
88-
bool validateAddress(const QString &address);
88+
bool validateAddress(const QString& address) const;
8989

9090
// Return status record for SendCoins, contains error id + information
9191
struct SendCoinsReturn
@@ -137,7 +137,7 @@ class WalletModel : public QObject
137137
UnlockContext requestUnlock();
138138

139139
bool bumpFee(uint256 hash, uint256& new_hash);
140-
bool displayAddress(std::string sAddress);
140+
bool displayAddress(std::string sAddress) const;
141141

142142
static bool isWalletEnabled();
143143

@@ -149,9 +149,7 @@ class WalletModel : public QObject
149149
QString getWalletName() const;
150150
QString getDisplayName() const;
151151

152-
bool isMultiwallet();
153-
154-
AddressTableModel* getAddressTableModel() const { return addressTableModel; }
152+
bool isMultiwallet() const;
155153

156154
void refresh(bool pk_hash_only = false);
157155

0 commit comments

Comments
 (0)