mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Merge #17918: qt: Hide non PKHash-Addresses in signing address book
c4ea501e96
qt: Hide non PKHash-Addresses in signing address book (Emil Engler) Pull request description: [Video Demo](https://www.youtube.com/watch?v=T-Rp2pFRmzY) This PR hides all non PKHash addresses in the signing GUI in the Address Book when it is opened through the signing dialog, as non PKHash addresses are useless there. ACKs for top commit: jonasschnelli: Code Review ACKc4ea501e96
Tree-SHA512: e321d45e15534b2d68da5a1297b1c7551cdd784f03203f54c9385c2ce0bb2b7316c09f9e8c3eb41bfa1e7207ecc94c8ed08f012e2d6c117b803996ade26feb2f
This commit is contained in:
commit
a9024a42fc
6 changed files with 16 additions and 5 deletions
|
@ -106,7 +106,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
|
|||
ui->newAddress->setVisible(true);
|
||||
break;
|
||||
case ReceivingTab:
|
||||
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."));
|
||||
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'."));
|
||||
ui->deleteAddress->setVisible(false);
|
||||
ui->newAddress->setVisible(false);
|
||||
break;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <wallet/wallet.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <typeinfo>
|
||||
|
||||
#include <QFont>
|
||||
#include <QDebug>
|
||||
|
@ -75,12 +76,14 @@ public:
|
|||
explicit AddressTablePriv(AddressTableModel *_parent):
|
||||
parent(_parent) {}
|
||||
|
||||
void refreshAddressTable(interfaces::Wallet& wallet)
|
||||
void refreshAddressTable(interfaces::Wallet& wallet, bool pk_hash_only = false)
|
||||
{
|
||||
cachedAddressTable.clear();
|
||||
{
|
||||
for (const auto& address : wallet.getAddresses())
|
||||
{
|
||||
if (pk_hash_only && address.dest.type() != typeid(PKHash))
|
||||
continue;
|
||||
AddressTableEntry::Type addressType = translateTransactionType(
|
||||
QString::fromStdString(address.purpose), address.is_mine);
|
||||
cachedAddressTable.append(AddressTableEntry(addressType,
|
||||
|
@ -159,12 +162,12 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
AddressTableModel::AddressTableModel(WalletModel *parent) :
|
||||
AddressTableModel::AddressTableModel(WalletModel *parent, bool pk_hash_only) :
|
||||
QAbstractTableModel(parent), walletModel(parent)
|
||||
{
|
||||
columns << tr("Label") << tr("Address");
|
||||
priv = new AddressTablePriv(this);
|
||||
priv->refreshAddressTable(parent->wallet());
|
||||
priv->refreshAddressTable(parent->wallet(), pk_hash_only);
|
||||
}
|
||||
|
||||
AddressTableModel::~AddressTableModel()
|
||||
|
|
|
@ -25,7 +25,7 @@ class AddressTableModel : public QAbstractTableModel
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AddressTableModel(WalletModel *parent = nullptr);
|
||||
explicit AddressTableModel(WalletModel *parent = nullptr, bool pk_hash_only = false);
|
||||
~AddressTableModel();
|
||||
|
||||
enum ColumnIndex {
|
||||
|
|
|
@ -91,6 +91,7 @@ void SignVerifyMessageDialog::on_addressBookButton_SM_clicked()
|
|||
{
|
||||
if (model && model->getAddressTableModel())
|
||||
{
|
||||
model->refresh(/* pk_hash_only */ true);
|
||||
AddressBookPage dlg(platformStyle, AddressBookPage::ForSelection, AddressBookPage::ReceivingTab, this);
|
||||
dlg.setModel(model->getAddressTableModel());
|
||||
if (dlg.exec())
|
||||
|
|
|
@ -585,3 +585,8 @@ bool WalletModel::isMultiwallet()
|
|||
{
|
||||
return m_node.getWallets().size() > 1;
|
||||
}
|
||||
|
||||
void WalletModel::refresh(bool pk_hash_only)
|
||||
{
|
||||
addressTableModel = new AddressTableModel(this, pk_hash_only);
|
||||
}
|
||||
|
|
|
@ -153,6 +153,8 @@ public:
|
|||
bool isMultiwallet();
|
||||
|
||||
AddressTableModel* getAddressTableModel() const { return addressTableModel; }
|
||||
|
||||
void refresh(bool pk_hash_only = false);
|
||||
private:
|
||||
std::unique_ptr<interfaces::Wallet> m_wallet;
|
||||
std::unique_ptr<interfaces::Handler> m_handler_unload;
|
||||
|
|
Loading…
Add table
Reference in a new issue