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
27 changes: 15 additions & 12 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

QList<CAmount> CoinControlDialog::payAmounts;
bool CoinControlDialog::fSubtractFeeFromAmount = false;
CoinControlDialog::Mode CoinControlDialog::mode{CoinControlDialog::Mode::NORMAL};

bool CCoinControlWidgetItem::operator<(const QTreeWidgetItem &other) const {
int column = treeWidget()->sortColumn();
Expand Down Expand Up @@ -496,16 +497,6 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
continue;
}

// unselect non-fully-mixed, this can happen when users switch from Send to PrivateSend
if (coinControl()->IsUsingPrivateSend()) {
int nRounds = model->getRealOutpointPrivateSendRounds(outpt);
if (nRounds < CPrivateSendClientOptions::GetRounds()) {
coinControl()->UnSelect(outpt);
fUnselectedNonMixed = true;
continue;
}
}

// Quantity
nQuantity++;

Expand Down Expand Up @@ -651,10 +642,22 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
}
}

void CoinControlDialog::usePrivateSend(bool fUsePrivateSend)
{
CoinControlDialog::mode = fUsePrivateSend ? CoinControlDialog::Mode::PRIVATESEND : CoinControlDialog::Mode::NORMAL;
}

CCoinControl* CoinControlDialog::coinControl()
{
static CCoinControl coin_control;
return &coin_control;
if (CoinControlDialog::mode == CoinControlDialog::Mode::NORMAL) {
static CCoinControl coinControlNormal;
coinControlNormal.UsePrivateSend(false);
return &coinControlNormal;
} else {
static CCoinControl coinControlPrivateSend;
coinControlPrivateSend.UsePrivateSend(true);
return &coinControlPrivateSend;
}
}

void CoinControlDialog::updateView()
Expand Down
8 changes: 8 additions & 0 deletions src/qt/coincontroldialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class CoinControlDialog : public QDialog
static QList<CAmount> payAmounts;
static CCoinControl *coinControl();
static bool fSubtractFeeFromAmount;
static void usePrivateSend(bool fUsePrivateSend);

private:
Ui::CoinControlDialog *ui;
Expand Down Expand Up @@ -83,6 +84,13 @@ class CoinControlDialog : public QDialog
};
friend class CCoinControlWidgetItem;

enum class Mode {
NORMAL,
PRIVATESEND,
};

static CoinControlDialog::Mode mode;

private Q_SLOTS:
void showMenu(const QPoint &);
void copyAmount();
Expand Down
29 changes: 14 additions & 15 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ int getIndexForConfTarget(int target) {
return confTargets.size() - 1;
}

SendCoinsDialog::SendCoinsDialog(QWidget* parent) :
SendCoinsDialog::SendCoinsDialog(bool _fPrivateSend, QWidget* parent) :
QDialog(parent),
ui(new Ui::SendCoinsDialog),
clientModel(0),
model(0),
fNewRecipientAllowed(true),
fFeeMinimized(true),
fPrivateSend(false)
fPrivateSend(_fPrivateSend)
{
ui->setupUi(this);

Expand Down Expand Up @@ -155,6 +155,14 @@ SendCoinsDialog::SendCoinsDialog(QWidget* parent) :
ui->customFee->setValue(settings.value("nTransactionFee").toLongLong());
ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool());
minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool());

if (fPrivateSend) {
ui->sendButton->setText("PrivateS&end");
ui->sendButton->setToolTip("Confirm the PrivateSend action");
} else {
ui->sendButton->setText("S&end");
ui->sendButton->setToolTip("Confirm the send action");
}
}

void SendCoinsDialog::setClientModel(ClientModel *_clientModel)
Expand Down Expand Up @@ -632,7 +640,6 @@ void SendCoinsDialog::updateDisplayUnit()
{
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance(),
model->getWatchBalance(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance());
CoinControlDialog::coinControl()->UsePrivateSend(fPrivateSend);
coinControlUpdateLabels();
ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
updateMinFeeLabel();
Expand Down Expand Up @@ -791,19 +798,11 @@ void SendCoinsDialog::updateCoinControlState(CCoinControl& ctrl)
ctrl.m_confirm_target = getConfTargetForIndex(ui->confTargetSelector->currentIndex());
}

void SendCoinsDialog::setPrivateSend(bool privateSend)
void SendCoinsDialog::showEvent(QShowEvent* event)
{
if (fPrivateSend != privateSend) {
fPrivateSend = privateSend;
coinControlUpdateLabels();
updateDisplayUnit();
if (privateSend) {
ui->sendButton->setText("PrivateS&end");
ui->sendButton->setToolTip("Confirm the PrivateSend action");
} else {
ui->sendButton->setText("S&end");
ui->sendButton->setToolTip("Confirm the send action");
}
QWidget::showEvent(event);
if (!event->spontaneous()) {
CoinControlDialog::usePrivateSend(fPrivateSend);
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/qt/sendcoinsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <QDialog>
#include <QMessageBox>
#include <QShowEvent>
#include <QString>
#include <QTimer>

Expand All @@ -32,7 +33,7 @@ class SendCoinsDialog : public QDialog
Q_OBJECT

public:
explicit SendCoinsDialog(QWidget* parent = 0);
explicit SendCoinsDialog(bool fPrivateSend = false, QWidget* parent = 0);
~SendCoinsDialog();

void setClientModel(ClientModel *clientModel);
Expand All @@ -45,7 +46,6 @@ class SendCoinsDialog : public QDialog
void setAddress(const QString &address);
void pasteEntry(const SendCoinsRecipient &rv);
bool handlePaymentRequest(const SendCoinsRecipient &recipient);
void setPrivateSend(bool privateSend);

public Q_SLOTS:
void clear();
Expand Down Expand Up @@ -77,6 +77,8 @@ public Q_SLOTS:
// Update the passed in CCoinControl with state from the GUI
void updateCoinControlState(CCoinControl& ctrl);

void showEvent(QShowEvent* event);

private Q_SLOTS:
void on_sendButton_clicked();
void on_buttonChooseFee_clicked();
Expand Down
15 changes: 10 additions & 5 deletions src/qt/walletview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ WalletView::WalletView(QWidget* parent) :

receiveCoinsPage = new ReceiveCoinsDialog();
sendCoinsPage = new SendCoinsDialog();
privateSendCoinsPage = new SendCoinsDialog(true);

usedSendingAddressesPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab, this);
usedReceivingAddressesPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab, this);
Expand All @@ -79,6 +80,7 @@ WalletView::WalletView(QWidget* parent) :
addWidget(transactionsPage);
addWidget(receiveCoinsPage);
addWidget(sendCoinsPage);
addWidget(privateSendCoinsPage);

QSettings settings;
if (settings.value("fShowMasternodesTab").toBool()) {
Expand All @@ -92,6 +94,7 @@ WalletView::WalletView(QWidget* parent) :

// Highlight transaction after send
connect(sendCoinsPage, SIGNAL(coinsSent(uint256)), transactionView, SLOT(focusTransaction(uint256)));
connect(privateSendCoinsPage, SIGNAL(coinsSent(uint256)), transactionView, SLOT(focusTransaction(uint256)));

// Double-clicking on a transaction on the transaction history page shows details
connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
Expand All @@ -102,8 +105,9 @@ WalletView::WalletView(QWidget* parent) :
// Clicking on "Export" allows to export the transaction list
connect(exportButton, SIGNAL(clicked()), transactionView, SLOT(exportClicked()));

// Pass through messages from sendCoinsPage
// Pass through messages from SendCoinsDialog
connect(sendCoinsPage, SIGNAL(message(QString,QString,unsigned int)), this, SIGNAL(message(QString,QString,unsigned int)));
connect(privateSendCoinsPage, SIGNAL(message(QString, QString, unsigned int)), this, SIGNAL(message(QString, QString, unsigned int)));

// Pass through messages from transactionView
connect(transactionView, SIGNAL(message(QString,QString,unsigned int)), this, SIGNAL(message(QString,QString,unsigned int)));
Expand All @@ -124,6 +128,7 @@ void WalletView::setBitcoinGUI(BitcoinGUI *gui)

// Navigate to transaction history page after send
connect(sendCoinsPage, SIGNAL(coinsSent(uint256)), gui, SLOT(gotoHistoryPage()));
connect(privateSendCoinsPage, SIGNAL(coinsSent(uint256)), gui, SLOT(gotoHistoryPage()));

// Receive and report messages
connect(this, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int)));
Expand All @@ -145,6 +150,7 @@ void WalletView::setClientModel(ClientModel *_clientModel)

overviewPage->setClientModel(_clientModel);
sendCoinsPage->setClientModel(_clientModel);
privateSendCoinsPage->setClientModel(_clientModel);
QSettings settings;
if (settings.value("fShowMasternodesTab").toBool()) {
masternodeListPage->setClientModel(_clientModel);
Expand All @@ -164,6 +170,7 @@ void WalletView::setWalletModel(WalletModel *_walletModel)
}
receiveCoinsPage->setModel(_walletModel);
sendCoinsPage->setModel(_walletModel);
privateSendCoinsPage->setModel(_walletModel);
usedReceivingAddressesPage->setModel(_walletModel ? _walletModel->getAddressTableModel() : nullptr);
usedSendingAddressesPage->setModel(_walletModel ? _walletModel->getAddressTableModel() : nullptr);

Expand Down Expand Up @@ -245,7 +252,6 @@ void WalletView::gotoReceiveCoinsPage()

void WalletView::gotoSendCoinsPage(QString addr)
{
sendCoinsPage->setPrivateSend(false);
setCurrentWidget(sendCoinsPage);

if (!addr.isEmpty()) {
Expand All @@ -255,11 +261,10 @@ void WalletView::gotoSendCoinsPage(QString addr)

void WalletView::gotoPrivateSendCoinsPage(QString addr)
{
sendCoinsPage->setPrivateSend(true);
setCurrentWidget(sendCoinsPage);
setCurrentWidget(privateSendCoinsPage);

if (!addr.isEmpty())
sendCoinsPage->setAddress(addr);
privateSendCoinsPage->setAddress(addr);
}

void WalletView::gotoSignMessageTab(QString addr)
Expand Down
1 change: 1 addition & 0 deletions src/qt/walletview.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class WalletView : public QStackedWidget
QWidget *transactionsPage;
ReceiveCoinsDialog *receiveCoinsPage;
SendCoinsDialog *sendCoinsPage;
SendCoinsDialog* privateSendCoinsPage;
AddressBookPage *usedSendingAddressesPage;
AddressBookPage *usedReceivingAddressesPage;
MasternodeList *masternodeListPage;
Expand Down