Skip to content

Commit

Permalink
fix stealth in editaddress tab
Browse files Browse the repository at this point in the history
  • Loading branch information
justinvforvendetta committed Jan 1, 2018
1 parent e544296 commit e361292
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
41 changes: 29 additions & 12 deletions src/qt/editaddressdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,24 @@ EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) :
case NewReceivingAddress:
setWindowTitle(tr("New receiving address"));
ui->addressEdit->setEnabled(false);
ui->addressEdit->setVisible(false);
ui->stealthCB->setEnabled(true);
ui->stealthCB->setVisible(true);
break;
case NewSendingAddress:
setWindowTitle(tr("New sending address"));
ui->stealthCB->setVisible(false);
break;
case EditReceivingAddress:
setWindowTitle(tr("Edit receiving address"));
ui->addressEdit->setDisabled(true);
ui->addressEdit->setEnabled(false);
ui->addressEdit->setVisible(true);
ui->stealthCB->setEnabled(false);
ui->stealthCB->setVisible(true);
break;
case EditSendingAddress:
setWindowTitle(tr("Edit sending address"));
ui->stealthCB->setVisible(false);
break;
}

Expand All @@ -44,9 +52,12 @@ EditAddressDialog::~EditAddressDialog()
void EditAddressDialog::setModel(AddressTableModel *model)
{
this->model = model;
if(!model)
return;

This comment has been minimized.

Copy link
@sova

sova Jan 2, 2018

would it be better to place this return statement above the assignment [this->model = model;] ? it seems like it's intended as a break when model is an unset variable. maybe throwing some sort of error would be best practice here.

mapper->setModel(model);
mapper->addMapping(ui->labelEdit, AddressTableModel::Label);
mapper->addMapping(ui->addressEdit, AddressTableModel::Address);
mapper->addMapping(ui->stealthCB, AddressTableModel::Type);
}

void EditAddressDialog::loadRow(int row)
Expand All @@ -62,10 +73,14 @@ bool EditAddressDialog::saveCurrentRow()
{
case NewReceivingAddress:
case NewSendingAddress:
{
int typeInd = ui->stealthCB->isChecked() ? AddressTableModel::AT_Stealth : AddressTableModel::AT_Normal;
address = model->addRow(
mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive,
ui->labelEdit->text(),
ui->addressEdit->text());
ui->addressEdit->text(),
typeInd);
}
break;
case EditReceivingAddress:
case EditSendingAddress:
Expand All @@ -86,31 +101,33 @@ void EditAddressDialog::accept()
{
switch(model->getEditStatus())
{
case AddressTableModel::DUPLICATE_ADDRESS:
case AddressTableModel::OK:
// Failed with unknown reason. Just reject.
break;
case AddressTableModel::NO_CHANGES:
// No changes were made during edit operation. Just reject.
break;
case AddressTableModel::INVALID_ADDRESS:
QMessageBox::warning(this, windowTitle(),
tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()),
tr("The entered address \"%1\" is not a valid Fantom address.").arg(ui->addressEdit->text()),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::INVALID_ADDRESS:
case AddressTableModel::DUPLICATE_ADDRESS:
QMessageBox::warning(this, windowTitle(),
tr("The entered address \"%1\" is not a valid VERGE address.").arg(ui->addressEdit->text()),
tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()),
QMessageBox::Ok, QMessageBox::Ok);
return;
break;
case AddressTableModel::WALLET_UNLOCK_FAILURE:
QMessageBox::critical(this, windowTitle(),
tr("Could not unlock wallet."),
QMessageBox::Ok, QMessageBox::Ok);
return;
break;
case AddressTableModel::KEY_GENERATION_FAILURE:
QMessageBox::critical(this, windowTitle(),
tr("New key generation failed."),
QMessageBox::Ok, QMessageBox::Ok);
return;
case AddressTableModel::OK:
// Failed with unknown reason. Just reject.
break;
}

return;
}
QDialog::accept();
Expand Down
12 changes: 6 additions & 6 deletions src/qt/editaddressdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

#include <QDialog>

QT_BEGIN_NAMESPACE
class QDataWidgetMapper;
QT_END_NAMESPACE

namespace Ui {
class EditAddressDialog;
}
class AddressTableModel;

QT_BEGIN_NAMESPACE
class QDataWidgetMapper;
QT_END_NAMESPACE

/** Dialog for editing an address and associated information.
*/
class EditAddressDialog : public QDialog
Expand All @@ -32,10 +32,10 @@ class EditAddressDialog : public QDialog
void setModel(AddressTableModel *model);
void loadRow(int row);

void accept();

QString getAddress() const;
void setAddress(const QString &address);
public slots:
void accept();
private:
bool saveCurrentRow();

Expand Down
4 changes: 2 additions & 2 deletions src/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ Value getnewstealthaddress(const Array& params, bool fHelp)
if (fHelp || params.size() > 1)
throw runtime_error(
"getnewstealthaddress [label]\n"
"Returns a new OpalCoin stealth address for receiving payments anonymously. ");
"Returns a new Verge stealth address for receiving payments anonymously. ");

if (pwalletMain->IsLocked())
throw runtime_error("Failed: Wallet must be unlocked.");
Expand Down Expand Up @@ -1978,7 +1978,7 @@ Value sendtostealthaddress(const Array& params, bool fHelp)

if (!sxAddr.SetEncoded(sEncoded))
{
result.push_back(Pair("result", "Invalid OpalCoin stealth address."));
result.push_back(Pair("result", "Invalid Verge stealth address."));
return result;
};

Expand Down

0 comments on commit e361292

Please sign in to comment.