diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 7ba41d25e6..bd08df359d 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -31,19 +31,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode, tab(_tab) { ui->setupUi(this); - - if (tab == SendingTab) { - ui->addressType->addItem(tr("Spark"), Spark); - ui->addressType->addItem(tr("Transparent"), Transparent); - ui->addressType->addItem(tr("RAP"), RAP); - } else if(tab == ReceivingTab && !isReused) { - ui->addressType->addItem(tr("Spark"), Spark); - ui->addressType->addItem(tr("Transparent"), Transparent); - } else { - ui->addressType->addItem(tr(""), Transparent); - ui->addressType->addItem(tr("Transparent"), Transparent); - ui->addressType->hide(); - } + this->isReused = isReused; if (!platformStyle->getImagesOnButtons()) { ui->newAddress->setIcon(QIcon()); @@ -127,6 +115,23 @@ void AddressBookPage::setModel(AddressTableModel *_model) this->model = _model; if(!_model) return; + bool spark = this->model->IsSparkAllowed(); + + if (tab == SendingTab) { + if (spark) { + ui->addressType->addItem(tr("Spark"), Spark); + } + ui->addressType->addItem(tr("Transparent"), Transparent); + } else if(tab == ReceivingTab && !this->isReused) { + if (spark) { + ui->addressType->addItem(tr("Spark"), Spark); + } + ui->addressType->addItem(tr("Transparent"), Transparent); + } else { + ui->addressType->addItem(tr(""), Transparent); + ui->addressType->addItem(tr("Transparent"), Transparent); + ui->addressType->hide(); + } proxyModel = new QSortFilterProxyModel(this); fproxyModel = new AddressBookFilterProxy(this); @@ -174,6 +179,23 @@ void AddressBookPage::setModel(AddressTableModel *_model) connect(ui->addressType, qOverload(&QComboBox::activated), this, &AddressBookPage::chooseAddressType); } +void AddressBookPage::updateSpark() { + ui->addressType->clear(); + if (tab == SendingTab) { + ui->addressType->addItem(tr("Spark"), Spark); + ui->addressType->addItem(tr("Transparent"), Transparent); + } else if(tab == ReceivingTab && !this->isReused) { + ui->addressType->addItem(tr("Spark"), Spark); + ui->addressType->addItem(tr("Transparent"), Transparent); + } else { + ui->addressType->addItem(tr(""), Transparent); + ui->addressType->addItem(tr("Transparent"), Transparent); + ui->addressType->hide(); + } + + chooseAddressType(0); +} + void AddressBookPage::on_copyAddress_clicked() { GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address); @@ -191,9 +213,7 @@ void AddressBookPage::onEditAction() EditAddressDialog::Mode mode; AddressTableModel * pmodel; pmodel = model; - if (ui->addressType->currentText() == AddressTableModel::RAP) { - mode = EditAddressDialog::EditPcode; - } else if (ui->addressType->currentText() == AddressTableModel::Transparent) { + if (ui->addressType->currentText() == AddressTableModel::Transparent) { mode = tab == SendingTab ? EditAddressDialog::EditSendingAddress : EditAddressDialog::EditReceivingAddress; } else { mode = tab == SendingTab ? EditAddressDialog::EditSparkSendingAddress : EditAddressDialog::EditSparkReceivingAddress; @@ -224,8 +244,6 @@ void AddressBookPage::on_newAddress_clicked() pmodel = model; if (ui->addressType->currentText() == AddressTableModel::Spark) { mode = tab == SendingTab ? EditAddressDialog::NewSparkSendingAddress : EditAddressDialog::NewSparkReceivingAddress; - } else if (ui->addressType->currentText() == AddressTableModel::RAP) { - mode = EditAddressDialog::NewPcode; } else { mode = tab == SendingTab ? EditAddressDialog::NewSendingAddress : EditAddressDialog::NewReceivingAddress; } @@ -333,10 +351,6 @@ void AddressBookPage::on_exportButton_clicked() writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole); writer.addColumn("Transparent Address", AddressTableModel::Address, Qt::EditRole); writer.addColumn("Address Type", AddressTableModel::AddressType, Qt::EditRole); - } else if (ui->addressType->currentText() == AddressTableModel::RAP) { - writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole); - writer.addColumn("PaymentCode", AddressTableModel::Address, Qt::EditRole); - writer.addColumn("Address Type", AddressTableModel::AddressType, Qt::EditRole); } else { writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole); writer.addColumn("Spark Address", AddressTableModel::Address, Qt::EditRole); @@ -356,8 +370,6 @@ void AddressBookPage::contextualMenu(const QPoint &point) if (ui->addressType->currentText() == "Spark") { copyAddressAction->setText(tr("&Copy Spark Address")); - } else if (ui->addressType->currentText() == "RAP") { - copyAddressAction->setText(tr("&Copy RAP address")); } else { copyAddressAction->setText(tr("&Copy Transparent Address")); } @@ -397,14 +409,12 @@ bool AddressBookFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & QModelIndex index = sourceModel()->index(sourceRow, 2, sourceParent); bool res0 = sourceModel()->data(index).toString().contains("spark"); bool res1 = sourceModel()->data(index).toString().contains("transparent"); - bool res2 = sourceModel()->data(index).toString().contains("RAP"); if(res0 && typeFilter == 0) return true; if(res1 && typeFilter == 1) return true; - if(res2 && typeFilter == 2) - return true; + return false; } diff --git a/src/qt/addressbookpage.h b/src/qt/addressbookpage.h index e89d1402f8..7ddbb65b5e 100644 --- a/src/qt/addressbookpage.h +++ b/src/qt/addressbookpage.h @@ -45,8 +45,7 @@ class AddressBookPage : public QDialog enum AddressTypeEnum { Spark, - Transparent, - RAP + Transparent }; explicit AddressBookPage(const PlatformStyle *platformStyle, Mode mode, Tabs tab, QWidget *parent, bool isReused = true); @@ -55,6 +54,8 @@ class AddressBookPage : public QDialog void setModel(AddressTableModel *model); const QString &getReturnValue() const { return returnValue; } + void updateSpark(); + public Q_SLOTS: void done(int retval); @@ -70,6 +71,7 @@ public Q_SLOTS: QAction *copyAddressAction; QAction *deleteAction; // to be able to explicitly disable it QString newAddressToSelect; + bool isReused; private Q_SLOTS: /** Delete currently selected address entry */ diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index 0352d19f03..16359b21a4 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -684,6 +684,11 @@ PcodeAddressTableModel * AddressTableModel::getPcodeAddressTableModel() return walletModel->getPcodeAddressTableModel(); } +bool AddressTableModel::IsSparkAllowed(){ + return spark::IsSparkAllowed(); +} + + // RAP pcodes static void NotifyPcodeLabeled(PcodeAddressTableModel *walletmodel, std::string pcode, std::string label, bool removed) diff --git a/src/qt/addresstablemodel.h b/src/qt/addresstablemodel.h index 3ff1cfa630..2fa4e51537 100644 --- a/src/qt/addresstablemodel.h +++ b/src/qt/addresstablemodel.h @@ -88,6 +88,8 @@ class AddressTableModel : public QAbstractTableModel EditStatus getEditStatus() const { return editStatus; } PcodeAddressTableModel * getPcodeAddressTableModel(); + + bool IsSparkAllowed(); protected: WalletModel *walletModel; CWallet *wallet; diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 733c2eeaa0..7e3279ee4e 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -398,7 +398,7 @@ void BitcoinApplication::unlockWallet_(void * wallet) { CWallet * wallet_ = reinterpret_cast(wallet); - QString info = tr("You need to unlock to allow spark wallet be created."); + QString info = tr("You need to unlock to allow Spark wallet be created."); walletModel = new WalletModel(platformStyle, wallet_, optionsModel); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index bbffd0a4c2..fe27475ed2 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1517,6 +1517,9 @@ void BitcoinGUI::checkLelantusVisibility(int numBlocks) } lelantusAction->setVisible(allowLelantusPage); } + + if (numBlocks == ::Params().GetConsensus().nSparkStartBlock) + walletFrame->updateAddressbook(); } void BitcoinGUI::toggleNetworkActive() diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 46b1f33f62..a7affffa67 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -173,16 +173,6 @@ - - - - Whether to show RAP addresses or not. - - - Display RAP addresses - - - diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index e0307a5395..6b94d1cc7a 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -185,7 +185,6 @@ void OptionsDialog::setMapper() mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange); mapper->addMapping(ui->reindexLelantus, OptionsModel::ReindexLelantus); mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures); - mapper->addMapping(ui->enableRapAddresses, OptionsModel::enableRapAddresses); /* Lelantus */ mapper->addMapping(ui->autoAnonymize, OptionsModel::AutoAnonymize); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 047a4bfa12..98b5955051 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -81,10 +81,6 @@ void OptionsModel::Init(bool resetSettings) settings.setValue("fCoinControlFeatures", false); fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool(); - if (!settings.contains("fenableRapAddresses")) - settings.setValue("fenableRapAddresses", false); - fenableRapAddresses = settings.value("fenableRapAddresses", false).toBool(); - if (!settings.contains("fAutoAnonymize")) settings.setValue("fAutoAnonymize", false); fAutoAnonymize = settings.value("fAutoAnonymize", false).toBool(); @@ -281,8 +277,6 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return settings.value("language"); case CoinControlFeatures: return fCoinControlFeatures; - case enableRapAddresses: - return fenableRapAddresses; case AutoAnonymize: return fAutoAnonymize; case LelantusPage: @@ -430,11 +424,6 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in settings.setValue("fCoinControlFeatures", fCoinControlFeatures); Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures); break; - case enableRapAddresses: - fenableRapAddresses = value.toBool(); - settings.setValue("fenableRapAddresses", fenableRapAddresses); - Q_EMIT enableRapAddressesChanged(fenableRapAddresses); - break; case AutoAnonymize: fAutoAnonymize = value.toBool(); settings.setValue("fAutoAnonymize", fAutoAnonymize); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 6b7d5de4c3..26a4c9612e 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -425,10 +425,10 @@ MigrateLelantusToSparkDialog::MigrateLelantusToSparkDialog(WalletModel *_model): QPushButton *ignore = new QPushButton(this); ignore->setText("Ignore"); - ignore->setStyleSheet("color:#9b1c2e;background-color:none;margin-top:30px;margin-bottom:60px;margin-left:50px;margin-right:20px;border:1px solid #9b1c2e;"); + ignore->setStyleSheet("margin-top:30px;margin-bottom:60px;margin-left:20px;margin-right:50px;"); QPushButton *migrate = new QPushButton(this); migrate->setText("Migrate"); - migrate->setStyleSheet("margin-top:30px;margin-bottom:60px;margin-left:20px;margin-right:50px;"); + migrate->setStyleSheet("color:#9b1c2e;background-color:none;margin-top:30px;margin-bottom:60px;margin-left:50px;margin-right:20px;border:1px solid #9b1c2e;"); QHBoxLayout *groupButton = new QHBoxLayout(this); groupButton->addWidget(ignore); groupButton->addWidget(migrate); @@ -462,13 +462,13 @@ MigrateLelantusToSparkDialog::MigrateLelantusToSparkDialog(WalletModel *_model): void MigrateLelantusToSparkDialog::onIgnoreClicked() { setVisible(false); - clickedButton = false; + clickedButton = true; } void MigrateLelantusToSparkDialog::onMigrateClicked() { setVisible(false); - clickedButton = true; + clickedButton = false; model->migrateLelantusToSpark(); } diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 3f514961f7..10e1e91db9 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -323,7 +323,7 @@ void SendCoinsDialog::on_sendButton_clicked() if (model->getLelantusModel()->getPrivateBalance().first > 0 && spark::IsSparkAllowed() && chainActive.Height() < ::Params().GetConsensus().nLelantusGracefulPeriod) { MigrateLelantusToSparkDialog migrateLelantusToSpark(model); bool clickedButton = migrateLelantusToSpark.getClickedButton(); - if(clickedButton) { + if(!clickedButton) { fNewRecipientAllowed = true; return; } @@ -343,7 +343,7 @@ void SendCoinsDialog::on_sendButton_clicked() if (spark::IsSparkAllowed()) { SendGoPrivateDialog goPrivateDialog; bool clickedButton = goPrivateDialog.getClickedButton(); - if (clickedButton) { + if (!clickedButton) { setAnonymizeMode(true); fNewRecipientAllowed = true; return; diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index c6609b3e12..3ede407713 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -259,3 +259,10 @@ void WalletFrame::outOfSyncWarningClicked() { Q_EMIT requestedSyncWarningInfo(); } + +void WalletFrame::updateAddressbook() { + WalletView *walletView = currentWalletView(); + + if (walletView) + walletView->updateAddressbook(); +} diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index 5840572d79..10a547f8e5 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -110,6 +110,8 @@ public Q_SLOTS: void usedReceivingAddresses(); /** Pass on signal over requested out-of-sync-warning information */ void outOfSyncWarningClicked(); + + void updateAddressbook(); }; #endif // BITCOIN_QT_WALLETFRAME_H diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 5b0c2a034d..f9c2625fc0 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -596,6 +596,12 @@ void WalletView::usedSendingAddresses() usedSendingAddressesPage->activateWindow(); } +void WalletView::updateAddressbook() +{ + usedReceivingAddressesPage->updateSpark(); + usedSendingAddressesPage->updateSpark(); +} + void WalletView::usedReceivingAddresses() { if(!walletModel) diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 692bcade37..1b8e2517e5 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -172,6 +172,9 @@ public Q_SLOTS: /** Show used sending addresses */ void usedSendingAddresses(); + + void updateAddressbook(); + /** Show used receiving addresses */ void usedReceivingAddresses();