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;>o+mEx0Q^N)2&&zqQ0>+3>b|AGP
zU{&xrn59sYD~jZK7R3(S&s?ac$oE=oyvNhn0iHxsbKlsMSL{q5oi-_o9o%tOA^PyZ
z5Ho4d1al&zC(|k#F2BMv*rpSer!@MjEYa?%{tD?8=Ssi7Vw-&NIZD)KiHf?+IR1st
zTWd2mu5@ccitSWZEJYI+v|mHVO&KgqE#(cNE94X~nuQw4l>g%u=GebK{2GBJm_^bP
z)8zjl8jAJcpEmT%yg|cXqr(_1y%MoT;{Zh$!2jrW72$5&!SDfn(SZoc#BO3&Gj8aN*>Z5
z!1cuW4wSLH@*4Y*AHDdhLlC98ErLaZX<*}8o`Cuawh%$4WTdFHZB5pe)C$qMhOJsR
z!)JfP3lZS5V$4R5{T_p`=6#Q-YvcG=E+^EHC+&A#78HNl`3ZMpVo4;uU1=xC%bvg@
zr258s&asMfq$R85D=*jSEgiSlb>{_10dwcr#r4
z8&QO;f3*7l3jR&k|Bd>AK!-Wgk2#evB9zUs)frJi^nKx{kDV_mdLQGYQ{i1|5;Rk##!|@iRb#q+payTo_is->setFont(GUIUtil::fixedPitchFont());
+ QPixmap p1(":/icons/mininav");
+ QPixmap p2(":/icons/minixnav");
+
+ ui->fromBox->insertItem(0,"Public NAV");
+ ui->fromBox->insertItem(1,"Private xNAV");
+ ui->fromBox->setItemData(0,p1,Qt::DecorationRole);
+ ui->fromBox->setItemData(1,p2,Qt::DecorationRole);
+ ui->fromBox->setIconSize(QSize(32,32));
+
// Connect signals
connect(ui->payAmount, SIGNAL(valueChanged()), this, SIGNAL(payAmountChanged()));
connect(ui->checkboxSubtractFeeFromAmount, SIGNAL(toggled(bool)), this, SIGNAL(subtractFeeFromAmountChanged()));
@@ -51,15 +60,13 @@ SendCoinsEntry::SendCoinsEntry(const PlatformStyle *platformStyle, QWidget *pare
connect(ui->addressBookCheckBox, SIGNAL(clicked()), this, SLOT(updateAddressBook()));
connect(ui->checkboxUseFullAmount, SIGNAL(clicked()), this, SLOT(useFullAmount()));
connect(ui->checkboxCoinControl, SIGNAL(toggled(bool)), this, SLOT(_coinControlFeaturesChanged(bool)));
- connect(ui->sendPublic, SIGNAL(clicked()), this, SLOT(sendPublicChanged()));
- connect(ui->sendPrivate, SIGNAL(clicked()), this, SLOT(sendPrivateChanged()));
+ connect(ui->fromBox, SIGNAL(currentIndexChanged(int)), this, SLOT(fromChanged(int)));
QSettings settings;
bool fDefaultPrivate = settings.value("defaultprivate", false).toBool();
- ui->sendPublic->setChecked(!fDefaultPrivate);
- ui->sendPrivate->setChecked(fDefaultPrivate);
+ ui->fromBox->setCurrentIndex(fDefaultPrivate);
ui->amountLabel->setText(fDefaultPrivate ? "A&mount (xNAV):" : "A&mount (NAV):");
ui->memo->setVisible(false);
ui->memoLabel->setVisible(false);
@@ -74,22 +81,13 @@ SendCoinsEntry::~SendCoinsEntry()
delete ui;
}
-void SendCoinsEntry::sendPublicChanged()
-{
- fPrivate = !((bool)ui->sendPublic->isChecked() && ui->sendPublic->isCheckable());
- QSettings settings;
- settings.setValue("defaultprivate", !ui->sendPublic->isChecked());
- ui->amountLabel->setText(fPrivate ? "A&mount (xNAV):" : "A&mount (NAV):");
- Q_EMIT privateOrPublicChanged(false);
-}
-
-void SendCoinsEntry::sendPrivateChanged()
+void SendCoinsEntry::fromChanged(int index)
{
- fPrivate = (bool)ui->sendPrivate->isChecked() && ui->sendPrivate->isCheckable();
+ fPrivate = index;
QSettings settings;
- settings.setValue("defaultprivate", ui->sendPrivate->isChecked());
+ settings.setValue("defaultprivate", index);
ui->amountLabel->setText(fPrivate ? "A&mount (xNAV):" : "A&mount (NAV):");
- Q_EMIT privateOrPublicChanged(true);
+ Q_EMIT privateOrPublicChanged(index);
}
void SendCoinsEntry::setTotalPrivateAmount(const CAmount& amount)
@@ -110,8 +108,7 @@ void SendCoinsEntry::useFullAmount()
{
ui->payAmount->setValue(totalAmount);
ui->payAmount->setDisabled(ui->checkboxUseFullAmount->isChecked());
- ui->sendPublic->setChecked(true);
- ui->sendPrivate->setChecked(false);
+ ui->fromBox->setCurrentIndex(0);
fPrivate = false;
}
@@ -263,7 +260,7 @@ SendCoinsRecipient SendCoinsEntry::getValue()
recipient.label = ui->addAsLabel->text();
recipient.amount = ui->payAmount->value();
recipient.message = ui->memo->text();
- recipient.isanon = ui->sendPrivate->isChecked();
+ recipient.isanon = ui->fromBox->currentIndex();
recipient.fSubtractFeeFromAmount = (ui->checkboxSubtractFeeFromAmount->checkState() == Qt::Checked);
return recipient;
diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h
index 94931b847..04f757c91 100644
--- a/src/qt/sendcoinsentry.h
+++ b/src/qt/sendcoinsentry.h
@@ -69,8 +69,7 @@ private Q_SLOTS:
void on_addressBookButton_clicked();
void updateDisplayUnit();
void updateAddressBook();
- void sendPrivateChanged();
- void sendPublicChanged();
+ void fromChanged(int);
void useFullAmount();
void coinControlFeaturesChanged(bool enabled);
void _coinControlFeaturesChanged(bool enabled);
diff --git a/src/qt/swapxnav.cpp b/src/qt/swapxnav.cpp
new file mode 100644
index 000000000..faa8bdfa9
--- /dev/null
+++ b/src/qt/swapxnav.cpp
@@ -0,0 +1,342 @@
+// Copyright (c) 2020 The NavCoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include "swapxnav.h"
+
+SwapXNAVDialog::SwapXNAVDialog(QWidget *parent) :
+ layout(new QVBoxLayout)
+{
+ this->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
+ this->resize(600,250);
+ this->setLayout(layout);
+
+ QFont amountFont("Sans Serif", 8, QFont::Bold);
+ QFont titleFont("Sans Serif", 16, QFont::Bold);
+ label1 = new QLabel("");
+ label1->setFont(amountFont);
+ label2 = new QLabel("");
+ label2->setFont(amountFont);
+
+ toplabel1 = new QLabel("");
+ toplabel1->setFont(titleFont);
+ toplabel2 = new QLabel("");
+ toplabel2->setFont(titleFont);
+
+ icon1 = new QLabel("");
+ icon2 = new QLabel("");
+
+ amount = new NavCoinAmountField(0, 0);
+
+ QPixmap pixmap(":/icons/swap");
+ QIcon ButtonIcon(pixmap);
+ swapButton = new QPushButton();
+ swapButton->setIcon(ButtonIcon);
+ swapButton->setIconSize(QSize(65, 65));
+ swapButton->setFixedSize(QSize(65, 65));
+ swapButton->setFlat(true);
+
+ connect(swapButton, SIGNAL(clicked()), this, SLOT(Swap()));
+
+ fMode = false;
+
+ QHBoxLayout *iconsLayout = new QHBoxLayout();
+ QVBoxLayout *icon1Layout = new QVBoxLayout();
+ QVBoxLayout *icon2Layout = new QVBoxLayout();
+
+ icon1Layout->addWidget(toplabel1);
+ icon1Layout->addWidget(icon1);
+ icon1Layout->addWidget(label1);
+ icon1Layout->setAlignment(icon1, Qt::AlignCenter);
+ icon1Layout->setAlignment(label1, Qt::AlignCenter);
+ icon1Layout->setAlignment(toplabel1, Qt::AlignCenter);
+
+ icon2Layout->addWidget(toplabel2);
+ icon2Layout->addWidget(icon2);
+ icon2Layout->addWidget(label2);
+ icon2Layout->setAlignment(icon2, Qt::AlignCenter);
+ icon2Layout->setAlignment(label2, Qt::AlignCenter);
+ icon2Layout->setAlignment(toplabel2, Qt::AlignCenter);
+
+ iconsLayout->addLayout(icon1Layout);
+ iconsLayout->addWidget(swapButton);
+ iconsLayout->addLayout(icon2Layout);
+
+ QLabel *amountLabel = new QLabel(tr("Swap amount: "));
+ amountLabel->setFont(titleFont);
+
+ QPushButton* okButton = new QPushButton(tr("SWAP!"));
+
+ connect(okButton, SIGNAL(clicked()), this, SLOT(Ok()));
+
+ layout->addSpacing(10);
+ layout->addWidget(amountLabel);
+ layout->addWidget(amount);
+ layout->addSpacing(20);
+ layout->addLayout(iconsLayout);
+ layout->addSpacing(20);
+ layout->addWidget(okButton);
+ layout->addSpacing(10);
+
+ layout->setAlignment(amountLabel, Qt::AlignCenter);
+ layout->setAlignment(amount, Qt::AlignCenter);
+
+ Swap();
+}
+
+void SwapXNAVDialog::setModel(WalletModel *model)
+{
+ this->model = model;
+}
+
+void SwapXNAVDialog::setClientModel(ClientModel *model)
+{
+ this->clientModel = model;
+}
+
+void SwapXNAVDialog::SetPublicBalance(CAmount a)
+{
+ int unit = 0;
+
+ this->publicBalance = a;
+ if (fMode)
+ label1->setText(QString::fromStdString(_("Available: ")) + NavCoinUnits::formatWithUnit(unit, a, false, NavCoinUnits::separatorAlways, false));
+ else
+ label2->setText(QString::fromStdString(_("Available: ")) + NavCoinUnits::formatWithUnit(unit, a, false, NavCoinUnits::separatorAlways, false));
+}
+
+void SwapXNAVDialog::SetPrivateBalance(CAmount a)
+{
+ int unit = 0;
+
+ this->privateBalance = a;
+ if (fMode)
+ label2->setText(QString::fromStdString(_("Available: ")) + NavCoinUnits::formatWithUnit(unit, a, false, NavCoinUnits::separatorAlways, true));
+ else
+ label1->setText(QString::fromStdString(_("Available: ")) + NavCoinUnits::formatWithUnit(unit, a, false, NavCoinUnits::separatorAlways, true));
+}
+
+void SwapXNAVDialog::Swap()
+{
+ fMode = !fMode;
+
+ QPixmap pix(":/icons/mininav");
+ QPixmap scaled = pix.scaled(50,50,Qt::KeepAspectRatio,Qt::SmoothTransformation);
+
+ QBitmap map(50,50);
+ map.fill(Qt::color0);
+ QPainter painter( &map );
+ painter.setBrush(Qt::color1);
+ painter.drawRoundedRect( 0, 0, 50, 50,15,15);
+ scaled.setMask(map);
+
+ QPixmap pix2(":/icons/minixnav");
+ QPixmap scaled2 = pix2.scaled(50,50,Qt::KeepAspectRatio,Qt::SmoothTransformation);
+
+ QBitmap map2(50,50);
+ map2.fill(Qt::color0);
+ QPainter painter2( &map2 );
+ painter2.setBrush(Qt::color1);
+ painter2.drawRoundedRect( 0, 0, 50, 50,15,15);
+ scaled2.setMask(map2);
+
+ if (fMode)
+ {
+ toplabel1->setText(tr("From: NAV"));
+ icon1->setPixmap(scaled);
+ toplabel2->setText(tr("To: xNAV"));
+ icon2->setPixmap(scaled2);
+ }
+ else
+ {
+ toplabel1->setText(tr("From: xNAV"));
+ icon1->setPixmap(scaled2);
+ toplabel2->setText(tr("To: NAV"));
+ icon2->setPixmap(scaled);
+ }
+
+ SetPublicBalance(this->publicBalance);
+ SetPrivateBalance(this->privateBalance);
+}
+
+void SwapXNAVDialog::Ok()
+{
+ CAmount nAmount = amount->value();
+
+ if ((fMode ? publicBalance : privateBalance) < nAmount)
+
+ {
+ QMessageBox msgBox(this);
+ std::string str = tr("You don't have that many coins to swap!\n\nAvailable:\n%1").arg(NavCoinUnits::formatWithUnit(0, fMode ? publicBalance : privateBalance, false, NavCoinUnits::separatorAlways, !fMode)).toStdString();
+ msgBox.setText(tr(str.c_str()));
+ msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
+ msgBox.setIcon(QMessageBox::Warning);
+ msgBox.setWindowTitle("Insufficient NAV");
+ msgBox.exec();
+ return;
+ }
+
+ CWalletTx wtx;
+
+ // Ensure wallet is unlocked
+ WalletModel::UnlockContext ctx(model->requestUnlock());
+ if(!ctx.isValid())
+ {
+ // Unlock wallet was cancelled
+ return;
+ }
+
+ CNavCoinAddress address;
+
+ if (fMode)
+ {
+ blsctDoublePublicKey k;
+ if (pwalletMain->GetBLSCTSubAddressPublicKeys(std::make_pair(0, 0), k))
+ address = CNavCoinAddress(k);
+ else
+ {
+ QMessageBox msgBox(this);
+ msgBox.setText(tr("Swap failed: your wallet does not support receiving xNAV"));
+ msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
+ msgBox.setIcon(QMessageBox::Warning);
+ msgBox.setWindowTitle("Error");
+ msgBox.exec();
+
+ QWidget::close();
+ return;
+ }
+ }
+ else
+ {
+ if (!pwalletMain->IsLocked())
+ pwalletMain->TopUpKeyPool();
+
+ // Generate a new key that is added to wallet
+ CPubKey newKey;
+ if (!pwalletMain->GetKeyFromPool(newKey))
+ {
+ QMessageBox msgBox(this);
+ msgBox.setText(tr("Swap failed: keypool run out!"));
+ msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
+ msgBox.setIcon(QMessageBox::Warning);
+ msgBox.setWindowTitle("Error");
+ msgBox.exec();
+
+ QWidget::close();
+ return;
+ }
+ CKeyID keyID = newKey.GetID();
+
+ address = CNavCoinAddress(keyID);
+ }
+
+ CScript scriptPubKey = GetScriptForDestination(address.Get());
+
+ // Create and send the transaction
+ CReserveKey reservekey(pwalletMain);
+ CAmount nFeeRequired;
+ std::string strError;
+ vector vecSend;
+ int nChangePosRet = -1;
+ CRecipient recipient = {scriptPubKey, nAmount, true, fMode};
+ if (fMode)
+ {
+ bls::G1Element vk, sk;
+ blsctDoublePublicKey dk = boost::get(address.Get());
+
+ if (!dk.GetSpendKey(sk) || !dk.GetViewKey(vk))
+ {
+ QMessageBox msgBox(this);
+ msgBox.setText(tr("Swap failed: invalid address"));
+ msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
+ msgBox.setIcon(QMessageBox::Warning);
+ msgBox.setWindowTitle("Error");
+ msgBox.exec();
+
+ QWidget::close();
+ return;
+ }
+ recipient.sk = sk.Serialize();
+ recipient.vk = vk.Serialize();
+ recipient.sMemo = "Swap";
+ }
+ vecSend.push_back(recipient);
+
+ std::vector> reserveBLSCTKey;
+
+ for (unsigned int i = 0; i < vecSend.size()+2; i++)
+ {
+ shared_ptr rk(new CReserveBLSCTBlindingKey(pwalletMain));
+ reserveBLSCTKey.insert(reserveBLSCTKey.begin(), std::move(rk));
+ }
+
+ CandidateTransaction selectedCoins;
+
+ if (!fMode)
+ {
+ AggregationSessionDialog msd(0);
+ msd.setWalletModel(model);
+ msd.setClientModel(clientModel);
+ if (!msd.exec())
+ QMessageBox::critical(this, tr("Something failed"), tr("The mixing process failed, if you continue, the transaction would be sent with limited privacy and the source could be easily identified by an observer. Please, review your connection to the network."));
+ else
+ {
+ selectedCoins = msd.GetSelectedCoins();
+ if (selectedCoins.tx.vout.size() == 0)
+ QMessageBox::critical(this, tr("No coins for mixing"), tr("We could not find any candidate coin, if you continue, the transaction would be sent with limited privacy and the source could be easily identified by an observer. Please, review your connection to the network."));
+ }
+ }
+
+ if (pwalletMain->CreateTransaction(vecSend, wtx, reservekey, reserveBLSCTKey, nFeeRequired, nChangePosRet, strError, !fMode, NULL, true, &selectedCoins)) {
+ if (QMessageBox::No == QMessageBox(QMessageBox::Information,
+ tr("Swap!"),
+ tr("In order to swap %1 to %2, you will have to pay a fee of %3.").arg(
+ NavCoinUnits::formatWithUnit(0, nAmount, false, NavCoinUnits::separatorAlways, !fMode),
+ fMode ? "xNAV" : "NAV",
+ NavCoinUnits::formatWithUnit(0, nFeeRequired, false, NavCoinUnits::separatorAlways, !fMode))
+ +"
"+tr("You will receive a total of %1.").arg(
+ NavCoinUnits::formatWithUnit(0, nAmount - nFeeRequired, false, NavCoinUnits::separatorAlways, !fMode))
+ +"
"+tr("Do you want to continue?"),
+ QMessageBox::Yes|QMessageBox::No).exec())
+ {
+ QWidget::close();
+ return;
+ }
+ }
+ else
+ {
+ // Display something went wrong UI
+ QMessageBox msgBox(this);
+ msgBox.setText(tr("Swap failed: %1").arg(QString::fromStdString(strError)));
+ msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
+ msgBox.setIcon(QMessageBox::Warning);
+ msgBox.setWindowTitle("Error");
+ msgBox.exec();
+
+ QWidget::close();
+ return;
+ }
+
+ if (!pwalletMain->CommitTransaction(wtx, reservekey, reserveBLSCTKey)) {
+ // Display something went wrong UI
+ QMessageBox msgBox(this);
+ msgBox.setText(tr("Swap failed"));
+ msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
+ msgBox.setIcon(QMessageBox::Warning);
+ msgBox.setWindowTitle("Error");
+ msgBox.exec();
+ }
+ else
+ {
+ // Display something went wrong UI
+ QMessageBox msgBox(this);
+ msgBox.setText(tr("Swap succeded"));
+ msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
+ msgBox.setIcon(QMessageBox::Information);
+ msgBox.setWindowTitle("Ok!");
+ msgBox.exec();
+ }
+
+ QWidget::close();
+ return;
+}
diff --git a/src/qt/swapxnav.h b/src/qt/swapxnav.h
new file mode 100644
index 000000000..352d22280
--- /dev/null
+++ b/src/qt/swapxnav.h
@@ -0,0 +1,67 @@
+// Copyright (c) 2020 The NavCoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef SWAPXNAV_H
+#define SWAPXNAV_H
+
+#include "aggregationsession.h"
+#include "navcoinunits.h"
+#include "optionsmodel.h"
+#include "navcoinamountfield.h"
+#include "blsct/key.h"
+#include "wallet/wallet.h"
+#include "clientmodel.h"
+#include "walletmodel.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define DEFAULT_UNIT 0
+
+class SwapXNAVDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ SwapXNAVDialog(QWidget *parent);
+
+ void setModel(WalletModel *model);
+ void setClientModel(ClientModel *model);
+ void SetPublicBalance(CAmount a);
+ void SetPrivateBalance(CAmount a);
+
+private:
+ CAmount publicBalance;
+ CAmount privateBalance;
+
+ bool fMode;
+
+ WalletModel *model;
+ ClientModel *clientModel;
+ QVBoxLayout* layout;
+ QLabel *label1;
+ QLabel *label2;
+ QLabel *toplabel1;
+ QLabel *toplabel2;
+ QPushButton *swapButton;
+ NavCoinAmountField *amount;
+
+ QLabel *icon1;
+ QLabel *icon2;
+
+private Q_SLOTS:
+ void Swap();
+ void Ok();
+};
+
+#endif // SWAPXNAV_H
diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp
index 9da7e5bcd..d35d9771e 100644
--- a/src/qt/walletview.cpp
+++ b/src/qt/walletview.cpp
@@ -147,7 +147,7 @@ void WalletView::setWalletModel(WalletModel *walletModel)
daoPage->setWalletModel(walletModel);
receiveCoinsPage->setModel(walletModel);
requestPaymentPage->setModel(walletModel);
- requestPaymentPage->showQR();
+ requestPaymentPage->showPrivateAddress(0);
sendCoinsPage->setModel(walletModel);
usedReceivingAddressesPage->setModel(walletModel->getAddressTableModel());
usedSendingAddressesPage->setModel(walletModel->getAddressTableModel());
@@ -231,6 +231,7 @@ void WalletView::gotoReceiveCoinsPage()
}
void WalletView::gotoRequestPaymentPage(){
+ requestPaymentPage->showPrivateAddress(0);
setCurrentWidget(requestPaymentPage);
daoPage->setActive(false);
}