Skip to content
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
2 changes: 1 addition & 1 deletion src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
else if(type == Receive)
{
// Generate a new address to associate with given label
WalletModel::UnlockContext ctx(walletModel->requestUnlock());
WalletModel::UnlockContext ctx(walletModel->requestUnlock(true));
if(!ctx.isValid())
{
// Unlock wallet failed or was cancelled
Expand Down
10 changes: 8 additions & 2 deletions src/qt/askpassphrasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) :
ui->passEdit2->installEventFilter(this);
ui->passEdit3->installEventFilter(this);

switch(mode)
switch(mode)
{
case Encrypt: // Ask passphrase x2
ui->passLabel1->hide();
ui->passEdit1->hide();
ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>10 or more random characters</b>, or <b>eight or more words</b>."));
setWindowTitle(tr("Encrypt wallet"));
break;
case UnlockAnonymize:
ui->anonymizationCheckBox->setChecked(true);
ui->anonymizationCheckBox->show();
case Unlock: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
ui->passLabel2->hide();
Expand Down Expand Up @@ -73,6 +76,7 @@ AskPassphraseDialog::~AskPassphraseDialog()
void AskPassphraseDialog::setModel(WalletModel *model)
{
this->model = model;
ui->anonymizationCheckBox->setChecked(model->isAnonymizeOnlyUnlocked());
}

void AskPassphraseDialog::accept()
Expand Down Expand Up @@ -138,8 +142,9 @@ void AskPassphraseDialog::accept()
QDialog::reject(); // Cancelled
}
} break;
case UnlockAnonymize:
case Unlock:
if(!model->setWalletLocked(false, oldpass))
if(!model->setWalletLocked(false, oldpass, ui->anonymizationCheckBox->isChecked()))
{
QMessageBox::critical(this, tr("Wallet unlock failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
Expand Down Expand Up @@ -193,6 +198,7 @@ void AskPassphraseDialog::textChanged()
case Encrypt: // New passphrase x2
acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
case UnlockAnonymize: // Old passphrase x1
case Unlock: // Old passphrase x1
case Decrypt:
acceptable = !ui->passEdit1->text().isEmpty();
Expand Down
1 change: 1 addition & 0 deletions src/qt/askpassphrasedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AskPassphraseDialog : public QDialog
public:
enum Mode {
Encrypt, /**< Ask passphrase twice and encrypt */
UnlockAnonymize, /**< Ask passphrase and unlock only for anonymization */
Unlock, /**< Ask passphrase and unlock */
ChangePass, /**< Ask old passphrase + new passphrase twice */
Decrypt /**< Ask passphrase and decrypt wallet */
Expand Down
24 changes: 24 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ void BitcoinGUI::createActions()
backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
unlockWalletAction = new QAction(tr("&Unlock Wallet..."), this);
unlockWalletAction->setToolTip(tr("Unlock wallet"));
lockWalletAction = new QAction(tr("&Lock Wallet"), this);
lockWalletAction->setToolTip(tr("Lock wallet"));
signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
signMessageAction->setStatusTip(tr("Sign messages with your DarkCoin addresses to prove you own them"));
verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);
Expand All @@ -256,6 +260,8 @@ void BitcoinGUI::createActions()
connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool)));
connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
connect(unlockWalletAction, SIGNAL(triggered()), walletFrame, SLOT(unlockWallet()));
connect(lockWalletAction, SIGNAL(triggered()), walletFrame, SLOT(lockWallet()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
}
Expand All @@ -281,6 +287,8 @@ void BitcoinGUI::createMenuBar()
QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
settings->addAction(encryptWalletAction);
settings->addAction(changePassphraseAction);
settings->addAction(unlockWalletAction);
settings->addAction(lockWalletAction);
settings->addSeparator();
settings->addAction(optionsAction);

Expand Down Expand Up @@ -810,6 +818,8 @@ void BitcoinGUI::setEncryptionStatus(int status)
labelEncryptionIcon->hide();
encryptWalletAction->setChecked(false);
changePassphraseAction->setEnabled(false);
unlockWalletAction->setVisible(false);
lockWalletAction->setVisible(false);
encryptWalletAction->setEnabled(true);
break;
case WalletModel::Unlocked:
Expand All @@ -818,6 +828,18 @@ void BitcoinGUI::setEncryptionStatus(int status)
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(false);
lockWalletAction->setVisible(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break;
case WalletModel::UnlockedForAnonymizationOnly:
labelEncryptionIcon->show();
labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b> for anonimization only"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(true);
lockWalletAction->setVisible(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break;
case WalletModel::Locked:
Expand All @@ -826,6 +848,8 @@ void BitcoinGUI::setEncryptionStatus(int status)
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(true);
lockWalletAction->setVisible(false);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class BitcoinGUI : public QMainWindow
QAction *encryptWalletAction;
QAction *backupWalletAction;
QAction *changePassphraseAction;
QAction *unlockWalletAction;
QAction *lockWalletAction;
QAction *aboutQtAction;
QAction *openRPCConsoleAction;

Expand Down
16 changes: 16 additions & 0 deletions src/qt/forms/askpassphrasedialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="anonymizationCheckBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Serves to disable the trivial sendmoney when OS account compromised. Provides no real security.</string>
</property>
<property name="text">
<string>For anonymization only</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down
10 changes: 5 additions & 5 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void OptionsDialog::setSaveButtonState(bool fState)
ui->okButton->setEnabled(fState);
}

void OptionsDialog::on_resetButton_clicked()
/*void OptionsDialog::on_resetButton_clicked()
{
if(model)
{
Expand All @@ -197,18 +197,18 @@ void OptionsDialog::on_resetButton_clicked()

disableApplyButton();

/* disable restart warning messages display */
// disable restart warning messages display
fRestartWarningDisplayed_Lang = fRestartWarningDisplayed_Proxy = true;

/* reset all options and save the default values (QSettings) */
// reset all options and save the default values (QSettings)
model->Reset();
mapper->toFirst();
mapper->submit();

/* re-enable restart warning messages display */
// re-enable restart warning messages display
fRestartWarningDisplayed_Lang = fRestartWarningDisplayed_Proxy = false;
}
}
}*/

void OptionsDialog::on_okButton_clicked()
{
Expand Down
2 changes: 1 addition & 1 deletion src/qt/optionsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private slots:
void disableSaveButtons();
/* set apply button and OK button state (enabled / disabled) */
void setSaveButtonState(bool fState);
void on_resetButton_clicked();
// void on_resetButton_clicked();
void on_okButton_clicked();
void on_cancelButton_clicked();
void on_applyButton_clicked();
Expand Down
13 changes: 9 additions & 4 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ void OverviewPage::darkSendStatus()

ui->darksendEnabled->setText("Disabled");
ui->darksendStatus->setText("");
ui->toggleDarksend->setText("Start Darksend Mixing");
}

return;
Expand All @@ -298,17 +299,21 @@ void OverviewPage::darkSendStatus()

if (pwalletMain->GetBalance() - pwalletMain->GetAnonymizedBalance() > 2*COIN){
if (walletModel->getEncryptionStatus() != WalletModel::Unencrypted){
if((nAnonymizeDarkcoinAmount*COIN)-pwalletMain->GetAnonymizedBalance() > 1.1*COIN && walletModel->getEncryptionStatus() == WalletModel::Locked){
WalletModel::UnlockContext ctx(walletModel->requestUnlock());
if((nAnonymizeDarkcoinAmount*COIN)-pwalletMain->GetAnonymizedBalance() > 1.1*COIN &&
walletModel->getEncryptionStatus() == WalletModel::Locked){

WalletModel::UnlockContext ctx(walletModel->requestUnlock(false));
if(!ctx.isValid()){
//unlock was cancelled
fEnableDarksend = false;
darkSendPool.cachedNumBlocks = 0;
LogPrintf("Wallet is locked and user declined to unlock. Disabling Darksend.\n");
}
}
if((nAnonymizeDarkcoinAmount*COIN)-pwalletMain->GetAnonymizedBalance() <= 1.1*COIN &&
walletModel->getEncryptionStatus() == WalletModel::Unlocked &&
walletModel->getEncryptionStatus() == WalletModel::Unlocked &&
darkSendPool.GetMyTransactionCount() == 0){

LogPrintf("Darksend is complete, locking wallet.\n");
walletModel->Lock();
}
Expand Down Expand Up @@ -413,4 +418,4 @@ void OverviewPage::toggleDarksend(){

darkSendPool.DoAutomaticDenominating();
}
}
}
7 changes: 6 additions & 1 deletion src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void SendCoinsDialog::on_sendButton_clicked()
return;
}

WalletModel::UnlockContext ctx(model->requestUnlock());
WalletModel::UnlockContext ctx(model->requestUnlock(true));
if(!ctx.isValid())
{
// Unlock wallet was cancelled
Expand Down Expand Up @@ -235,6 +235,11 @@ void SendCoinsDialog::on_sendButton_clicked()
tr("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."),
QMessageBox::Ok, QMessageBox::Ok);
break;
case WalletModel::AnonymizeOnlyUnlocked:
QMessageBox::warning(this, tr("Send Coins"),
tr("Error: The wallet was unlocked only to anonymize coins."),
QMessageBox::Ok, QMessageBox::Ok);
break;
case WalletModel::Aborted: // User aborted, nothing to do
break;
case WalletModel::OK:
Expand Down
2 changes: 1 addition & 1 deletion src/qt/signverifymessagedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
return;
}

WalletModel::UnlockContext ctx(model->requestUnlock());
WalletModel::UnlockContext ctx(model->requestUnlock(true));
if (!ctx.isValid())
{
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
Expand Down
7 changes: 7 additions & 0 deletions src/qt/walletframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ void WalletFrame::unlockWallet()
walletView->unlockWallet();
}

void WalletFrame::lockWallet()
{
WalletView *walletView = currentWalletView();
if (walletView)
walletView->lockWallet();
}

void WalletFrame::setEncryptionStatus()
{
WalletView *walletView = currentWalletView();
Expand Down
2 changes: 2 additions & 0 deletions src/qt/walletframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public slots:
void changePassphrase();
/** Ask for passphrase to unlock wallet temporarily */
void unlockWallet();
/** Lock wallet */
void lockWallet();

/** Set the encryption status as shown in the UI.
@param[in] status current encryption status
Expand Down
33 changes: 28 additions & 5 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
return OK;
}

if(isAnonymizeOnlyUnlocked())
{
return AnonymizeOnlyUnlocked;
}

// Pre-check input data for validity
foreach(const SendCoinsRecipient &rcp, recipients)
{
Expand Down Expand Up @@ -290,6 +295,10 @@ WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
{
return Locked;
}
else if (wallet->fWalletUnlockAnonymizeOnly)
{
return UnlockedForAnonymizationOnly;
}
else
{
return Unlocked;
Expand All @@ -310,17 +319,18 @@ bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphr
}
}

bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase)
bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase, bool anonymizeOnly)
{
if(locked)
{
// Lock
return false; //wallet->Lock();
// return false; //wallet->Lock();
return wallet->Lock();
}
else
{
// Unlock
return wallet->Unlock(passPhrase);
return wallet->Unlock(passPhrase, anonymizeOnly);
}
}

Expand All @@ -329,6 +339,11 @@ void WalletModel::Lock()
wallet->Lock();
}

bool WalletModel::isAnonymizeOnlyUnlocked()
{
return wallet->fWalletUnlockAnonymizeOnly;
}

bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass)
{
bool retval;
Expand Down Expand Up @@ -396,9 +411,16 @@ void WalletModel::unsubscribeFromCoreSignals()
}

// WalletModel::UnlockContext implementation
WalletModel::UnlockContext WalletModel::requestUnlock()
WalletModel::UnlockContext WalletModel::requestUnlock(bool relock)
{
bool was_locked = getEncryptionStatus() == Locked;

if (!was_locked && isAnonymizeOnlyUnlocked())
{
setWalletLocked(true);
was_locked = getEncryptionStatus() == Locked;
}

if(was_locked)
{
// Request UI to unlock wallet
Expand All @@ -407,7 +429,8 @@ WalletModel::UnlockContext WalletModel::requestUnlock()
// If wallet is still locked, unlock was failed or cancelled, mark context as invalid
bool valid = getEncryptionStatus() != Locked;

return UnlockContext(this, valid, was_locked);
return UnlockContext(this, valid, relock);
// return UnlockContext(this, valid, was_locked && !isAnonymizeOnlyUnlocked());
}

WalletModel::UnlockContext::UnlockContext(WalletModel *wallet, bool valid, bool relock):
Expand Down
Loading