Skip to content

Commit

Permalink
Merge pull request #420 from qtumproject/time/token-address-fix
Browse files Browse the repository at this point in the history
Filter user defined address for receiver only for token address
  • Loading branch information
qtum-neil authored Nov 28, 2017
2 parents 2a7afc9 + f5369af commit 09a3a35
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/qt/addressfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ AddressField::AddressField(QWidget *parent) :
QComboBox(parent),
m_addressType(AddressField::UTXO),
m_addressTableModel(0),
m_addressColumn(0)
m_addressColumn(0),
m_typeRole(Qt::UserRole),
m_receive("R")

{
setComboBoxEditable(false);

Expand Down Expand Up @@ -92,7 +95,11 @@ void AddressField::on_refresh()
{
QModelIndex index = m_addressTableModel->index(row, m_addressColumn);
QString strAddress = m_addressTableModel->data(index).toString();
appendAddress(strAddress);
QString type = m_addressTableModel->data(index, m_typeRole).toString();
if(type == m_receive)
{
appendAddress(strAddress);
}
}

// Include zero or unconfirmed coins too
Expand Down Expand Up @@ -137,12 +144,24 @@ void AddressField::on_editingFinished()

void AddressField::appendAddress(const QString &strAddress)
{
if(!m_stringList.contains(strAddress))
CBitcoinAddress address(strAddress.toStdString());
if(!m_stringList.contains(strAddress) &&
IsMine(*pwalletMain, address.Get()))
{
m_stringList.append(strAddress);
}
}

void AddressField::setReceive(const QString &receive)
{
m_receive = receive;
}

void AddressField::setTypeRole(int typeRole)
{
m_typeRole = typeRole;
}

void AddressField::setAddressColumn(int addressColumn)
{
m_addressColumn = addressColumn;
Expand Down
6 changes: 6 additions & 0 deletions src/qt/addressfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class AddressField: public QComboBox

void setAddressColumn(int addressColumn);

void setTypeRole(int typeRole);

void setReceive(const QString &receive);

Q_SIGNALS:
/**
* @brief addressTypeChanged Signal that the address type is changed
Expand Down Expand Up @@ -94,6 +98,8 @@ public Q_SLOTS:
AddressType m_addressType;
QAbstractItemModel* m_addressTableModel;
int m_addressColumn;
int m_typeRole;
QString m_receive;
};

#endif // ADDRESSFIELD_H
2 changes: 2 additions & 0 deletions src/qt/addtokenpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ AddTokenPage::AddTokenPage(QWidget *parent) :
connect(ui->lineEditTokenSymbol, SIGNAL(textChanged(const QString &)), SLOT(on_updateConfirmButton()));

ui->lineEditSenderAddress->setAddressColumn(AddressTableModel::Address);
ui->lineEditSenderAddress->setTypeRole(AddressTableModel::TypeRole);
ui->lineEditSenderAddress->setReceive(AddressTableModel::Receive);
if(ui->lineEditSenderAddress->isEditable())
((QValidatedLineEdit*)ui->lineEditSenderAddress->lineEdit())->setEmptyIsValid(false);
m_validTokenAddress = false;
Expand Down

0 comments on commit 09a3a35

Please sign in to comment.