Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added password prompt for CFund payment/proposal dialogs #474

Merged
merged 1 commit into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions src/qt/communityfundcreatepaymentrequestdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#include "communityfundcreatepaymentrequestdialog.h"
#include "ui_communityfundcreatepaymentrequestdialog.h"
#include "communityfundsuccessdialog.h"
#include "sendcommunityfunddialog.h"
#include "ui_communityfundcreatepaymentrequestdialog.h"

#include <QMessageBox>
#include <string>

#include "base58.h"
#include "consensus/cfund.h"
#include "main.h"
#include "main.cpp"
#include "guiconstants.h"
#include "skinize.h"
#include "guiutil.h"
#include "main.cpp"
#include "main.h"
#include "skinize.h"
#include "sync.h"
#include "wallet/wallet.h"
#include "base58.h"
#include <string>
#include "walletmodel.h"

std::string random_str(size_t length)
{
Expand All @@ -33,14 +35,20 @@ std::string random_str(size_t length)

CommunityFundCreatePaymentRequestDialog::CommunityFundCreatePaymentRequestDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CommunityFundCreatePaymentRequestDialog)
ui(new Ui::CommunityFundCreatePaymentRequestDialog),
model(0)
{
ui->setupUi(this);

connect(ui->pushButtonClose, SIGNAL(clicked()), this, SLOT(reject()));
connect(ui->pushButtonSubmitPaymentRequest, SIGNAL(clicked()), SLOT(click_pushButtonSubmitPaymentRequest()));
}

void CommunityFundCreatePaymentRequestDialog::setModel(WalletModel *model)
{
this->model = model;
}

bool CommunityFundCreatePaymentRequestDialog::validate()
{
bool isValid = true;
Expand Down Expand Up @@ -131,24 +139,10 @@ void CommunityFundCreatePaymentRequestDialog::click_pushButtonSubmitPaymentReque
}

// Ensure wallet is unlocked
if (pwalletMain->IsLocked()) {
QMessageBox msgBox(this);
std::string str = "Please unlock the wallet\n";
msgBox.setText(tr(str.c_str()));
msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle("Error");
msgBox.exec();
return;
}
if (fWalletUnlockStakingOnly) {
QMessageBox msgBox(this);
std::string str = "Wallet is unlocked for staking only\n";
msgBox.setText(tr(str.c_str()));
msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle("Error");
msgBox.exec();
WalletModel::UnlockContext ctx(model->requestUnlock());
if(!ctx.isValid())
{
// Unlock wallet was cancelled
return;
}

Expand Down
7 changes: 6 additions & 1 deletion src/qt/communityfundcreatepaymentrequestdialog.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#ifndef COMMUNITYFUNDCREATEPAYMENTREQUESTDIALOG_H
#define COMMUNITYFUNDCREATEPAYMENTREQUESTDIALOG_H

#include <QDialog>
#include "../qvalidatedplaintextedit.h"
#include "uint256.h"
#include "walletmodel.h"

#include <QDialog>

namespace Ui {
class CommunityFundCreatePaymentRequestDialog;
Expand All @@ -17,8 +19,11 @@ class CommunityFundCreatePaymentRequestDialog : public QDialog
explicit CommunityFundCreatePaymentRequestDialog(QWidget *parent = 0);
~CommunityFundCreatePaymentRequestDialog();

void setModel(WalletModel *model);

private:
Ui::CommunityFundCreatePaymentRequestDialog *ui;
WalletModel *model;
bool validate();
bool isActiveProposal(uint256 hash);

Expand Down
51 changes: 23 additions & 28 deletions src/qt/communityfundcreateproposaldialog.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
#include "communityfundcreateproposaldialog.h"
#include "ui_communityfundcreateproposaldialog.h"
#include "sendcommunityfunddialog.h"
#include "communityfundsuccessdialog.h"
#include "sendcommunityfunddialog.h"
#include "ui_communityfundcreateproposaldialog.h"

#include <QMessageBox>
#include <QTextListFormat>
#include <QDialog>
#include <QMessageBox>
#include <QSpinBox>
#include <QTextListFormat>
#include <string>

#include "base58.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "sync.h"
#include "wallet/wallet.h"
#include "base58.h"
#include "main.h"
#include <string>
#include "qvalidatedspinbox.h"
#include "sync.h"
#include "wallet/wallet.h"
#include "walletmodel.h"

CommunityFundCreateProposalDialog::CommunityFundCreateProposalDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CommunityFundCreateProposalDialog)
ui(new Ui::CommunityFundCreateProposalDialog),
model(0)
{
ui->setupUi(this);
GUIUtil::setupAddressWidget(ui->lineEditNavcoinAddress, this);
Expand Down Expand Up @@ -57,6 +59,11 @@ CommunityFundCreateProposalDialog::CommunityFundCreateProposalDialog(QWidget *pa
ui->labelWarning->setText(QString::fromStdString(warning));
}

void CommunityFundCreateProposalDialog::setModel(WalletModel *model)
{
this->model = model;
}

// Validate input fields
bool CommunityFundCreateProposalDialog::validate()
{
Expand Down Expand Up @@ -103,6 +110,9 @@ void CommunityFundCreateProposalDialog::click_spinBox() {

void CommunityFundCreateProposalDialog::click_pushButtonCreateProposal()
{
if(!model)
return;

if(this->validate())
{
LOCK2(cs_main, pwalletMain->cs_wallet);
Expand Down Expand Up @@ -147,24 +157,10 @@ void CommunityFundCreateProposalDialog::click_pushButtonCreateProposal()
}

// Ensure wallet is unlocked
if (pwalletMain->IsLocked()) {
QMessageBox msgBox(this);
std::string str = "Please unlock the wallet\n";
msgBox.setText(tr(str.c_str()));
msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle("Error");
msgBox.exec();
return;
}
if (fWalletUnlockStakingOnly) {
QMessageBox msgBox(this);
std::string str = "Wallet is unlocked for staking only\n";
msgBox.setText(tr(str.c_str()));
msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle("Error");
msgBox.exec();
WalletModel::UnlockContext ctx(model->requestUnlock());
if(!ctx.isValid())
{
// Unlock wallet was cancelled
return;
}

Expand Down Expand Up @@ -197,7 +193,6 @@ void CommunityFundCreateProposalDialog::click_pushButtonCreateProposal()
return;
}
else {

// User accepted making the proposal
// Parse NavCoin address
CScript CFContributionScript;
Expand Down
8 changes: 6 additions & 2 deletions src/qt/communityfundcreateproposaldialog.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef COMMUNITYFUNDCREATEPROPOSALDIALOG_H
#define COMMUNITYFUNDCREATEPROPOSALDIALOG_H

#include <QDialog>
#include "qvalidatedspinbox.h"
#include "walletmodel.h"

#include <QDialog>

namespace Ui {
class CommunityFundCreateProposalDialog;
Expand All @@ -16,14 +18,16 @@ class CommunityFundCreateProposalDialog : public QDialog
explicit CommunityFundCreateProposalDialog(QWidget *parent = 0);
~CommunityFundCreateProposalDialog();

void setModel(WalletModel *model);

private:
Ui::CommunityFundCreateProposalDialog *ui;
WalletModel *model;
bool validate();

private Q_SLOTS:
void click_pushButtonCreateProposal();
void click_spinBox();

};

#endif // COMMUNITYFUNDCREATEPROPOSALDIALOG_H
2 changes: 2 additions & 0 deletions src/qt/communityfundpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,15 @@ void CommunityFundPage::click_radioButtonExpired()
void CommunityFundPage::click_pushButtonCreateProposal()
{
CommunityFundCreateProposalDialog dlg(this);
dlg.setModel(walletModel);
dlg.exec();
refresh(ui->radioButtonAll->isChecked(), viewing_proposals);
}

void CommunityFundPage::click_pushButtonCreatePaymentRequest()
{
CommunityFundCreatePaymentRequestDialog dlg(this);
dlg.setModel(walletModel);
dlg.exec();
refresh(ui->radioButtonAll->isChecked(), viewing_proposals);
}
Expand Down