diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index dc29520c10..03461fc9a6 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -96,9 +96,6 @@ QT_TS = \ QT_FORMS_UI = \ qt/forms/addressbookpage.ui \ - qt/forms/blanksigmadialog.ui \ - qt/forms/sigmadialog.ui \ - qt/forms/sigmacoincontroldialog.ui \ qt/forms/askpassphrasedialog.ui \ qt/forms/automintdialog.ui \ qt/forms/automintnotification.ui \ @@ -138,8 +135,6 @@ QT_MOC_CPP = \ qt/moc_addressbookpage.cpp \ qt/moc_automintdialog.cpp \ qt/moc_automintnotification.cpp \ - qt/moc_sigmadialog.cpp \ - qt/moc_sigmacoincontroldialog.cpp \ qt/moc_addresstablemodel.cpp \ qt/moc_askpassphrasedialog.cpp \ qt/moc_bantablemodel.cpp \ @@ -231,8 +226,6 @@ BITCOIN_QT_H = \ qt/addressbookpage.h \ qt/automintdialog.h \ qt/automintnotification.h \ - qt/sigmadialog.h \ - qt/sigmacoincontroldialog.h \ qt/addresstablemodel.h \ qt/askpassphrasedialog.h \ qt/bantablemodel.h \ @@ -318,7 +311,6 @@ RES_ICONS = \ qt/res/icons/bitcoin.png \ qt/res/icons/firo.png \ qt/res/icons/zerocoin.png \ - qt/res/icons/sigma.png \ qt/res/icons/paymentcode.png \ qt/res/icons/masternodes.png \ qt/res/icons/qrcode.png \ @@ -466,8 +458,6 @@ BITCOIN_QT_WALLET_CPP = \ qt/addressbookpage.cpp \ qt/automintdialog.cpp \ qt/automintnotification.cpp \ - qt/sigmadialog.cpp \ - qt/sigmacoincontroldialog.cpp \ qt/addresstablemodel.cpp \ qt/askpassphrasedialog.cpp \ qt/coincontroldialog.cpp \ diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc index d566bde699..847d6410c7 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -29,7 +29,6 @@ res/icons/history.png res/icons/qrcode.png res/icons/zerocoin.png - res/icons/sigma.png res/icons/masternodes.png res/icons/overview.png res/icons/export.png diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 8eb97856c2..fb8a0f5191 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -34,7 +34,6 @@ #include "chainparams.h" #include "init.h" #include "lelantus.h" -#include "sigma.h" #include "ui_interface.h" #include "util.h" @@ -133,7 +132,6 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle * openRPCConsoleAction(0), openAction(0), showHelpMessageAction(0), - sigmaAction(0), lelantusAction(0), masternodeAction(0), createPcodeAction(0), @@ -364,14 +362,6 @@ void BitcoinGUI::createActions() tabGroup->addAction(historyAction); #ifdef ENABLE_WALLET - sigmaAction = new QAction(tr("Si&gma"), this); - sigmaAction->setStatusTip(tr("Anonymize your coins and perform private transfers using Sigma")); - sigmaAction->setToolTip(sigmaAction->statusTip()); - sigmaAction->setCheckable(true); - sigmaAction->setShortcut(QKeySequence(Qt::ALT + key++)); - tabGroup->addAction(sigmaAction); - sigmaAction->setVisible(false); - lelantusAction = new QAction(tr("&Lelantus"), this); lelantusAction->setStatusTip(tr("Anonymize your coins")); lelantusAction->setToolTip(lelantusAction->statusTip()); @@ -436,7 +426,7 @@ void BitcoinGUI::createActions() connect(receiveCoinsMenuAction, &QAction::triggered, this, &BitcoinGUI::gotoReceiveCoinsPage); connect(historyAction, &QAction::triggered, this, [this]{ showNormalIfMinimized(); }); connect(historyAction, &QAction::triggered, this, &BitcoinGUI::gotoHistoryPage); - connect(sigmaAction, &QAction::triggered, this, &BitcoinGUI::gotoSigmaPage); + connect(lelantusAction, &QAction::triggered, this, &BitcoinGUI::gotoLelantusPage); connect(createPcodeAction, &QAction::triggered, this, &BitcoinGUI::gotoCreatePcodePage); #ifdef ENABLE_ELYSIUM @@ -583,7 +573,6 @@ void BitcoinGUI::createToolBars() toolbar->addAction(sendCoinsAction); toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); - toolbar->addAction(sigmaAction); toolbar->addAction(lelantusAction); toolbar->addAction(masternodeAction); @@ -670,7 +659,6 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel) checkZnodeVisibility(blocks); #ifdef ENABLE_WALLET - checkSigmaVisibility(blocks); checkLelantusVisibility(blocks); #endif // ENABLE_WALLET } @@ -728,7 +716,6 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled) receiveCoinsMenuAction->setEnabled(enabled); createPcodeAction->setEnabled(enabled); historyAction->setEnabled(enabled); - sigmaAction->setEnabled(enabled); lelantusAction->setEnabled(enabled); masternodeAction->setEnabled(enabled); encryptWalletAction->setEnabled(enabled); @@ -927,12 +914,6 @@ void BitcoinGUI::gotoSignMessageTab(QString addr) if (walletFrame) walletFrame->gotoSignMessageTab(addr); } -void BitcoinGUI::gotoSigmaPage() -{ - sigmaAction->setChecked(true); - if (walletFrame) walletFrame->gotoSigmaPage(); -} - void BitcoinGUI::gotoLelantusPage() { lelantusAction->setChecked(true); @@ -1103,7 +1084,6 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer progressBar->setToolTip(tooltip); #ifdef ENABLE_WALLET - checkSigmaVisibility(count); checkLelantusVisibility(count); #endif // ENABLE_WALLET @@ -1518,17 +1498,6 @@ void BitcoinGUI::checkZnodeVisibility(int numBlocks) { } } -void BitcoinGUI::checkSigmaVisibility(int numBlocks) -{ - auto allowSigmaPage = sigma::IsSigmaAllowed(numBlocks) && !lelantus::IsLelantusAllowed(numBlocks); - if (allowSigmaPage != sigmaAction->isVisible()) { - if (!allowSigmaPage && sigmaAction->isChecked()) { - gotoOverviewPage(); - } - sigmaAction->setVisible(allowSigmaPage); - } -} - void BitcoinGUI::checkLelantusVisibility(int numBlocks) { auto allowLelantusPage = false; diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 2eecabac50..a4da2cc4d8 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -124,7 +124,6 @@ class BitcoinGUI : public QMainWindow QAction *openRPCConsoleAction; QAction *openAction; QAction *showHelpMessageAction; - QAction *sigmaAction; QAction *lelantusAction; QAction *masternodeAction; QAction *createPcodeAction; @@ -164,8 +163,6 @@ class BitcoinGUI : public QMainWindow /** Updates Znode visibility */ void checkZnodeVisibility(int numBlocks); - /** Updates Sigma visibility */ - void checkSigmaVisibility(int numBlocks); /** Updates Lelantus visibility */ void checkLelantusVisibility(int numBlocks); /** Update UI with latest network info from model. */ @@ -241,8 +238,6 @@ public Q_SLOTS: void gotoCreatePcodePage(); /** Switch to send coins page */ void gotoSendCoinsPage(QString addr = ""); - /** Switch to sigma page */ - void gotoSigmaPage(); /** Switch to lelantus page */ void gotoLelantusPage(); diff --git a/src/qt/forms/blanksigmadialog.ui b/src/qt/forms/blanksigmadialog.ui deleted file mode 100644 index 7ca4b548f5..0000000000 --- a/src/qt/forms/blanksigmadialog.ui +++ /dev/null @@ -1,38 +0,0 @@ - - - BlankSigmaDialog - - - - 0 - 0 - 770 - 395 - - - - - - - - - We have detected that your wallet does not use an HD seed. An HD seed allows you to restore all your private keys and also Sigma mints when restoring from a backup. - -To have Sigma private transactions functionality, an HD wallet is required. We highly recommend that you create a new wallet and send your funds over to the newly-created wallet or use the dumpwallet command in conjunction with importwallet to move your keys to the new wallet. If you have existing Zerocoins, they will be also ported following using dump/import wallet, and the Remint page will be accessible to you. - - - - Qt::AlignCenter - - - true - - - - - - - - - - diff --git a/src/qt/forms/sigmacoincontroldialog.ui b/src/qt/forms/sigmacoincontroldialog.ui deleted file mode 100644 index 36030e5d3c..0000000000 --- a/src/qt/forms/sigmacoincontroldialog.ui +++ /dev/null @@ -1,534 +0,0 @@ - - - SigmaCoinControlDialog - - - - 0 - 0 - 748 - 319 - - - - Coin Selection - - - - - - 0 - - - 10 - - - - - 10 - - - 10 - - - 6 - - - 6 - - - - - - 75 - true - - - - Quantity: - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - 75 - true - - - - Bytes: - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - 10 - - - 10 - - - 6 - - - 6 - - - - - - 75 - true - - - - Amount: - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0.00 FIRO - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - 75 - true - - - - Priority: - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - medium - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - 10 - - - 10 - - - 6 - - - 6 - - - - - - 75 - true - - - - Fee: - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0.00 FIRO - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - false - - - - 75 - true - - - - Dust: - - - - - - - false - - - IBeamCursor - - - Qt::ActionsContextMenu - - - no - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - 10 - - - 10 - - - 6 - - - 6 - - - - - - 75 - true - - - - After Fee: - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0.00 FIRO - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - false - - - - 75 - true - - - - Change: - - - - - - - false - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0.00 FIRO - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - - - - 0 - 40 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - - - - 14 - - - - - - 0 - 0 - - - - (un)select all - - - false - - - - - - - - 0 - 0 - - - - Tree mode - - - - - - - - 0 - 0 - - - - List mode - - - true - - - - - - - (1 locked) - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Qt::CustomContextMenu - - - false - - - 12 - - - true - - - false - - - - - - - - - Amount - - - - - Received with label - - - - - Received with address - - - - - Date - - - - - Confirmations - - - Confirmed - - - - - Priority - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - - - - - - CoinControlTreeWidget - QTreeWidget -
coincontroltreewidget.h
-
-
- - -
diff --git a/src/qt/forms/sigmadialog.ui b/src/qt/forms/sigmadialog.ui deleted file mode 100644 index e097709002..0000000000 --- a/src/qt/forms/sigmadialog.ui +++ /dev/null @@ -1,1280 +0,0 @@ - - - SigmaDialog - - - - 0 - 0 - 729 - 534 - - - - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - - - 0 - - - 10 - - - 10 - - - - - 15 - - - - - - 0 - 0 - - - - - 75 - true - - - - font-weight:bold; - - - Coin Control Features - - - - - - - - - 8 - - - 10 - - - - - - - - Inputs... - - - false - - - - - - - automatically selected - - - 5 - - - - - - - - 75 - true - - - - color:red;font-weight:bold; - - - Insufficient funds! - - - 5 - - - - - - - Qt::Horizontal - - - - 40 - 1 - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 20 - - - 0 - - - 10 - - - - - 10 - - - 14 - - - 10 - - - 4 - - - 6 - - - - - - 75 - true - - - - Quantity: - - - 0 - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0 - - - 0 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - 75 - true - - - - Bytes: - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - 10 - - - 14 - - - 6 - - - 4 - - - 6 - - - - - - 75 - true - - - - Amount: - - - 0 - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0.00 FIRO - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - 75 - true - - - - Priority: - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - medium - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - 10 - - - 14 - - - 6 - - - 4 - - - 6 - - - - - - 75 - true - - - - Fee: - - - 0 - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0.00 FIRO - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - 75 - true - - - - Dust: - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - no - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - 10 - - - 14 - - - 6 - - - 4 - - - 6 - - - - - - 75 - true - - - - After Fee: - - - 0 - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0.00 FIRO - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - 75 - true - - - - Change: - - - - - - - IBeamCursor - - - Qt::ActionsContextMenu - - - 0.00 FIRO - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - - - - - - - 12 - - - QLayout::SetDefaultConstraint - - - 5 - - - 5 - - - - - If this is activated, but the change address is empty or invalid, change will be sent to a newly generated address. - - - Custom change address - - - - - - - false - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - 3 - - - - - - - - - - Qt::Vertical - - - - 800 - 1 - - - - - - - - - - - - - - - - 75 - true - - - - Anonymized Coins: - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - QLayout::SetFixedSize - - - 10 - - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0.05 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 40 - 0 - - - - FIRO - - - Qt::AlignCenter - - - - - - - 0.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 110 - 0 - - - - - 75 - true - - - - 0.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 10 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - FIRO - - - Qt::AlignCenter - - - - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0.1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 110 - 0 - - - - - 50 - false - - - - 0.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 - - - - - Qt::Horizontal - - - - - - - - - Pending: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Spendable: - - - - - - - 0.5 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 40 - 0 - - - - FIRO - - - Qt::AlignCenter - - - - - - - 100 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 75 - true - - - - Total: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 25 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 75 - true - - - - Total: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - - - - - - - 0 - - - - Mint - - - - - - - - - - Amount to mint - - - - - - - - - - FIRO - - - - - - - Available amount to mint: - - - - - - - - 0 - 0 - - - - - 80 - 0 - - - - - 75 - true - - - - 0.00000000 FIRO - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - false - - - &Mint - - - - - - - false - - - Select Denominations - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Spend - - - - - - - - - - false - - - &Spend - - - - ../res/icons/export.png../res/icons/export.png - - - - - - - &Clear All - - - - ../res/icons/quit.png../res/icons/quit.png - - - - - - - &Add Recipient - - - - ../res/icons/add.png../res/icons/add.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - true - - - true - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - true - - - - - 0 - 0 - 685 - 169 - - - - true - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/qt/lelantusdialog.cpp b/src/qt/lelantusdialog.cpp index 4694cf56f3..be6e2ef2b2 100644 --- a/src/qt/lelantusdialog.cpp +++ b/src/qt/lelantusdialog.cpp @@ -32,9 +32,9 @@ LelantusDialog::LelantusDialog(const PlatformStyle *platformStyle, QWidget *pare setWindowTitle(tr("Lelantus")); // hide amount of global pool - ui->globalTotalCoinsAmount->setVisible(false); - ui->globalLatestGroupCoinsAmount->setVisible(false); - ui->globalUnspentAmount->setVisible(false); + // ui->globalTotalCoinsAmount->setVisible(false); + // ui->globalLatestGroupCoinsAmount->setVisible(false); + // ui->globalUnspentAmount->setVisible(false); // Coin Control connect(ui->pushButtonCoinControl, &QPushButton::clicked, this, &LelantusDialog::coinControlButtonClicked); diff --git a/src/qt/lookupspdialog.cpp b/src/qt/lookupspdialog.cpp index 9c29c28bfa..520f098106 100644 --- a/src/qt/lookupspdialog.cpp +++ b/src/qt/lookupspdialog.cpp @@ -334,7 +334,7 @@ void LookupSPDialog::updateDisplayedProperty() bool manualIssuance = sp.manual; // sigma - ui->sigmaStatusLabel->setText(QString::fromStdString(std::to_string(sp.sigmaStatus))); + // ui->sigmaStatusLabel->setText(QString::fromStdString(std::to_string(sp.sigmaStatus))); ui->denominationTable->setRowCount(0); for (size_t i = 0; i < sp.denominations.size(); i++) { diff --git a/src/qt/res/css/firo.css b/src/qt/res/css/firo.css index 0324315c6a..d99b96f80b 100644 --- a/src/qt/res/css/firo.css +++ b/src/qt/res/css/firo.css @@ -1744,38 +1744,6 @@ QStackedWidget#SendCoinsEntry .QToolButton#addressBookButton { margin-left: 10px; } -/* SigmaCoinControlDialog */ - -QDialog#SigmaCoinControlDialog QLabel#labelCoinControlQuantityText, -QDialog#SigmaCoinControlDialog QLabel#labelCoinControlBytesText, -QDialog#SigmaCoinControlDialog QLabel#labelCoinControlAmountText, -QDialog#SigmaCoinControlDialog QLabel#labelCoinControlPriorityText, -QDialog#SigmaCoinControlDialog QLabel#labelCoinControlFeeText, -QDialog#SigmaCoinControlDialog QLabel#labelCoinControlLowOutputText, -QDialog#SigmaCoinControlDialog QLabel#labelCoinControlAfterFeeText, -QDialog#SigmaCoinControlDialog QLabel#labelCoinControlChangeText { - font-weight: bold; -} - -/* SigmaDialog */ - -QWidget#SigmaDialog QLabel#labelCoinControlFeatures, -QWidget#SigmaDialog QLabel#labelCoinControlInsuffFunds, -QWidget#SigmaDialog QLabel#label_3, -QWidget#SigmaDialog QLabel#label_121, -QWidget#SigmaDialog QLabel#total, -QWidget#SigmaDialog QLabel#availableAmount, -QWidget#SigmaDialog QLabel#labelCoinControlQuantityText, -QWidget#SigmaDialog QLabel#labelCoinControlBytesText, -QWidget#SigmaDialog QLabel#labelCoinControlAmountText, -QWidget#SigmaDialog QLabel#labelCoinControlPriorityText, -QWidget#SigmaDialog QLabel#labelCoinControlFeeText, -QWidget#SigmaDialog QLabel#labelCoinControlLowOutputText, -QWidget#SigmaDialog QLabel#labelCoinControlAfterFeeText, -QWidget#SigmaDialog QLabel#labelCoinControlChangeText { - font-weight: bold; -} - /* SignVerifyMessageDialog */ QDialog#SignVerifyMessageDialog { diff --git a/src/qt/res/icons/sigma.png b/src/qt/res/icons/sigma.png deleted file mode 100644 index 41707833b2..0000000000 Binary files a/src/qt/res/icons/sigma.png and /dev/null differ diff --git a/src/qt/sigmacoincontroldialog.cpp b/src/qt/sigmacoincontroldialog.cpp deleted file mode 100644 index f9800a3d7e..0000000000 --- a/src/qt/sigmacoincontroldialog.cpp +++ /dev/null @@ -1,858 +0,0 @@ -// Copyright (c) 2011-2015 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "sigmacoincontroldialog.h" -#include "ui_sigmacoincontroldialog.h" - -#include "addresstablemodel.h" -#include "bitcoinunits.h" -#include "bitcoingui.h" -#include "guiutil.h" -#include "optionsmodel.h" -#include "platformstyle.h" -#include "txmempool.h" -#include "walletmodel.h" -#include "sigmadialog.h" - -#include "wallet/coincontrol.h" -#include "init.h" -#include "validation.h" // For minRelayTxFee -#include "wallet/wallet.h" - -#include // for 'map_list_of()' - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QList SigmaCoinControlDialog::payAmounts; -CCoinControl* SigmaCoinControlDialog::coinControl = new CCoinControl(); -bool SigmaCoinControlDialog::fSubtractFeeFromAmount = false; -bool SigmaCoinControlDialog::fMintTabSelected = true; - -bool CSigmaCoinControlWidgetItem::operator<(const QTreeWidgetItem &other) const { - int column = treeWidget()->sortColumn(); - if (column == SigmaCoinControlDialog::COLUMN_AMOUNT || column == SigmaCoinControlDialog::COLUMN_DATE || column == SigmaCoinControlDialog::COLUMN_CONFIRMATIONS) - return data(column, Qt::UserRole).toLongLong() < other.data(column, Qt::UserRole).toLongLong(); - return QTreeWidgetItem::operator<(other); -} - -SigmaCoinControlDialog::SigmaCoinControlDialog(const PlatformStyle *platformStyle, QWidget *parent) : - QDialog(parent), - ui(new Ui::SigmaCoinControlDialog), - model(0), - platformStyle(platformStyle) -{ - ui->setupUi(this); - - // context menu actions - QAction *copyAddressAction = new QAction(tr("Copy address"), this); - QAction *copyLabelAction = new QAction(tr("Copy label"), this); - QAction *copyAmountAction = new QAction(tr("Copy amount"), this); - copyTransactionHashAction = new QAction(tr("Copy transaction ID"), this); // we need to enable/disable this - lockAction = new QAction(tr("Lock unspent"), this); // we need to enable/disable this - unlockAction = new QAction(tr("Unlock unspent"), this); // we need to enable/disable this - - // context menu - contextMenu = new QMenu(this); - contextMenu->addAction(copyAddressAction); - contextMenu->addAction(copyLabelAction); - contextMenu->addAction(copyAmountAction); - contextMenu->addAction(copyTransactionHashAction); - contextMenu->addSeparator(); - contextMenu->addAction(lockAction); - contextMenu->addAction(unlockAction); - - // context menu signals - connect(ui->treeWidget, &QWidget::customContextMenuRequested, this, &SigmaCoinControlDialog::showMenu); - connect(copyAddressAction, &QAction::triggered, this, &SigmaCoinControlDialog::copyAddress); - connect(copyLabelAction, &QAction::triggered, this, &SigmaCoinControlDialog::copyLabel); - connect(copyAmountAction, &QAction::triggered, this, &SigmaCoinControlDialog::copyAmount); - connect(copyTransactionHashAction, &QAction::triggered, this, &SigmaCoinControlDialog::copyTransactionHash); - connect(lockAction, &QAction::triggered, this, &SigmaCoinControlDialog::lockCoin); - connect(unlockAction, &QAction::triggered, this, &SigmaCoinControlDialog::unlockCoin); - - // clipboard actions - QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); - QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this); - QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); - QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); - QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); - QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this); - QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this); - QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); - - connect(clipboardQuantityAction, &QAction::triggered, this, &SigmaCoinControlDialog::clipboardQuantity); - connect(clipboardAmountAction, &QAction::triggered, this, &SigmaCoinControlDialog::clipboardAmount); - connect(clipboardFeeAction, &QAction::triggered, this, &SigmaCoinControlDialog::clipboardFee); - connect(clipboardAfterFeeAction, &QAction::triggered, this, &SigmaCoinControlDialog::clipboardAfterFee); - connect(clipboardBytesAction, &QAction::triggered, this, &SigmaCoinControlDialog::clipboardBytes); - connect(clipboardLowOutputAction, &QAction::triggered, this, &SigmaCoinControlDialog::clipboardLowOutput); - connect(clipboardChangeAction, &QAction::triggered, this, &SigmaCoinControlDialog::clipboardChange); - - ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); - ui->labelCoinControlAmount->addAction(clipboardAmountAction); - ui->labelCoinControlFee->addAction(clipboardFeeAction); - ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); - ui->labelCoinControlBytes->addAction(clipboardBytesAction); - ui->labelCoinControlPriority->addAction(clipboardPriorityAction); - ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); - ui->labelCoinControlChange->addAction(clipboardChangeAction); - - // toggle tree/list mode - connect(ui->radioTreeMode, &QRadioButton::toggled, this, &SigmaCoinControlDialog::radioTreeMode); - connect(ui->radioListMode, &QRadioButton::toggled, this, &SigmaCoinControlDialog::radioListMode); - - // click on checkbox - connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &SigmaCoinControlDialog::viewItemChanged); - - // click on header -#if QT_VERSION < 0x050000 - ui->treeWidget->header()->setClickable(true); -#else - ui->treeWidget->header()->setSectionsClickable(true); -#endif - connect(ui->treeWidget->header(), &QHeaderView::sectionClicked, this, &SigmaCoinControlDialog::headerSectionClicked); - - // ok button - connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &SigmaCoinControlDialog::buttonBoxClicked); - - // (un)select all - connect(ui->pushButtonSelectAll, &QPushButton::clicked, this, &SigmaCoinControlDialog::buttonSelectAllClicked); - - // change coin control first column label due Qt4 bug. - // see https://github.com/bitcoin/bitcoin/issues/5716 - ui->treeWidget->headerItem()->setText(COLUMN_CHECKBOX, QString()); - - ui->treeWidget->setColumnWidth(COLUMN_CHECKBOX, 84); - ui->treeWidget->setColumnWidth(COLUMN_AMOUNT, 100); - ui->treeWidget->setColumnWidth(COLUMN_LABEL, 170); - ui->treeWidget->setColumnWidth(COLUMN_ADDRESS, 290); - ui->treeWidget->setColumnWidth(COLUMN_DATE, 110); - ui->treeWidget->setColumnWidth(COLUMN_CONFIRMATIONS, 100); - ui->treeWidget->setColumnWidth(COLUMN_PRIORITY, 100); - ui->treeWidget->setColumnHidden(COLUMN_TXHASH, true); // store transaction hash in this column, but don't show it - ui->treeWidget->setColumnHidden(COLUMN_VOUT_INDEX, true); // store vout index in this column, but don't show it - - // default view is sorted by amount desc - sortView(COLUMN_AMOUNT, Qt::DescendingOrder); - - // restore list mode and sortorder as a convenience feature - QSettings settings; - if (settings.contains("nCoinControlMode") && !settings.value("nCoinControlMode").toBool()) - ui->radioTreeMode->click(); - if (settings.contains("nCoinControlSortColumn") && settings.contains("nCoinControlSortOrder")) - sortView(settings.value("nCoinControlSortColumn").toInt(), ((Qt::SortOrder)settings.value("nCoinControlSortOrder").toInt())); -} - -SigmaCoinControlDialog::~SigmaCoinControlDialog() -{ - QSettings settings; - settings.setValue("nCoinControlMode", ui->radioListMode->isChecked()); - settings.setValue("nCoinControlSortColumn", sortColumn); - settings.setValue("nCoinControlSortOrder", (int)sortOrder); - - delete ui; -} - -void SigmaCoinControlDialog::setModel(WalletModel *model) -{ - this->model = model; - - if(model && model->getOptionsModel() && model->getAddressTableModel()) - { - updateView(); - updateLabelLocked(); - SigmaCoinControlDialog::updateLabels(model, this); - } -} - -// ok button -void SigmaCoinControlDialog::buttonBoxClicked(QAbstractButton* button) -{ - if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) - done(QDialog::Accepted); // closes the dialog -} - -// (un)select all -void SigmaCoinControlDialog::buttonSelectAllClicked() -{ - Qt::CheckState state = Qt::Checked; - for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) - { - if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != Qt::Unchecked) - { - state = Qt::Unchecked; - break; - } - } - ui->treeWidget->setEnabled(false); - for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) - if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != state) - ui->treeWidget->topLevelItem(i)->setCheckState(COLUMN_CHECKBOX, state); - ui->treeWidget->setEnabled(true); - if (state == Qt::Unchecked) - coinControl->UnSelectAll(); // just to be sure - SigmaCoinControlDialog::updateLabels(model, this); -} - -// context menu -void SigmaCoinControlDialog::showMenu(const QPoint &point) -{ - QTreeWidgetItem *item = ui->treeWidget->itemAt(point); - if(item) - { - contextMenuItem = item; - - // disable some items (like Copy Transaction ID, lock, unlock) for tree roots in context menu - if (item->text(COLUMN_TXHASH).length() == 64) // transaction hash is 64 characters (this means its a child node, so its not a parent node in tree mode) - { - copyTransactionHashAction->setEnabled(true); - if (model->isLockedCoin(uint256S(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt())) - { - lockAction->setEnabled(false); - unlockAction->setEnabled(true); - } - else - { - lockAction->setEnabled(true); - unlockAction->setEnabled(false); - } - } - else // this means click on parent node in tree mode -> disable all - { - copyTransactionHashAction->setEnabled(false); - lockAction->setEnabled(false); - unlockAction->setEnabled(false); - } - - // show context menu - contextMenu->exec(QCursor::pos()); - } -} - -// context menu action: copy amount -void SigmaCoinControlDialog::copyAmount() -{ - GUIUtil::setClipboard(BitcoinUnits::removeSpaces(contextMenuItem->text(COLUMN_AMOUNT))); -} - -// context menu action: copy label -void SigmaCoinControlDialog::copyLabel() -{ - if (ui->radioTreeMode->isChecked() && contextMenuItem->text(COLUMN_LABEL).length() == 0 && contextMenuItem->parent()) - GUIUtil::setClipboard(contextMenuItem->parent()->text(COLUMN_LABEL)); - else - GUIUtil::setClipboard(contextMenuItem->text(COLUMN_LABEL)); -} - -// context menu action: copy address -void SigmaCoinControlDialog::copyAddress() -{ - if (ui->radioTreeMode->isChecked() && contextMenuItem->text(COLUMN_ADDRESS).length() == 0 && contextMenuItem->parent()) - GUIUtil::setClipboard(contextMenuItem->parent()->text(COLUMN_ADDRESS)); - else - GUIUtil::setClipboard(contextMenuItem->text(COLUMN_ADDRESS)); -} - -// context menu action: copy transaction id -void SigmaCoinControlDialog::copyTransactionHash() -{ - GUIUtil::setClipboard(contextMenuItem->text(COLUMN_TXHASH)); -} - -// context menu action: lock coin -void SigmaCoinControlDialog::lockCoin() -{ - if (contextMenuItem->checkState(COLUMN_CHECKBOX) == Qt::Checked) - contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); - - COutPoint outpt(uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); - model->lockCoin(outpt); - contextMenuItem->setDisabled(true); - contextMenuItem->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed")); - updateLabelLocked(); -} - -// context menu action: unlock coin -void SigmaCoinControlDialog::unlockCoin() -{ - COutPoint outpt(uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); - model->unlockCoin(outpt); - contextMenuItem->setDisabled(false); - contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon()); - updateLabelLocked(); -} - -// copy label "Quantity" to clipboard -void SigmaCoinControlDialog::clipboardQuantity() -{ - GUIUtil::setClipboard(ui->labelCoinControlQuantity->text()); -} - -// copy label "Amount" to clipboard -void SigmaCoinControlDialog::clipboardAmount() -{ - GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" "))); -} - -// copy label "Fee" to clipboard -void SigmaCoinControlDialog::clipboardFee() -{ - GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")).replace(ASYMP_UTF8, "")); -} - -// copy label "After fee" to clipboard -void SigmaCoinControlDialog::clipboardAfterFee() -{ - GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")).replace(ASYMP_UTF8, "")); -} - -// copy label "Bytes" to clipboard -void SigmaCoinControlDialog::clipboardBytes() -{ - GUIUtil::setClipboard(ui->labelCoinControlBytes->text().replace(ASYMP_UTF8, "")); -} - -// copy label "Priority" to clipboard -void SigmaCoinControlDialog::clipboardPriority() -{ - GUIUtil::setClipboard(ui->labelCoinControlPriority->text()); -} - -// copy label "Dust" to clipboard -void SigmaCoinControlDialog::clipboardLowOutput() -{ - GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text()); -} - -// copy label "Change" to clipboard -void SigmaCoinControlDialog::clipboardChange() -{ - GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")).replace(ASYMP_UTF8, "")); -} - -// treeview: sort -void SigmaCoinControlDialog::sortView(int column, Qt::SortOrder order) -{ - sortColumn = column; - sortOrder = order; - ui->treeWidget->sortItems(column, order); - ui->treeWidget->header()->setSortIndicator(sortColumn, sortOrder); -} - -// treeview: clicked on header -void SigmaCoinControlDialog::headerSectionClicked(int logicalIndex) -{ - if (logicalIndex == COLUMN_CHECKBOX) // click on most left column -> do nothing - { - ui->treeWidget->header()->setSortIndicator(sortColumn, sortOrder); - } - else - { - if (sortColumn == logicalIndex) - sortOrder = ((sortOrder == Qt::AscendingOrder) ? Qt::DescendingOrder : Qt::AscendingOrder); - else - { - sortColumn = logicalIndex; - sortOrder = ((sortColumn == COLUMN_LABEL || sortColumn == COLUMN_ADDRESS) ? Qt::AscendingOrder : Qt::DescendingOrder); // if label or address then default => asc, else default => desc - } - - sortView(sortColumn, sortOrder); - } -} - -// toggle tree mode -void SigmaCoinControlDialog::radioTreeMode(bool checked) -{ - if (checked && model) - updateView(); -} - -// toggle list mode -void SigmaCoinControlDialog::radioListMode(bool checked) -{ - if (checked && model) - updateView(); -} - -// checkbox clicked by user -void SigmaCoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column) -{ - if (column == COLUMN_CHECKBOX && item->text(COLUMN_TXHASH).length() == 64) // transaction hash is 64 characters (this means its a child node, so its not a parent node in tree mode) - { - COutPoint outpt(uint256S(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt()); - - if (item->checkState(COLUMN_CHECKBOX) == Qt::Unchecked) - coinControl->UnSelect(outpt); - else if (item->isDisabled()) // locked (this happens if "check all" through parent node) - item->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); - else - coinControl->Select(outpt); - - // selection changed -> update labels - if (ui->treeWidget->isEnabled()) // do not update on every click for (un)select all - SigmaCoinControlDialog::updateLabels(model, this); - } - - // TODO: Remove this temporary qt5 fix after Qt5.3 and Qt5.4 are no longer used. - // Fixed in Qt5.5 and above: https://bugreports.qt.io/browse/QTBUG-43473 -#if QT_VERSION >= 0x050000 - else if (column == COLUMN_CHECKBOX && item->childCount() > 0) - { - if (item->checkState(COLUMN_CHECKBOX) == Qt::PartiallyChecked && item->child(0)->checkState(COLUMN_CHECKBOX) == Qt::PartiallyChecked) - item->setCheckState(COLUMN_CHECKBOX, Qt::Checked); - } -#endif -} - -// return human readable label for priority number -QString SigmaCoinControlDialog::getPriorityLabel(double dPriority, double mempoolEstimatePriority) -{ - double dPriorityMedium = mempoolEstimatePriority; - - if (dPriorityMedium <= 0) - dPriorityMedium = AllowFreeThreshold(); // not enough data, back to hard-coded - - if (dPriority / 1000000 > dPriorityMedium) return tr("highest"); - else if (dPriority / 100000 > dPriorityMedium) return tr("higher"); - else if (dPriority / 10000 > dPriorityMedium) return tr("high"); - else if (dPriority / 1000 > dPriorityMedium) return tr("medium-high"); - else if (dPriority > dPriorityMedium) return tr("medium"); - else if (dPriority * 10 > dPriorityMedium) return tr("low-medium"); - else if (dPriority * 100 > dPriorityMedium) return tr("low"); - else if (dPriority * 1000 > dPriorityMedium) return tr("lower"); - else return tr("lowest"); -} - -// shows count of locked unspent outputs -void SigmaCoinControlDialog::updateLabelLocked() -{ - std::vector vOutpts; - model->listLockedCoins(vOutpts); - if (vOutpts.size() > 0) - { - ui->labelLocked->setText(tr("(%1 locked)").arg(vOutpts.size())); - ui->labelLocked->setVisible(true); - } - else ui->labelLocked->setVisible(false); -} - -void SigmaCoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) -{ - if (!model) - return; - - // nPayAmount - CAmount nPayAmount = 0; - bool fDust = false; - CMutableTransaction txDummy; - Q_FOREACH(const CAmount &amount, SigmaCoinControlDialog::payAmounts) - { - nPayAmount += amount; - - if (amount > 0) - { - CTxOut txout(amount, (CScript)std::vector(24, 0)); - txDummy.vout.push_back(txout); - if (txout.IsDust(::minRelayTxFee)) - fDust = true; - } - } - - QString sPriorityLabel = tr("none"); - CAmount nAmount = 0; - CAmount nPayFee = 0; - CAmount nAfterFee = 0; - CAmount nChange = 0; - unsigned int nBytes = 0; - unsigned int nBytesInputs = 0; - double dPriority = 0; - double dPriorityInputs = 0; - unsigned int nQuantity = 0; - int nQuantityUncompressed = 0; - bool fAllowFree = false; - bool fWitness = false; - - std::vector vCoinControl; - std::vector vOutputs; - coinControl->ListSelected(vCoinControl); - model->getOutputs(vCoinControl, vOutputs, fMintTabSelected); - - BOOST_FOREACH(const COutput& out, vOutputs) { - // unselect already spent, very unlikely scenario, this could happen - // when selected are spent elsewhere, like rpc or another computer - uint256 txhash = out.tx->tx->GetHash(); - COutPoint outpt(txhash, out.i); - if (model->isSpent(outpt)) - { - coinControl->UnSelect(outpt); - continue; - } - - // Quantity - nQuantity++; - - // Amount - nAmount += out.tx->tx->vout[out.i].nValue; - - // Priority - dPriorityInputs += (double)out.tx->tx->vout[out.i].nValue * (out.nDepth+1); - if(fMintTabSelected){ - // Bytes - CTxDestination address; - int witnessversion = 0; - std::vector witnessprogram; - if (out.tx->tx->vout[out.i].scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) - { - nBytesInputs += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4); - fWitness = true; - } - else if(ExtractDestination(out.tx->tx->vout[out.i].scriptPubKey, address)) - { - CPubKey pubkey; - CKeyID *keyid = boost::get(&address); - if (keyid && model->getPubKey(*keyid, pubkey)) - { - nBytesInputs += (pubkey.IsCompressed() ? 148 : 180); - if (!pubkey.IsCompressed()) - nQuantityUncompressed++; - } - else - nBytesInputs += 148; // in all error cases, simply assume 148 here - } - else nBytesInputs += 148; - } else { - nBytesInputs += 1363; //1363 is the size of each vin containing sigma proof - } - } - - // calculation - if (nQuantity > 0) - { - // Bytes - if(fMintTabSelected) { - nBytes = nBytesInputs + - ((SigmaCoinControlDialog::payAmounts.size() > 0 ? SigmaCoinControlDialog::payAmounts.size() + 1 : 2) * 34) + 10; // always assume +1 output for change here - if (fWitness) { - // there is some fudging in these numbers related to the actual virtual transaction size calculation that will keep this estimate from being exact. - // usually, the result will be an overestimate within a couple of satoshis so that the confirmation dialog ends up displaying a slightly smaller fee. - // also, the witness stack size value value is a variable sized integer. usually, the number of stack items will be well under the single byte var int limit. - nBytes += 2; // account for the serialized marker and flag bytes - nBytes += nQuantity; // account for the witness byte that holds the number of stack items for each input. - } - } else { - //34 is the size of each normal vout, 10 is the size of empty transaction, - nBytes = nBytesInputs + SigmaCoinControlDialog::payAmounts.size() * 34 + 10; - } - - // Priority - double mempoolEstimatePriority = mempool.estimateSmartPriority(nTxConfirmTarget); - dPriority = dPriorityInputs / (nBytes - nBytesInputs + (nQuantityUncompressed * 29)); // 29 = 180 - 151 (uncompressed public keys are over the limit. max 151 bytes of the input are ignored for priority) - sPriorityLabel = SigmaCoinControlDialog::getPriorityLabel(dPriority, mempoolEstimatePriority); - - // Fee - nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool); - if (nPayFee > 0 && coinControl->nMinimumTotalFee > nPayFee) - nPayFee = coinControl->nMinimumTotalFee; - - - // Allow free? (require at least hard-coded threshold and default to that if no estimate) - double dPriorityNeeded = std::max(mempoolEstimatePriority, AllowFreeThreshold()); - fAllowFree = (dPriority >= dPriorityNeeded); - - if (fSendFreeTransactions) - if (fAllowFree && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE) - nPayFee = 0; - - if (nPayAmount > 0) { - nChange = nAmount - nPayAmount; - if (!SigmaCoinControlDialog::fSubtractFeeFromAmount) - nChange -= nPayFee; - - if (fMintTabSelected) { - // Never create dust outputs; if we would, just add the dust to the fee. - if (nChange > 0 && nChange < MIN_CHANGE) { - CTxOut txout(nChange, (CScript) std::vector(24, 0)); - if (txout.IsDust(::minRelayTxFee)) { - if (SigmaCoinControlDialog::fSubtractFeeFromAmount) // dust-change will be raised until no dust - nChange = txout.GetDustThreshold(::minRelayTxFee); - else { - nPayFee += nChange; - nChange = 0; - } - } - } - - if (nChange == 0 && !SigmaCoinControlDialog::fSubtractFeeFromAmount) - nBytes -= 34; - - } else { //adding sizes of automatic remints - std::vector denominations; - sigma::GetAllDenoms(denominations); - std::vector coinsOut; - CAmount mintedChange = CWallet::SelectMintCoinsForAmount(nChange, denominations,coinsOut); - nBytes += 44 * coinsOut.size(); //44 is the siz of each vout containing sigma mint - //add remaining to fee - nPayFee += nChange - mintedChange; - } - } - - // after fee - nAfterFee = nAmount - nPayFee; - if (nAfterFee < 0) - nAfterFee = 0; - } - - // actually update labels - int nDisplayUnit = BitcoinUnits::BTC; - if (model && model->getOptionsModel()) - nDisplayUnit = model->getOptionsModel()->getDisplayUnit(); - - QLabel *l1 = dialog->findChild("labelCoinControlQuantity"); - QLabel *l2 = dialog->findChild("labelCoinControlAmount"); - QLabel *l3 = dialog->findChild("labelCoinControlFee"); - QLabel *l4 = dialog->findChild("labelCoinControlAfterFee"); - QLabel *l5 = dialog->findChild("labelCoinControlBytes"); - QLabel *l6 = dialog->findChild("labelCoinControlPriority"); - QLabel *l7 = dialog->findChild("labelCoinControlLowOutput"); - QLabel *l8 = dialog->findChild("labelCoinControlChange"); - - // enable/disable "dust" and "change" - dialog->findChild("labelCoinControlLowOutputText")->setEnabled(nPayAmount > 0); - dialog->findChild("labelCoinControlLowOutput") ->setEnabled(nPayAmount > 0); - dialog->findChild("labelCoinControlChangeText") ->setEnabled(nPayAmount > 0); - dialog->findChild("labelCoinControlChange") ->setEnabled(nPayAmount > 0); - - // stats - l1->setText(QString::number(nQuantity)); // Quantity - l2->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAmount)); // Amount - l3->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nPayFee)); // Fee - l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); // After Fee - l5->setText(((nBytes > 0) ? ASYMP_UTF8 : "") + QString::number(nBytes)); // Bytes - l6->setText(sPriorityLabel); // Priority - l7->setText(fDust ? tr("yes") : tr("no")); // Dust - l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); // Change - if (nPayFee > 0 && (coinControl->nMinimumTotalFee < nPayFee)) - { - l3->setText(ASYMP_UTF8 + l3->text()); - l4->setText(ASYMP_UTF8 + l4->text()); - if (nChange > 0 && !SigmaCoinControlDialog::fSubtractFeeFromAmount) - l8->setText(ASYMP_UTF8 + l8->text()); - } - - // turn labels "red" - l5->setStyleSheet((nBytes >= MAX_FREE_TRANSACTION_CREATE_SIZE) ? "color:red;" : "");// Bytes >= 1000 - l6->setStyleSheet((dPriority > 0 && !fAllowFree) ? "color:red;" : ""); // Priority < "medium" - l7->setStyleSheet((fDust) ? "color:red;" : ""); // Dust = "yes" - - // tool tips - QString toolTip1 = tr("This label turns red if the transaction size is greater than 1000 bytes.") + "

"; - toolTip1 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, CWallet::GetRequiredFee(1000))) + "

"; - toolTip1 += tr("Can vary +/- 1 byte per input."); - - QString toolTip2 = tr("Transactions with higher priority are more likely to get included into a block.") + "

"; - toolTip2 += tr("This label turns red if the priority is smaller than \"medium\".") + "

"; - toolTip2 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, CWallet::GetRequiredFee(1000))); - - QString toolTip3 = tr("This label turns red if any recipient receives an amount smaller than the current dust threshold."); - - // how many satoshis the estimated fee can vary per byte we guess wrong - double dFeeVary; - if (payTxFee.GetFeePerK() > 0) - dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), payTxFee.GetFeePerK()) / 1000; - else { - dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), mempool.estimateSmartFee(nTxConfirmTarget).GetFeePerK()) / 1000; - } - QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary); - - l3->setToolTip(toolTip4); - l4->setToolTip(toolTip4); - l5->setToolTip(toolTip1); - l6->setToolTip(toolTip2); - l7->setToolTip(toolTip3); - l8->setToolTip(toolTip4); - dialog->findChild("labelCoinControlFeeText") ->setToolTip(l3->toolTip()); - dialog->findChild("labelCoinControlAfterFeeText") ->setToolTip(l4->toolTip()); - dialog->findChild("labelCoinControlBytesText") ->setToolTip(l5->toolTip()); - dialog->findChild("labelCoinControlPriorityText") ->setToolTip(l6->toolTip()); - dialog->findChild("labelCoinControlLowOutputText")->setToolTip(l7->toolTip()); - dialog->findChild("labelCoinControlChangeText") ->setToolTip(l8->toolTip()); - - // Insufficient funds - QLabel *label = dialog->findChild("labelCoinControlInsuffFunds"); - if (label) - label->setVisible(nChange < 0); -} - -void SigmaCoinControlDialog::updateView() -{ - if (!model || !model->getOptionsModel() || !model->getAddressTableModel()) - return; - - bool treeMode = ui->radioTreeMode->isChecked(); - - ui->treeWidget->clear(); - ui->treeWidget->setEnabled(false); // performance, otherwise updateLabels would be called for every checked checkbox - ui->treeWidget->setAlternatingRowColors(!treeMode); - QFlags flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; - QFlags flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate; - - int nDisplayUnit = model->getOptionsModel()->getDisplayUnit(); - double mempoolEstimatePriority = mempool.estimateSmartPriority(nTxConfirmTarget); - - std::map > mapCoins; - - if(fMintTabSelected){ - model->listCoins(mapCoins, CoinType::ALL_COINS); - }else{ - model->listCoins(mapCoins, CoinType::ONLY_MINTS); - } - - BOOST_FOREACH(const PAIRTYPE(QString, std::vector)& coins, mapCoins) { - CSigmaCoinControlWidgetItem *itemWalletAddress = new CSigmaCoinControlWidgetItem(); - itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); - QString sWalletAddress = coins.first; - QString sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress); - if (sWalletLabel.isEmpty()) - sWalletLabel = tr("(no label)"); - - if (treeMode) - { - // wallet address - ui->treeWidget->addTopLevelItem(itemWalletAddress); - - itemWalletAddress->setFlags(flgTristate); - itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); - - // label - itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel); - - // address - itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress); - } - - CAmount nSum = 0; - double dPrioritySum = 0; - int nChildren = 0; - int nInputSum = 0; - bool nIsMint = (sWalletAddress == QString::fromStdString("(mint)")); - BOOST_FOREACH(const COutput& out, coins.second) { - int nInputSize = 0; - nSum += out.tx->tx->vout[out.i].nValue; - nChildren++; - - CSigmaCoinControlWidgetItem *itemOutput; - if (treeMode) itemOutput = new CSigmaCoinControlWidgetItem(itemWalletAddress); - else itemOutput = new CSigmaCoinControlWidgetItem(ui->treeWidget); - itemOutput->setFlags(flgCheckbox); - itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked); - - // address - CTxDestination outputAddress; - QString sAddress = ""; - if(!treeMode && nIsMint){ - itemOutput->setText(COLUMN_ADDRESS, sWalletAddress); - sAddress = sWalletAddress; - } - if(ExtractDestination(out.tx->tx->vout[out.i].scriptPubKey, outputAddress)) - { - sAddress = QString::fromStdString(CBitcoinAddress(outputAddress).ToString()); - - // if listMode or change => show Firo address. In tree mode, address is not shown again for direct wallet address outputs - if (!treeMode || (!(sAddress == sWalletAddress))) - itemOutput->setText(COLUMN_ADDRESS, sAddress); - - CPubKey pubkey; - CKeyID *keyid = boost::get(&outputAddress); - if (keyid && model->getPubKey(*keyid, pubkey) && !pubkey.IsCompressed()) - nInputSize = 29; // 29 = 180 - 151 (public key is 180 bytes, priority free area is 151 bytes) - } - - // label - if (!(sAddress == sWalletAddress)) // change - { - // tooltip from where the change comes from - itemOutput->setToolTip(COLUMN_LABEL, tr("change from %1 (%2)").arg(sWalletLabel).arg(sWalletAddress)); - itemOutput->setText(COLUMN_LABEL, tr("(change)")); - } - else if (!treeMode) - { - QString sLabel = model->getAddressTableModel()->labelForAddress(sAddress); - if (sLabel.isEmpty()) - sLabel = tr("(no label)"); - itemOutput->setText(COLUMN_LABEL, sLabel); - } - - // amount - itemOutput->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, out.tx->tx->vout[out.i].nValue)); - itemOutput->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)out.tx->tx->vout[out.i].nValue)); // padding so that sorting works correctly - - // date - itemOutput->setText(COLUMN_DATE, GUIUtil::dateTimeStr(out.tx->GetTxTime())); - itemOutput->setData(COLUMN_DATE, Qt::UserRole, QVariant((qlonglong)out.tx->GetTxTime())); - - // confirmations - itemOutput->setText(COLUMN_CONFIRMATIONS, QString::number(out.nDepth)); - itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant((qlonglong)out.nDepth)); - - // priority - double dPriority = ((double)out.tx->tx->vout[out.i].nValue / (nInputSize + 78)) * (out.nDepth+1); // 78 = 2 * 34 + 10 - itemOutput->setText(COLUMN_PRIORITY, SigmaCoinControlDialog::getPriorityLabel(dPriority, mempoolEstimatePriority)); - itemOutput->setData(COLUMN_PRIORITY, Qt::UserRole, QVariant((qlonglong)dPriority)); - dPrioritySum += (double)out.tx->tx->vout[out.i].nValue * (out.nDepth+1); - nInputSum += nInputSize; - - // transaction hash - uint256 txhash = out.tx->tx->GetHash(); - itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(txhash.GetHex())); - - // vout index - itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i)); - - // disable locked coins - if (model->isLockedCoin(txhash, out.i)) - { - COutPoint outpt(txhash, out.i); - coinControl->UnSelect(outpt); // just to be sure - itemOutput->setDisabled(true); - itemOutput->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed")); - } - - // set checkbox - if (coinControl->IsSelected(COutPoint(txhash, out.i))) - itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked); - } - - // amount - if (treeMode) - { - dPrioritySum = dPrioritySum / (nInputSum + 78); - itemWalletAddress->setText(COLUMN_CHECKBOX, "(" + QString::number(nChildren) + ")"); - itemWalletAddress->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, nSum)); - itemWalletAddress->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)nSum)); - itemWalletAddress->setText(COLUMN_PRIORITY, SigmaCoinControlDialog::getPriorityLabel(dPrioritySum, mempoolEstimatePriority)); - itemWalletAddress->setData(COLUMN_PRIORITY, Qt::UserRole, QVariant((qlonglong)dPrioritySum)); - } - } - - // expand all partially selected - if (treeMode) - { - for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) - if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) == Qt::PartiallyChecked) - ui->treeWidget->topLevelItem(i)->setExpanded(true); - } - - // sort view - sortView(sortColumn, sortOrder); - ui->treeWidget->setEnabled(true); -} diff --git a/src/qt/sigmacoincontroldialog.h b/src/qt/sigmacoincontroldialog.h deleted file mode 100644 index e77669c96d..0000000000 --- a/src/qt/sigmacoincontroldialog.h +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) 2011-2015 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_QT_SIGMACOINCONTROLDIALOG_H -#define BITCOIN_QT_SIGMACOINCONTROLDIALOG_H - -#include "amount.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -class PlatformStyle; -class WalletModel; - -class CCoinControl; -class CTxMemPool; - -namespace Ui { - class SigmaCoinControlDialog; -} - -#define ASYMP_UTF8 "\xE2\x89\x88" - -class CSigmaCoinControlWidgetItem : public QTreeWidgetItem -{ -public: - CSigmaCoinControlWidgetItem(QTreeWidget *parent, int type = Type) : QTreeWidgetItem(parent, type) {} - CSigmaCoinControlWidgetItem(int type = Type) : QTreeWidgetItem(type) {} - CSigmaCoinControlWidgetItem(QTreeWidgetItem *parent, int type = Type) : QTreeWidgetItem(parent, type) {} - - bool operator<(const QTreeWidgetItem &other) const; -}; - - -class SigmaCoinControlDialog : public QDialog -{ - Q_OBJECT - -public: - explicit SigmaCoinControlDialog(const PlatformStyle *platformStyle, QWidget *parent = 0); - ~SigmaCoinControlDialog(); - - void setModel(WalletModel *model); - - // static because also called from sendcoinsdialog - static void updateLabels(WalletModel*, QDialog*); - static QString getPriorityLabel(double dPriority, double mempoolEstimatePriority); - - static QList payAmounts; - static CCoinControl *coinControl; - static bool fSubtractFeeFromAmount; - static bool fMintTabSelected; - -private: - Ui::SigmaCoinControlDialog *ui; - WalletModel *model; - int sortColumn; - Qt::SortOrder sortOrder; - - QMenu *contextMenu; - QTreeWidgetItem *contextMenuItem; - QAction *copyTransactionHashAction; - QAction *lockAction; - QAction *unlockAction; - - const PlatformStyle *platformStyle; - - void sortView(int, Qt::SortOrder); - void updateView(); - - enum - { - COLUMN_CHECKBOX = 0, - COLUMN_AMOUNT, - COLUMN_LABEL, - COLUMN_ADDRESS, - COLUMN_DATE, - COLUMN_CONFIRMATIONS, - COLUMN_PRIORITY, - COLUMN_TXHASH, - COLUMN_VOUT_INDEX, - }; - friend class CSigmaCoinControlWidgetItem; - -private Q_SLOTS: - void showMenu(const QPoint &); - void copyAmount(); - void copyLabel(); - void copyAddress(); - void copyTransactionHash(); - void lockCoin(); - void unlockCoin(); - void clipboardQuantity(); - void clipboardAmount(); - void clipboardFee(); - void clipboardAfterFee(); - void clipboardBytes(); - void clipboardPriority(); - void clipboardLowOutput(); - void clipboardChange(); - void radioTreeMode(bool); - void radioListMode(bool); - void viewItemChanged(QTreeWidgetItem*, int); - void headerSectionClicked(int); - void buttonBoxClicked(QAbstractButton*); - void buttonSelectAllClicked(); - void updateLabelLocked(); -}; - -#endif // BITCOIN_QT_SIGMACOINCONTROLDIALOG_H diff --git a/src/qt/sigmadialog.cpp b/src/qt/sigmadialog.cpp deleted file mode 100644 index cd5c09aa74..0000000000 --- a/src/qt/sigmadialog.cpp +++ /dev/null @@ -1,823 +0,0 @@ -#include "sigmadialog.h" -#include "ui_sigmadialog.h" -#include "ui_blanksigmadialog.h" - -#include "bitcoinunits.h" -#include "guiutil.h" -#include "manualmintdialog.h" -#include "optionsmodel.h" -#include "platformstyle.h" -#include "sendcoinsdialog.h" -#include "sendcoinsentry.h" -#include "walletmodel.h" - -#include "../sigma.h" -#include "../wallet/wallet.h" -#include "../wallet/walletdb.h" -#include "../sigma/coin.h" - -#include -#include - -#include -#include -#include -#include - -#include - -#define SEND_CONFIRM_DELAY 3 - -BlankSigmaDialog::BlankSigmaDialog() : - ui(new Ui::BlankSigmaDialog) -{ - ui->setupUi(this); - setWindowTitle(tr("sigma")); -} - -BlankSigmaDialog::~BlankSigmaDialog() -{ - delete ui; -} - -SigmaDialog::SigmaDialog(const PlatformStyle *platformStyle, QWidget *parent) : - QDialog(parent), - ui(new Ui::SigmaDialog), - clientModel(0), - walletModel(0), - isNewRecipientAllowed(true), - platformStyle(platformStyle) -{ - ui->setupUi(this); - setWindowTitle(tr("Sigma")); - - ui->scrollArea->setBackgroundRole(QPalette::Base); - ui->selectDenomsButton->hide(); - - if (platformStyle->getImagesOnButtons()) { - ui->sendButton->setIcon(platformStyle->SingleColorIcon(":/icons/export")); - ui->clearButton->setIcon(platformStyle->SingleColorIcon(":/icons/quit")); - ui->addButton->setIcon(platformStyle->SingleColorIcon(":/icons/add")); - - ui->mintButton->setIcon(platformStyle->SingleColorIcon(":/icons/add")); - ui->selectDenomsButton->setIcon(platformStyle->SingleColorIcon(":/icons/edit")); - } else { - ui->sendButton->setIcon(QIcon()); - ui->clearButton->setIcon(QIcon()); - ui->addButton->setIcon(QIcon()); - - ui->mintButton->setIcon(QIcon()); - ui->selectDenomsButton->setIcon(QIcon()); - } - - addEntry(); - - // init coin control section - GUIUtil::setupAddressWidget(ui->lineEditCoinControlChange, this); - - connect(ui->addButton, &QPushButton::clicked, this, &SigmaDialog::addEntry); - connect(ui->clearButton, &QPushButton::clicked, this, &SigmaDialog::clear); - // Coin Control - connect(ui->pushButtonCoinControl, &QPushButton::clicked, this, &SigmaDialog::coinControlButtonClicked); - connect(ui->checkBoxCoinControlChange, &QCheckBox::stateChanged, this, &SigmaDialog::coinControlChangeChecked); - connect(ui->lineEditCoinControlChange, &QValidatedLineEdit::textEdited, this, &SigmaDialog::coinControlChangeEdited); - // Coin Control: clipboard actions - QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); - QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this); - QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); - QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); - QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); - QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this); - QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this); - QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); - connect(clipboardQuantityAction, &QAction::triggered, this, &SigmaDialog::coinControlClipboardQuantity); - connect(clipboardAmountAction, &QAction::triggered, this, &SigmaDialog::coinControlClipboardAmount); - connect(clipboardFeeAction, &QAction::triggered, this, &SigmaDialog::coinControlClipboardFee); - connect(clipboardAfterFeeAction, &QAction::triggered, this, &SigmaDialog::coinControlClipboardAfterFee); - connect(clipboardBytesAction, &QAction::triggered, this, &SigmaDialog::coinControlClipboardBytes); - connect(clipboardPriorityAction, &QAction::triggered, this, &SigmaDialog::coinControlClipboardPriority); - connect(clipboardLowOutputAction, &QAction::triggered, this, &SigmaDialog::coinControlClipboardLowOutput); - connect(clipboardChangeAction, &QAction::triggered, this, &SigmaDialog::coinControlClipboardChange); - ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); - ui->labelCoinControlAmount->addAction(clipboardAmountAction); - ui->labelCoinControlFee->addAction(clipboardFeeAction); - ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); - ui->labelCoinControlBytes->addAction(clipboardBytesAction); - ui->labelCoinControlPriority->addAction(clipboardPriorityAction); - ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); - ui->labelCoinControlChange->addAction(clipboardChangeAction); - - connect(ui->amountToMint, &BitcoinAmountField::valueChanged, this, &SigmaDialog::coinControlUpdateLabels); - - //check if user clicked at a tab - connect(ui->tabWidget, &QTabWidget::currentChanged, this, &SigmaDialog::tabSelected); -} - -void SigmaDialog::setClientModel(ClientModel *model) -{ - this->clientModel = model; - - if (model) { - bool sigmaAllowed = sigma::IsSigmaAllowed(model->getNumBlocks()); - - connect(model, &ClientModel::numBlocksChanged, this, &SigmaDialog::numBlocksChanged); - - ui->mintButton->setEnabled(sigmaAllowed); - ui->sendButton->setEnabled(sigmaAllowed); - } -} - -void SigmaDialog::setWalletModel(WalletModel *model) -{ - this->walletModel = model; - - if (model && model->getOptionsModel()) { - connect(model, &WalletModel::balanceChanged, this, &SigmaDialog::updateMintableBalance); - connect(model, &WalletModel::updateMintable, this, &SigmaDialog::updateMintableBalance); - connect(model, &WalletModel::notifySigmaChanged, this, &SigmaDialog::updateCoins); - model->checkSigmaAmount(true); - for (int i = 0; i < ui->entries->count(); ++i) { - SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - if (entry) { - entry->setModel(model); - entry->setSubtractFeeFromAmount(true); - } - } - } - - // Coin Control - connect(model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &SigmaDialog::coinControlUpdateLabels); - connect(model->getOptionsModel(), &OptionsModel::coinControlFeaturesChanged, this, &SigmaDialog::coinControlFeatureChanged); - ui->frameCoinControl->setVisible(model->getOptionsModel()->getCoinControlFeatures()); - coinControlUpdateLabels(); -} - -void SigmaDialog::tabSelected(){ - bool coinControlSelected = walletModel->getOptionsModel()->getCoinControlFeatures(); - if(ui->tabWidget->currentIndex()==0){ - SigmaCoinControlDialog::fMintTabSelected = true; - if(coinControlSelected) - ui->coinControlChange->show(); - } - if(ui->tabWidget->currentIndex()==1){ - SigmaCoinControlDialog::fMintTabSelected = false; - if(coinControlSelected) - ui->coinControlChange->hide(); - } - // reset the coin control window on a tab change (preserves the backend so the state is the same when returning) - if(coinControlSelected) - coinControlUpdateLabels(); -} - -SigmaDialog::~SigmaDialog() -{ - delete ui; -} - -void SigmaDialog::numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header) -{ - if (!header) { - bool sigmaAllowed = sigma::IsSigmaAllowed(count); - - ui->mintButton->setEnabled(sigmaAllowed); - ui->sendButton->setEnabled(sigmaAllowed); - } -} - -static QString formatAmount(CAmount n); - -void SigmaDialog::on_mintButton_clicked() -{ - auto rawAmount = ui->amountToMint->value(); - CAmount amount(rawAmount * COIN); - - // round any thing smaller than 0.01 - // if more than or equal 0.005 round to 0.01 otherwise round to 0.00 - amount = amount / CENT * CENT + ((amount % CENT >= CENT / 2) ? CENT : 0); - - // check if amount to mint is impossible to process. - std::vector denoms; - sigma::GetAllDenoms(denoms); - - auto smallestDenomination = denoms.back(); - CAmount smallestDenominationValue; - sigma::DenominationToInteger(smallestDenomination, smallestDenominationValue); - - if (amount < smallestDenominationValue) { - QMessageBox::critical(this, tr("Amount too small to mint"), - tr("Amount to mint must not be lower than %1 FIRO.").arg(formatAmount(smallestDenominationValue)), - QMessageBox::Ok, QMessageBox::Ok); - return; - } - - if (amount % smallestDenominationValue != 0) { - amount -= amount % smallestDenominationValue; - auto reply = QMessageBox::question( - this, tr("Unable to mint."), - tr("Amount to mint must be a multiple of 0.05 FIRO. Do you want to mint %1 FIRO?" - ).arg(formatAmount(amount))); - - if (reply == QMessageBox::No) { - return; - } - } - - try { - WalletModel::UnlockContext ctx(walletModel->requestUnlock()); - if (!ctx.isValid()) { - return; - } - if (walletModel->getOptionsModel()->getCoinControlFeatures()){ - walletModel->sigmaMint(amount, SigmaCoinControlDialog::coinControl); - }else{ - walletModel->sigmaMint(amount); - } - } catch (const std::runtime_error& e) { - QMessageBox::critical(this, tr("Error"), - tr("You cannot mint Sigma because %1").arg(tr(e.what())), - QMessageBox::Ok, QMessageBox::Ok); - return; - } - - - - QMessageBox::information(this, tr("Success"), - tr("Sigma successfully minted"), - QMessageBox::Ok, QMessageBox::Ok); - - SigmaCoinControlDialog::coinControl->UnSelectAll(); - coinControlUpdateLabels(); - - ui->amountToMint->setValue(0); -} - -void SigmaDialog::on_sendButton_clicked() -{ - if (!walletModel || !walletModel->getOptionsModel()) - return; - - QList recipients; - bool valid = true; - - for (int i = 0; i < ui->entries->count(); ++i) { - SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - if (entry) { - if (entry->validate()) { - recipients.append(entry->getValue()); - } else { - valid = false; - } - } - } - - if (!valid || recipients.isEmpty()) { - return; - } - - isNewRecipientAllowed = false; - WalletModel::UnlockContext ctx(walletModel->requestUnlock()); - if (!ctx.isValid()) { - isNewRecipientAllowed = true; - return; - } - - // prepare transaction for getting txFee earlier - std::vector selectedCoins; - std::vector changes; - WalletModelTransaction currentTransaction(recipients); - WalletModel::SendCoinsReturn prepareStatus; - bool fChangeAddedToFee = false; - if (walletModel->getOptionsModel()->getCoinControlFeatures()){ - prepareStatus = walletModel->prepareSigmaSpendTransaction(currentTransaction, selectedCoins, changes, fChangeAddedToFee, SigmaCoinControlDialog::coinControl); - }else{ - prepareStatus = walletModel->prepareSigmaSpendTransaction(currentTransaction, selectedCoins, changes, fChangeAddedToFee); - } - - // process prepareStatus and on error generate message shown to user - processSpendCoinsReturn(prepareStatus, - BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee())); - - // Check unsafe coins - if (prepareStatus.status == WalletModel::AmountExceedsBalance) { - auto unsafeCoins = walletModel->GetUnsafeCoins(); - std::vector unsafeDenomVals; - for (const auto coin : unsafeCoins) { - unsafeDenomVals.push_back(coin.get_denomination_value()); - } - std::sort(unsafeDenomVals.begin(), unsafeDenomVals.end()); - - QString unsafeDenomsStr = tr(""); - for (const auto denomVal : unsafeDenomVals) { - sigma::CoinDenomination denom; - sigma::IntegerToDenomination(denomVal, denom); - auto denomStr = sigma::DenominationToString(denom).c_str(); - unsafeDenomsStr.append(tr("%1, ").arg(denomStr)); - } - - if (!unsafeCoins.empty()) { - unsafeDenomsStr.resize(unsafeDenomsStr.size() - 2); - unsafeDenomsStr.append(tr(" denomination")); - if (unsafeCoins.size() > 1) { - unsafeDenomsStr.append(tr("s")); - } - - QMessageBox::information(this, tr("Have unspendable coins."), - tr("To protect your privacy, we require you to wait until more people mint %1, Once this is done, your minted coin will be spendable.").arg(unsafeDenomsStr), - QMessageBox::Ok); - } - } - - if (prepareStatus.status != WalletModel::OK) { - isNewRecipientAllowed = true; - return; - } - - CAmount txFee = currentTransaction.getTransactionFee(); - CAmount totalAmount(0); - - auto walletTx = currentTransaction.getTransaction(); - - // Format confirmation message - QStringList formatted; - for (auto const &rcp : currentTransaction.getRecipients()) { - - CAmount realAmount = rcp.amount; - CScript recipientScriptPubKey = GetScriptForDestination(CBitcoinAddress(rcp.address.toStdString()).Get()); - - for (auto const &out : walletTx->tx->vout) { - if (out.scriptPubKey == recipientScriptPubKey) { - realAmount = out.nValue; - } - } - - totalAmount += realAmount; - - // generate bold amount string - QString amount = "" + BitcoinUnits::formatHtmlWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), realAmount); - amount.append(""); - - // generate monospace address string - QString address = "" + rcp.address; - address.append(""); - - QString recipientElement; - - if (!rcp.paymentRequest.IsInitialized()) { - if (rcp.label.length() > 0) { // label with address - recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label)); - recipientElement.append(QString(" (%1)").arg(address)); - } else { // just address - recipientElement = tr("%1 to %2").arg(amount, address); - } - } else if (!rcp.authenticatedMerchant.isEmpty()) { // authenticated payment request - recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant)); - } else { // unauthenticated payment request - recipientElement = tr("%1 to %2").arg(amount, address); - } - - formatted.append(recipientElement); - } - - QString questionString = tr("Are you sure you want to spend?"); - questionString.append("

%1"); - - if (txFee > 0) { - // append fee string if a fee is required - questionString.append("
"); - questionString.append(BitcoinUnits::formatHtmlWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), txFee)); - questionString.append(" "); - questionString.append(tr("added as transaction fee")); - - // append transaction size - questionString.append(" (" + QString::number((double)currentTransaction.getTransactionSize() / 1000) + " kB)"); - } - - // add total amount in all subdivision units - questionString.append("
"); - totalAmount += txFee; - QStringList alternativeUnits; - Q_FOREACH(BitcoinUnits::Unit u, BitcoinUnits::availableUnits()) { - if (u != walletModel->getOptionsModel()->getDisplayUnit()) - alternativeUnits.append(BitcoinUnits::formatHtmlWithUnit(u, totalAmount)); - } - questionString.append(tr("Total Amount %1") - .arg(BitcoinUnits::formatHtmlWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), totalAmount))); - questionString.append(QString("
(=%2)
") - .arg(alternativeUnits.join(" " + tr("or") + "
"))); - - std::string info = ""; - - if(walletTx->tx->vout.size() > recipients.size()) - info += "Change will be reminted"; - - if(fChangeAddedToFee) { - if(info == "") - info = "Amounts smaller than 0.05 are added to fee."; - else - info += " and amounts smaller than 0.05 are added to fee."; - } - - questionString.append(QString("

%1
") - .arg(tr(info.c_str()))); - - SendConfirmationDialog confirmationDialog(tr("Confirm spend coins"), - questionString.arg(formatted.join("
")), SEND_CONFIRM_DELAY, this); - - confirmationDialog.exec(); - QMessageBox::StandardButton retval = (QMessageBox::StandardButton)confirmationDialog.result(); - - if (retval != QMessageBox::Yes) { - isNewRecipientAllowed = true; - return; - } - - //reset cc - if(walletModel->getOptionsModel()->getCoinControlFeatures()) - SigmaCoinControlDialog::coinControl->SetNull(); - - // now send the prepared transaction - WalletModel::SendCoinsReturn sendStatus = walletModel->sendSigma(currentTransaction, selectedCoins, changes); - // process sendStatus and on error generate message shown to user - processSpendCoinsReturn(sendStatus); - - if (sendStatus.status == WalletModel::OK) { - accept(); - SigmaCoinControlDialog::coinControl->UnSelectAll(); - coinControlUpdateLabels(); - } - - isNewRecipientAllowed = true; -} - -void SigmaDialog::clear() -{ - // Remove entries until only one left - while (ui->entries->count()) { - ui->entries->takeAt(0)->widget()->deleteLater(); - } - addEntry(); - - updateTabsAndLabels(); -} - -void SigmaDialog::accept() -{ - clear(); -} - -void SigmaDialog::reject(){} - -SendCoinsEntry *SigmaDialog::addEntry() { - SendCoinsEntry *entry = new SendCoinsEntry(platformStyle, this); - entry->setModel(walletModel); - ui->entries->addWidget(entry); - connect(entry, &SendCoinsEntry::removeEntry, this, &SigmaDialog::removeEntry); - connect(entry, &SendCoinsEntry::payAmountChanged, this, &SigmaDialog::coinControlUpdateLabels); - connect(entry, &SendCoinsEntry::subtractFeeFromAmountChanged, this, &SigmaDialog::coinControlUpdateLabels); - - // Focus the field, so that entry can start immediately - entry->clear(); - entry->setSubtractFeeFromAmount(true); - entry->setFocus(); - ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); - qApp->processEvents(); - QScrollBar* bar = ui->scrollArea->verticalScrollBar(); - if (bar) - bar->setSliderPosition(bar->maximum()); - - updateTabsAndLabels(); - return entry; -} - -void SigmaDialog::updateTabsAndLabels() -{ - setupTabChain(0); -} - -void SigmaDialog::removeEntry(SendCoinsEntry* entry) -{ - entry->hide(); - - // If the last entry is about to be removed add an empty one - if (ui->entries->count() == 1) - addEntry(); - - entry->deleteLater(); - - updateTabsAndLabels(); -} - -void SigmaDialog::updateAvailableToMintBalance(const CAmount& balance) -{ - QString formattedBalance = BitcoinUnits::formatHtmlWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), balance); - ui->availableAmount->setText(formattedBalance); -} - -void SigmaDialog::updateMintableBalance() -{ - updateAvailableToMintBalance(this->walletModel->getBalance(NULL, true)); - walletModel->checkSigmaAmount(true); -} - -// Coin Control: copy label "Quantity" to clipboard -void SigmaDialog::coinControlClipboardQuantity() -{ - GUIUtil::setClipboard(ui->labelCoinControlQuantity->text()); -} - -// Coin Control: copy label "Amount" to clipboard -void SigmaDialog::coinControlClipboardAmount() -{ - GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" "))); -} - -// Coin Control: copy label "Fee" to clipboard -void SigmaDialog::coinControlClipboardFee() -{ - GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")).replace(ASYMP_UTF8, "")); -} - -// Coin Control: copy label "After fee" to clipboard -void SigmaDialog::coinControlClipboardAfterFee() -{ - GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")).replace(ASYMP_UTF8, "")); -} - -// Coin Control: copy label "Bytes" to clipboard -void SigmaDialog::coinControlClipboardBytes() -{ - GUIUtil::setClipboard(ui->labelCoinControlBytes->text().replace(ASYMP_UTF8, "")); -} - -// Coin Control: copy label "Priority" to clipboard -void SigmaDialog::coinControlClipboardPriority() -{ - GUIUtil::setClipboard(ui->labelCoinControlPriority->text()); -} - -// Coin Control: copy label "Dust" to clipboard -void SigmaDialog::coinControlClipboardLowOutput() -{ - GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text()); -} - -// Coin Control: copy label "Change" to clipboard -void SigmaDialog::coinControlClipboardChange() -{ - GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")).replace(ASYMP_UTF8, "")); -} - -// Coin Control: update labels -void SigmaDialog::coinControlUpdateLabels() -{ - if (!walletModel || !walletModel->getOptionsModel()) - return; - - // set pay amounts - SigmaCoinControlDialog::payAmounts.clear(); - SigmaCoinControlDialog::fSubtractFeeFromAmount = false; - if(SigmaCoinControlDialog::fMintTabSelected){ - SigmaCoinControlDialog::payAmounts.append(ui->amountToMint->value() * COIN); - }else{ - for(int i = 0; i < ui->entries->count(); ++i) - { - SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - if(entry && !entry->isHidden()) - { - SendCoinsRecipient rcp = entry->getValue(); - SigmaCoinControlDialog::payAmounts.append(rcp.amount); - if (rcp.fSubtractFeeFromAmount) - SigmaCoinControlDialog::fSubtractFeeFromAmount = true; - } - } - } - - - if (SigmaCoinControlDialog::coinControl->HasSelected()) - { - - // actual coin control calculation - SigmaCoinControlDialog::updateLabels(walletModel, this); - - // show coin control stats - ui->labelCoinControlAutomaticallySelected->hide(); - ui->widgetCoinControl->show(); - } - else - { - // hide coin control stats - ui->labelCoinControlAutomaticallySelected->show(); - ui->widgetCoinControl->hide(); - ui->labelCoinControlInsuffFunds->hide(); - } -} - -// Coin Control: button inputs -> show actual coin control dialog -void SigmaDialog::coinControlButtonClicked() -{ - SigmaCoinControlDialog dlg(platformStyle); - dlg.setModel(walletModel); - dlg.exec(); - coinControlUpdateLabels(); -} - -// Coin Control: checkbox custom change address -void SigmaDialog::coinControlChangeChecked(int state) -{ - if (state == Qt::Unchecked) - { - SigmaCoinControlDialog::coinControl->destChange = CNoDestination(); - ui->labelCoinControlChangeLabel->clear(); - } - else - // use this to re-validate an already entered address - coinControlChangeEdited(ui->lineEditCoinControlChange->text()); - - ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked)); -} - -// Coin Control: custom change address changed -void SigmaDialog::coinControlChangeEdited(const QString& text) -{ - if (walletModel && walletModel->getAddressTableModel()) - { - // Default to no change address until verified - SigmaCoinControlDialog::coinControl->destChange = CNoDestination(); - ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); - - CBitcoinAddress addr = CBitcoinAddress(text.toStdString()); - - if (text.isEmpty()) // Nothing entered - { - ui->labelCoinControlChangeLabel->setText(""); - } - else if (!addr.IsValid()) // Invalid address - { - ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Firo address")); - } - else // Valid address - { - CKeyID keyid; - addr.GetKeyID(keyid); - if (!walletModel->havePrivKey(keyid)) // Unknown change address - { - ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address")); - } - else // Known change address - { - ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}"); - - // Query label - QString associatedLabel = walletModel->getAddressTableModel()->labelForAddress(text); - if (!associatedLabel.isEmpty()) - ui->labelCoinControlChangeLabel->setText(associatedLabel); - else - ui->labelCoinControlChangeLabel->setText(tr("(no label)")); - - SigmaCoinControlDialog::coinControl->destChange = addr.Get(); - } - } - } -} - -// Coin Control: settings menu - coin control enabled/disabled by user -void SigmaDialog::coinControlFeatureChanged(bool checked) -{ - ui->frameCoinControl->setVisible(checked); - - if (!checked && walletModel) // coin control features disabled - SigmaCoinControlDialog::coinControl->SetNull(); - - coinControlUpdateLabels(); -} - -QWidget *SigmaDialog::setupTabChain(QWidget *prev) -{ - for (int i = 0; i < ui->entries->count(); ++i) { - SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - if (entry) { - prev = entry->setupTabChain(prev); - } - } - QWidget::setTabOrder(prev, ui->sendButton); - QWidget::setTabOrder(ui->sendButton, ui->clearButton); - QWidget::setTabOrder(ui->clearButton, ui->addButton); - return ui->addButton; -} - -void SigmaDialog::processSpendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg) -{ - QPair msgParams; - // Default to a warning message, override if error message is needed - msgParams.second = CClientUIInterface::MSG_WARNING; - - // This comment is specific to SendCoinsDialog usage of WalletModel::SendCoinsReturn. - // WalletModel::TransactionCommitFailed is used only in WalletModel::sendCoins() - // all others are used only in WalletModel::prepareTransaction() - switch (sendCoinsReturn.status) { - case WalletModel::InvalidAddress: - msgParams.first = tr("The recipient address is not valid. Please recheck."); - break; - case WalletModel::InvalidAmount: - msgParams.first = tr("The amount to pay must be larger than 0."); - break; - case WalletModel::AmountExceedsBalance: - msgParams.first = tr("The amount exceeds your balance."); - break; - case WalletModel::AmountWithFeeExceedsBalance: - msgParams.first = tr("The total exceeds your balance when the %1 transaction fee is included.").arg(msgArg); - break; - case WalletModel::DuplicateAddress: - msgParams.first = tr("Duplicate address found: addresses should only be used once each."); - break; - case WalletModel::SigmaDisabled: - msgParams.first = tr("Sigma is disabled at this period!"); - msgParams.second = CClientUIInterface::MSG_ERROR; - break; - case WalletModel::TransactionCreationFailed: - msgParams.first = tr("Transaction creation failed!"); - msgParams.second = CClientUIInterface::MSG_ERROR; - break; - case WalletModel::TransactionCommitFailed: - msgParams.first = tr("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."); - msgParams.second = CClientUIInterface::MSG_ERROR; - break; - // case WalletModel::AbsurdFee: - // msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), maxTxFee)); - // break; - case WalletModel::PaymentRequestExpired: - msgParams.first = tr("Payment request expired."); - msgParams.second = CClientUIInterface::MSG_ERROR; - break; - case WalletModel::ExceedLimit: - msgParams.first = tr("Transaction exceeds max number of spends (35) or value (500 FIRO per transaction), please reduce the amount you wish to spend."); - msgParams.second = CClientUIInterface::MSG_ERROR; - break; - // included to prevent a compiler warning. - case WalletModel::OK: - default: - return; - } - - Q_EMIT message(tr("Send Coins"), msgParams.first, msgParams.second); -} - -static QString formatAmount(CAmount n) -{ - qint64 coin = BitcoinUnits::factor(BitcoinUnits::Unit::BTC); - - qint64 n_abs = (n > 0 ? n : -n); - qint64 quotient = n_abs / coin; - qint64 remainder = (n_abs % coin) * 100 / coin; - - QString quotient_str = QString::number(quotient); - QString remainder_str = QString::number(remainder).rightJustified(2, '0'); - - if (n < 0) - quotient_str.insert(0, '-'); - return quotient_str + QString(".") + remainder_str; -} - -void SigmaDialog::updateCoins(const std::vector& spendable, const std::vector& pending) -{ - std::unordered_map spendableDenominationCoins; - - CAmount sum(0); - int64_t denom; - for (const auto& c : spendable) { - spendableDenominationCoins[c.denom]++; - DenominationToInteger(c.denom, denom); - sum += denom; - } - - // update coins amount - int denom100Amount = spendableDenominationCoins[sigma::CoinDenomination::SIGMA_DENOM_100]; - int denom25Amount = spendableDenominationCoins[sigma::CoinDenomination::SIGMA_DENOM_25]; - int denom10Amount = spendableDenominationCoins[sigma::CoinDenomination::SIGMA_DENOM_10]; - int denom1Amount = spendableDenominationCoins[sigma::CoinDenomination::SIGMA_DENOM_1]; - int denom05Amount = spendableDenominationCoins[sigma::CoinDenomination::SIGMA_DENOM_0_5]; - int denom01Amount = spendableDenominationCoins[sigma::CoinDenomination::SIGMA_DENOM_0_1]; - int denom005Amount = spendableDenominationCoins[sigma::CoinDenomination::SIGMA_DENOM_0_05]; - - ui->amountDenom100->setText(QString::fromStdString(std::to_string(denom100Amount))); - ui->amountDenom25->setText(QString::fromStdString(std::to_string(denom25Amount))); - ui->amountDenom10->setText(QString::fromStdString(std::to_string(denom10Amount))); - ui->amountDenom1->setText(QString::fromStdString(std::to_string(denom1Amount))); - ui->amountDenom05->setText(QString::fromStdString(std::to_string(denom05Amount))); - ui->amountDenom01->setText(QString::fromStdString(std::to_string(denom01Amount))); - ui->amountDenom005->setText(QString::fromStdString(std::to_string(denom005Amount))); - - CAmount pendingSum(0); - for (const auto& c : pending) { - DenominationToInteger(c.denom, denom); - pendingSum += denom; - } - - QString pendingAmount = QString("%1").arg(formatAmount(pendingSum)); - QString spendableAmount = QString("%1").arg(formatAmount(sum)); - QString totalAmount = QString("%1").arg(formatAmount(sum + pendingSum)); - - ui->pending->setText(pendingAmount); - ui->spendable->setText(spendableAmount); - ui->total->setText(totalAmount); -} diff --git a/src/qt/sigmadialog.h b/src/qt/sigmadialog.h deleted file mode 100644 index 5b2530226e..0000000000 --- a/src/qt/sigmadialog.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef FIRO_QT_SIGMAPAGE_H -#define FIRO_QT_SIGMAPAGE_H - -#include "addresstablemodel.h" -#include "clientmodel.h" -#include "platformstyle.h" -#include "sendcoinsentry.h" -#include "coincontroldialog.h" -#include - -#include - -namespace Ui { - class SigmaDialog; - class BlankSigmaDialog; -} - -class BlankSigmaDialog : public QDialog -{ - Q_OBJECT - -public: - BlankSigmaDialog(); - ~BlankSigmaDialog(); - -private: - Ui::BlankSigmaDialog *ui; -}; - -class SigmaDialog : public QDialog -{ - Q_OBJECT - -public: - SigmaDialog(const PlatformStyle *platformStyle, QWidget *parent = 0); - ~SigmaDialog(); - - void setClientModel(ClientModel *model); - void setWalletModel(WalletModel *model); - - /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). - */ - QWidget *setupTabChain(QWidget *prev); - -public Q_SLOTS: - void clear(); - void accept(); - void reject(); - SendCoinsEntry* addEntry(); - void coinControlFeatureChanged(bool); - void updateTabsAndLabels(); - void coinControlUpdateLabels(); - void coinControlClipboardQuantity(); - void coinControlClipboardAmount(); - void coinControlClipboardFee(); - void coinControlClipboardAfterFee(); - void coinControlClipboardBytes(); - void coinControlClipboardPriority(); - void coinControlClipboardLowOutput(); - void coinControlClipboardChange(); - void coinControlButtonClicked(); - void coinControlChangeChecked(int); - void coinControlChangeEdited(const QString &); - void tabSelected(); - -private: - Ui::SigmaDialog *ui; - ClientModel *clientModel; - WalletModel *walletModel; - bool isNewRecipientAllowed; - const PlatformStyle *platformStyle; - - void processSpendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg = QString()); - -private Q_SLOTS: - void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header); - void on_mintButton_clicked(); - void on_sendButton_clicked(); - void removeEntry(SendCoinsEntry* entry); - void updateAvailableToMintBalance(const CAmount& balance); - void updateMintableBalance(); - void updateCoins(const std::vector& spendable, const std::vector& pending); - -Q_SIGNALS: - // Fired when a message should be reported to the user - void message(const QString &title, const QString &message, unsigned int style); -}; - -#endif // FIRO_QT_SIGMAPAGE_H diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index 21b38c56d7..c6609b3e12 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -194,13 +194,6 @@ void WalletFrame::gotoSignMessageTab(QString addr) walletView->gotoSignMessageTab(addr); } -void WalletFrame::gotoSigmaPage() -{ - QMap::const_iterator i; - for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) - i.value()->gotoSigmaPage(); -} - void WalletFrame::gotoLelantusPage() { QMap::const_iterator i; diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index 574b972748..5840572d79 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -87,8 +87,6 @@ public Q_SLOTS: void gotoCreatePcodePage(); /** Switch to send coins page */ void gotoSendCoinsPage(QString addr = ""); - /** Switch to sigma page */ - void gotoSigmaPage(); /** Switch to lelantus page */ void gotoLelantusPage(); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 9c72d9bbcd..61740886f0 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -214,44 +214,6 @@ void WalletModel::checkBalanceChanged() } } -void WalletModel::checkSigmaAmount(bool forced) -{ - auto currentBlock = chainActive.Height(); - if ((cachedHavePendingCoin && currentBlock > lastBlockCheckSigma) - || currentBlock < lastBlockCheckSigma // reorg - || forced) { - - auto coins = wallet->zwallet->GetTracker().ListMints(true, false, false); - - std::vector spendable, pending; - - std::vector anonimity_set; - uint256 blockHash; - - cachedHavePendingCoin = false; - - for (const auto& coin : coins) { - - // ignore spent coin - if (coin.isUsed) - continue; - - int coinHeight = coin.nHeight; - - if (coinHeight > 0 - && coinHeight + (ZC_MINT_CONFIRMATIONS-1) <= chainActive.Height()) { - spendable.push_back(coin); - } else { - cachedHavePendingCoin = true; - pending.push_back(coin); - } - } - - lastBlockCheckSigma = currentBlock; - Q_EMIT notifySigmaChanged(spendable, pending); - } -} - void WalletModel::updateTransaction() { // Balance and number of transactions might have changed @@ -1289,176 +1251,6 @@ bool WalletModel::rebroadcastTransaction(uint256 hash, CValidationState &state) return true; } -// Sigma -WalletModel::SendCoinsReturn WalletModel::prepareSigmaSpendTransaction( - WalletModelTransaction &transaction, - std::vector &selectedCoins, - std::vector &changes, - bool& fChangeAddedToFee, - const CCoinControl *coinControl) -{ - QList recipients = transaction.getRecipients(); - std::vector sendRecipients; - - if (recipients.empty()) { - return OK; - } - - QSet addresses; // Used to detect duplicates - - for (const auto& rcp : recipients) { - if (!validateAddress(rcp.address)) { - return InvalidAmount; - } - addresses.insert(rcp.address); - - CScript scriptPubKey = GetScriptForDestination(CBitcoinAddress(rcp.address.toStdString()).Get()); - CRecipient recipient = {scriptPubKey, rcp.amount, rcp.fSubtractFeeFromAmount}; - sendRecipients.push_back(recipient); - } - - if (addresses.size() != recipients.size()) { - return DuplicateAddress; - } - - // create transaction - CAmount fee; - - CWalletTx *newTx = transaction.getTransaction(); - try { - *newTx = wallet->CreateSigmaSpendTransaction(sendRecipients, fee, selectedCoins, changes, fChangeAddedToFee, coinControl); - } catch (const InsufficientFunds& err) { - return AmountExceedsBalance; - } catch (const std::runtime_error& err) { - if (_("Can not choose coins within limit.") == err.what()) - return ExceedLimit; - if (_("Sigma is disabled at this period.") == err.what()) - return SigmaDisabled; - throw err; - } catch (const std::invalid_argument& err) { - return ExceedLimit; - } - - transaction.setTransactionFee(fee); - - return SendCoinsReturn(OK); -} - -WalletModel::SendCoinsReturn WalletModel::sendSigma(WalletModelTransaction &transaction, - std::vector& coins, std::vector& changes) -{ - QByteArray transaction_array; /* store serialized transaction */ - - { - LOCK2(cs_main, wallet->cs_wallet); - CWalletTx *newTx = transaction.getTransaction(); - - for (const auto& rcp : transaction.getRecipients()) { - if (rcp.paymentRequest.IsInitialized()) - { - // Make sure any payment requests involved are still valid. - if (PaymentServer::verifyExpired(rcp.paymentRequest.getDetails())) { - return PaymentRequestExpired; - } - - // Store PaymentRequests in wtx.vOrderForm in wallet. - std::string key("PaymentRequest"); - std::string value; - rcp.paymentRequest.SerializeToString(&value); - newTx->vOrderForm.push_back(std::make_pair(key, value)); - } else if (!rcp.message.isEmpty()) { - // Message from normal firo:URI (firo:123...?message=example) - newTx->vOrderForm.push_back(std::make_pair("Message", rcp.message.toStdString())); - } - } - - try { - wallet->CommitSigmaTransaction(*newTx, coins, changes); - } catch (...) { - return TransactionCommitFailed; - } - - CTransactionRef t = newTx->tx; - CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); - ssTx << t; - transaction_array.append(&(ssTx[0]), ssTx.size()); - } - - // Add addresses / update labels that we've sent to to the address book, - // and emit coinsSent signal for each recipient - for (const auto& rcp : transaction.getRecipients()) { - // Don't touch the address book when we have a payment request - if (!rcp.paymentRequest.IsInitialized()) { - std::string address = rcp.address.toStdString(); - CTxDestination dest = CBitcoinAddress(address).Get(); - std::string label = rcp.label.toStdString(); - { - LOCK(wallet->cs_wallet); - - auto mi = wallet->mapAddressBook.find(dest); - - // Check if we have a new address or an updated label - if (mi == wallet->mapAddressBook.end()) { - wallet->SetAddressBook(dest, label, "send"); - } - else if (mi->second.name != label) { - wallet->SetAddressBook(dest, label, ""); // "" means don't change purpose - } - } - } - Q_EMIT coinsSent(wallet, rcp, transaction_array); - } - checkBalanceChanged(); - - return SendCoinsReturn(OK); -} - -void WalletModel::sigmaMint(const CAmount& n, const CCoinControl *coinControl) -{ - std::vector denominations; - sigma::GetAllDenoms(denominations); - - std::vector mints; - if (CWallet::SelectMintCoinsForAmount(n, denominations, mints) != n) { - throw std::runtime_error("Problem with coin selection.\n"); - } - - std::vector privCoins; - - const sigma::Params* sigmaParams = sigma::Params::get_default(); - std::transform(mints.begin(), mints.end(), std::back_inserter(privCoins), - [sigmaParams](const sigma::CoinDenomination& denom) -> sigma::PrivateCoin { - return sigma::PrivateCoin(sigmaParams, denom); - }); - - std::vector vDMints; - auto recipients = CWallet::CreateSigmaMintRecipients(privCoins, vDMints); - - CWalletTx wtx; - std::string strError = pwalletMain->MintAndStoreSigma(recipients, privCoins, vDMints, wtx, false, coinControl); - - if (strError != "") { - throw std::range_error(strError); - } -} - -std::vector WalletModel::GetUnsafeCoins(const CCoinControl* coinControl) -{ - auto allCoins = wallet->GetAvailableCoins(coinControl, true); - auto spendableCoins = wallet->GetAvailableCoins(coinControl); - std::vector unsafeCoins; - for (auto& coin : allCoins) { - if (spendableCoins.end() == std::find_if(spendableCoins.begin(), spendableCoins.end(), - [coin](const CSigmaEntry& spendalbe) { - return coin.value == spendalbe.value; - } - )) { - unsafeCoins.push_back(coin); - } - } - return unsafeCoins; -} - CAmount WalletModel::GetJMintCredit(const CTxOut& txout) const { return wallet->GetCredit(txout, ISMINE_SPENDABLE); } diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 70a835c554..280faeb98e 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -118,7 +118,6 @@ class WalletModel : public QObject AmountExceedsBalance, AmountWithFeeExceedsBalance, DuplicateAddress, - SigmaDisabled, TransactionCreationFailed, // Error returned when wallet is still locked TransactionCommitFailed, AbsurdFee, @@ -263,22 +262,6 @@ class WalletModel : public QObject bool transactionCanBeRebroadcast(uint256 hash) const; bool rebroadcastTransaction(uint256 hash, CValidationState &state); - // Sigma - SendCoinsReturn prepareSigmaSpendTransaction(WalletModelTransaction &transaction, - std::vector& coins, std::vector& changes, - bool& fChangeAddedToFee, - const CCoinControl *coinControl = NULL); - - // Send coins to a list of recipients - SendCoinsReturn sendSigma(WalletModelTransaction &transaction, - std::vector& coins, std::vector& changes); - - // Mint sigma - void sigmaMint(const CAmount& n, const CCoinControl *coinControl = NULL); - void checkSigmaAmount(bool forced); - - std::vector GetUnsafeCoins(const CCoinControl* coinControl = NULL); - CAmount GetJMintCredit(const CTxOut& txout) const; private: @@ -311,10 +294,6 @@ class WalletModel : public QObject EncryptionStatus cachedEncryptionStatus; int cachedNumBlocks; - // Sigma - bool cachedHavePendingCoin = true; - int lastBlockCheckSigma = 0; - QTimer *pollTimer; int cachedNumISLocks; @@ -354,8 +333,6 @@ class WalletModel : public QObject // Watch-only address added void notifyWatchonlyChanged(bool fHaveWatchonly); - // Update sigma changed - void notifySigmaChanged(const std::vector& spendable, const std::vector& pending); public Q_SLOTS: /* Wallet status might have changed */ void updateStatus(); diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 7d085f9203..eec967c01a 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -21,7 +21,6 @@ #include "platformstyle.h" #include "receivecoinsdialog.h" #include "sendcoinsdialog.h" -#include "sigmadialog.h" #include "signverifymessagedialog.h" #include "tradehistorydialog.h" #include "transactiontablemodel.h" @@ -63,10 +62,8 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): sendElysiumView(0), sendCoinsTabs(0), #endif - sigmaView(0), - blankSigmaView(0), lelantusView(0), - blankLelantusView(0), + // blankLelantusView(0), firoTransactionsView(0), platformStyle(_platformStyle) { @@ -79,7 +76,6 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): createPcodePage = new CreatePcodeDialog(platformStyle); usedSendingAddressesPage = new AddressBookPage(platformStyle, AddressBookPage::ForEditing, AddressBookPage::SendingTab, this); usedReceivingAddressesPage = new AddressBookPage(platformStyle, AddressBookPage::ForEditing, AddressBookPage::ReceivingTab, this); - sigmaPage = new QWidget(this); lelantusPage = new QWidget(this); sendCoinsPage = new QWidget(this); @@ -96,7 +92,6 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): #ifdef ENABLE_ELYSIUM setupToolboxPage(); #endif - setupSigmaPage(); setupLelantusPage(); addWidget(overviewPage); @@ -107,7 +102,6 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): addWidget(receiveCoinsPage); addWidget(createPcodePage); addWidget(sendCoinsPage); - addWidget(sigmaPage); addWidget(lelantusPage); #ifdef ENABLE_ELYSIUM addWidget(toolboxPage); @@ -213,36 +207,19 @@ void WalletView::setupSendCoinPage() sendCoinsPage->setLayout(pageLayout); } -void WalletView::setupSigmaPage() -{ - // Set layout for Sigma page - auto pageLayout = new QVBoxLayout(); - - if (pwalletMain->IsHDSeedAvailable()) { - sigmaView = new SigmaDialog(platformStyle); - connect(sigmaView, &SigmaDialog::message, this, &WalletView::message); - pageLayout->addWidget(sigmaView); - sigmaPage->setLayout(pageLayout); - } else { - blankSigmaView = new BlankSigmaDialog(); - pageLayout->addWidget(blankSigmaView); - sigmaPage->setLayout(pageLayout); - } -} - void WalletView::setupLelantusPage() { auto pageLayout = new QVBoxLayout(); - if (pwalletMain->IsHDSeedAvailable()) { + // if (pwalletMain->IsHDSeedAvailable()) { lelantusView = new LelantusDialog(platformStyle); connect(lelantusView, &LelantusDialog::message, this, &WalletView::message); pageLayout->addWidget(lelantusView); - } else { + // } else { - blankLelantusView = new BlankSigmaDialog(); - pageLayout->addWidget(blankLelantusView); - } + // blankLelantusView = new BlankSigmaDialog(); + // pageLayout->addWidget(blankLelantusView); + // } lelantusPage->setLayout(pageLayout); } @@ -306,7 +283,6 @@ void WalletView::setClientModel(ClientModel *_clientModel) elyAssetsPage->setClientModel(clientModel); #endif if (pwalletMain->IsHDSeedAvailable()) { - sigmaView->setClientModel(clientModel); lelantusView->setClientModel(clientModel); } @@ -333,7 +309,6 @@ void WalletView::setWalletModel(WalletModel *_walletModel) // TODO: fix this //sendCoinsPage->setModel(_walletModel); if (pwalletMain->IsHDSeedAvailable()) { - sigmaView->setWalletModel(_walletModel); lelantusView->setWalletModel(_walletModel); } usedReceivingAddressesPage->setModel(_walletModel->getAddressTableModel()); @@ -482,11 +457,6 @@ void WalletView::gotoCreatePcodePage() setCurrentWidget(createPcodePage); } -void WalletView::gotoSigmaPage() -{ - setCurrentWidget(sigmaPage); -} - void WalletView::gotoLelantusPage() { setCurrentWidget(lelantusPage); diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 90ae160825..f53c4ffb0c 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -13,7 +13,6 @@ #include "automintnotification.h" #include "amount.h" #include "masternodelist.h" -#include "sigmadialog.h" #include "lelantusdialog.h" #ifdef ENABLE_ELYSIUM @@ -85,7 +84,6 @@ class WalletView : public QStackedWidget #ifdef ENABLE_ELYSIUM void setupToolboxPage(); #endif - void setupSigmaPage(); void setupLelantusPage(); private: @@ -112,12 +110,8 @@ class WalletView : public QStackedWidget TradeHistoryDialog *tradeHistoryTab; MetaDExDialog *metaDExTab; MetaDExCancelDialog *cancelTab; - SigmaDialog *sigmaView; - BlankSigmaDialog *blankSigmaView; LelantusDialog *lelantusView; - BlankSigmaDialog *blankLelantusView; QWidget *lelantusPage; - QWidget *sigmaPage; TransactionView *firoTransactionList; QWidget *firoTransactionsView; MasternodeList *masternodeListPage; @@ -153,8 +147,6 @@ public Q_SLOTS: void gotoCreatePcodePage(); /** Switch to send coins page */ void gotoSendCoinsPage(QString addr = ""); - /** Switch to sigma page */ - void gotoSigmaPage(); /** Switch to lelantus page */ void gotoLelantusPage();