Skip to content

Commit c4ea501

Browse files
committed
qt: Hide non PKHash-Addresses in signing address book
1 parent 2ed74a4 commit c4ea501

File tree

6 files changed

+16
-5
lines changed

6 files changed

+16
-5
lines changed

src/qt/addressbookpage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
106106
ui->newAddress->setVisible(true);
107107
break;
108108
case ReceivingTab:
109-
ui->labelExplanation->setText(tr("These are your Bitcoin addresses for receiving payments. Use the 'Create new receiving address' button in the receive tab to create new addresses."));
109+
ui->labelExplanation->setText(tr("These are your Bitcoin addresses for receiving payments. Use the 'Create new receiving address' button in the receive tab to create new addresses.\nSigning is only possible with addresses of the type 'legacy'."));
110110
ui->deleteAddress->setVisible(false);
111111
ui->newAddress->setVisible(false);
112112
break;

src/qt/addresstablemodel.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <wallet/wallet.h>
1212

1313
#include <algorithm>
14+
#include <typeinfo>
1415

1516
#include <QFont>
1617
#include <QDebug>
@@ -75,12 +76,14 @@ class AddressTablePriv
7576
explicit AddressTablePriv(AddressTableModel *_parent):
7677
parent(_parent) {}
7778

78-
void refreshAddressTable(interfaces::Wallet& wallet)
79+
void refreshAddressTable(interfaces::Wallet& wallet, bool pk_hash_only = false)
7980
{
8081
cachedAddressTable.clear();
8182
{
8283
for (const auto& address : wallet.getAddresses())
8384
{
85+
if (pk_hash_only && address.dest.type() != typeid(PKHash))
86+
continue;
8487
AddressTableEntry::Type addressType = translateTransactionType(
8588
QString::fromStdString(address.purpose), address.is_mine);
8689
cachedAddressTable.append(AddressTableEntry(addressType,
@@ -159,12 +162,12 @@ class AddressTablePriv
159162
}
160163
};
161164

162-
AddressTableModel::AddressTableModel(WalletModel *parent) :
165+
AddressTableModel::AddressTableModel(WalletModel *parent, bool pk_hash_only) :
163166
QAbstractTableModel(parent), walletModel(parent)
164167
{
165168
columns << tr("Label") << tr("Address");
166169
priv = new AddressTablePriv(this);
167-
priv->refreshAddressTable(parent->wallet());
170+
priv->refreshAddressTable(parent->wallet(), pk_hash_only);
168171
}
169172

170173
AddressTableModel::~AddressTableModel()

src/qt/addresstablemodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AddressTableModel : public QAbstractTableModel
2525
Q_OBJECT
2626

2727
public:
28-
explicit AddressTableModel(WalletModel *parent = nullptr);
28+
explicit AddressTableModel(WalletModel *parent = nullptr, bool pk_hash_only = false);
2929
~AddressTableModel();
3030

3131
enum ColumnIndex {

src/qt/signverifymessagedialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ void SignVerifyMessageDialog::on_addressBookButton_SM_clicked()
8989
{
9090
if (model && model->getAddressTableModel())
9191
{
92+
model->refresh(/* pk_hash_only */ true);
9293
AddressBookPage dlg(platformStyle, AddressBookPage::ForSelection, AddressBookPage::ReceivingTab, this);
9394
dlg.setModel(model->getAddressTableModel());
9495
if (dlg.exec())

src/qt/walletmodel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,3 +563,8 @@ bool WalletModel::isMultiwallet()
563563
{
564564
return m_node.getWallets().size() > 1;
565565
}
566+
567+
void WalletModel::refresh(bool pk_hash_only)
568+
{
569+
addressTableModel = new AddressTableModel(this, pk_hash_only);
570+
}

src/qt/walletmodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ class WalletModel : public QObject
152152
bool isMultiwallet();
153153

154154
AddressTableModel* getAddressTableModel() const { return addressTableModel; }
155+
156+
void refresh(bool pk_hash_only = false);
155157
private:
156158
std::unique_ptr<interfaces::Wallet> m_wallet;
157159
std::unique_ptr<interfaces::Handler> m_handler_unload;

0 commit comments

Comments
 (0)