From bacce7ccbaae974da901e4596b682b3d0a985578 Mon Sep 17 00:00:00 2001 From: "levoncrypto1994@gmail.com" Date: Thu, 18 Apr 2024 21:12:48 +0400 Subject: [PATCH 1/7] Add warning messages with sending --- src/qt/forms/sendcoinsentry.ui | 2 +- src/qt/sendcoinsdialog.cpp | 115 +++++++++++---------------------- src/qt/sendcoinsdialog.h | 14 ---- src/qt/sendcoinsentry.cpp | 35 ++++++++-- src/qt/sendcoinsentry.h | 6 +- 5 files changed, 72 insertions(+), 100 deletions(-) diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui index c5098689c4..361f182f0a 100644 --- a/src/qt/forms/sendcoinsentry.ui +++ b/src/qt/forms/sendcoinsentry.ui @@ -162,7 +162,7 @@ - You are using a transparent transaction, please go private. If this is a masternode transaction, you do not have to go private + color: #FFA800; margin-left:-10px; diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 8880bf0af7..f72178bcb9 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -340,15 +340,6 @@ void SendCoinsDialog::on_sendButton_clicked() return; } } else if ((fAnonymousMode == false) && (sparkAddressCount == 0)) { - if (spark::IsSparkAllowed()) { - SendGoPrivateDialog goPrivateDialog; - bool clickedButton = goPrivateDialog.getClickedButton(); - if (!clickedButton) { - setAnonymizeMode(true); - fNewRecipientAllowed = true; - return; - } - } prepareStatus = model->prepareTransaction(currentTransaction, &ctrl); } else { fNewRecipientAllowed = true; @@ -366,6 +357,37 @@ void SendCoinsDialog::on_sendButton_clicked() // Format confirmation message QStringList formatted; + QString warningMessage; + + bool IsExchange = false; + for(int i = 0; i < recipients.size(); ++i){ + std::string address = recipients[i].address.toStdString(); + CBitcoinAddress add(address); + CTxDestination dest = add.Get(); + if (boost::get(&dest)) { + IsExchange = true; + break; + } + } + + if (!fAnonymousMode) { + if (model->validateSparkAddress(recipients[0].address)) { + warningMessage = tr(" You are sending Firo from a transparent address to a Spark address."); + } else if (IsExchange) { + warningMessage = tr(" You are sending Firo into an Exchange Address. Exchange Addresses can only receive funds from a transparent address."); + } else { + warningMessage = tr(" You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead."); + } + } else { + for (auto i = 0; i < recipients.size(); ++i) { + if (model->validateSparkAddress(recipients[i].address)) { + warningMessage = tr(" You are sending Firo from a Spark address to another Spark address. This transaction is fully private."); + break; + } + warningMessage = tr(" You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits."); + } + } + if ((fAnonymousMode == false) && (recipients.size() == sparkAddressCount) && spark::IsSparkAllowed()) { for(int i = 0; i < recipients.size(); i++) { @@ -459,7 +481,9 @@ void SendCoinsDialog::on_sendButton_clicked() formatted.append(recipientElement); } } + QString questionString = tr("Are you sure you want to send?"); + questionString.append(warningMessage); questionString.append("

%1"); double txSize; if ((fAnonymousMode == false) && (recipients.size() == sparkAddressCount) && spark::IsSparkAllowed()) @@ -562,9 +586,9 @@ void SendCoinsDialog::on_sendButton_clicked() void SendCoinsDialog::on_switchFundButton_clicked() { setAnonymizeMode(!fAnonymousMode); - coinControlUpdateLabels(); - + entry->setfAnonymousMode(fAnonymousMode); entry->setWarning(fAnonymousMode); + coinControlUpdateLabels(); } void SendCoinsDialog::clear() @@ -593,7 +617,9 @@ SendCoinsEntry *SendCoinsDialog::addEntry() { entry = new SendCoinsEntry(platformStyle, this); entry->setModel(model); + entry->setfAnonymousMode(fAnonymousMode); entry->setWarning(fAnonymousMode); + ui->entries->addWidget(entry); connect(entry, &SendCoinsEntry::removeEntry, this, &SendCoinsDialog::removeEntry); connect(entry, &SendCoinsEntry::payAmountChanged, this, &SendCoinsDialog::coinControlUpdateLabels); @@ -685,7 +711,6 @@ void SendCoinsDialog::setAddress(const QString &address) { entry = addEntry(); } - entry->setAddress(address); } @@ -1212,69 +1237,3 @@ void SendConfirmationDialog::updateYesButton() yesButton->setText(tr("Yes")); } } - -SendGoPrivateDialog::SendGoPrivateDialog():QMessageBox() -{ - QDialog::setWindowTitle("Make this a private transaction"); - QDialog::setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint); - - QLabel *ic = new QLabel(); - QIcon icon_; - icon_.addFile(QString::fromUtf8(":/icons/ic_info"), QSize(), QIcon::Normal, QIcon::On); - ic->setPixmap(icon_.pixmap(18, 18)); - ic->setFixedWidth(50); - ic->setAlignment(Qt::AlignRight); - ic->setStyleSheet("color:#92400E"); - QLabel *text = new QLabel(); - text->setText(tr("You are using a transparent transaction, please go private. If this is a masternode transaction, you do not have to go private")); - text->setAlignment(Qt::AlignLeft); - text->setWordWrap(true); - text->setStyleSheet("color:#92400E;"); - - 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;"); - QPushButton *goPrivate = new QPushButton(this); - goPrivate->setText("Go Private"); - goPrivate->setStyleSheet("margin-top:30px;margin-bottom:60px;margin-left:20px;margin-right:50px;"); - QHBoxLayout *groupButton = new QHBoxLayout(this); - groupButton->addWidget(ignore); - groupButton->addWidget(goPrivate); - - QHBoxLayout *hlayout = new QHBoxLayout(this); - hlayout->addWidget(ic); - hlayout->addWidget(text); - - QWidget *layout_ = new QWidget(); - layout_->setLayout(hlayout); - layout_->setStyleSheet("background-color:#FEF3C7;"); - - QVBoxLayout *vlayout = new QVBoxLayout(this); - vlayout->addWidget(layout_); - vlayout->addLayout(groupButton); - vlayout->setContentsMargins(0,0,0,0); - QWidget *wbody = new QWidget(); - wbody->setLayout(vlayout); - layout()->addWidget(wbody); - setContentsMargins(0, 0, 0, 0); - setStyleSheet("margin-right:-30px;"); - setStandardButtons(0); - connect(ignore, &QPushButton::clicked, this, &SendGoPrivateDialog::onIgnoreClicked); - connect(goPrivate, &QPushButton::clicked, this, &SendGoPrivateDialog::onGoPrivateClicked); - exec(); -} -void SendGoPrivateDialog::onIgnoreClicked() -{ - setVisible(false); - clickedButton = true; -} -void SendGoPrivateDialog::onGoPrivateClicked() -{ - setVisible(false); - clickedButton = false; -} - -bool SendGoPrivateDialog::getClickedButton() -{ - return clickedButton; -} \ No newline at end of file diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 7656627a55..21dbfa837d 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -127,18 +127,4 @@ private Q_SLOTS: int secDelay; }; -class SendGoPrivateDialog : public QMessageBox -{ - Q_OBJECT -private: - bool clickedButton; -public: - SendGoPrivateDialog(); - bool getClickedButton(); - -private Q_SLOTS: - void onIgnoreClicked(); - void onGoPrivateClicked(); -}; - #endif // BITCOIN_QT_SENDCOINSDIALOG_H diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 49fda59920..cef34a7bdf 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -82,6 +82,7 @@ void SendCoinsEntry::on_addressBookButton_clicked() void SendCoinsEntry::on_payTo_textChanged(const QString &address) { updateLabel(address); + setWarning(fAnonymousMode); } void SendCoinsEntry::setModel(WalletModel *_model) @@ -124,15 +125,34 @@ void SendCoinsEntry::deleteClicked() void SendCoinsEntry::setWarning(bool fAnonymousMode) { - if(fAnonymousMode) { - ui->textWarning->hide(); - ui->iconWarning->hide(); + QString address = ui->payTo->text(); + QString warningText; + + if (address.startsWith("EX")) { + warningText = tr("You are sending Firo to an Exchange Address. Exchange Addresses can only receive funds from a transparent address."); } else { - ui->textWarning->show(); - ui->iconWarning->show(); + if (!fAnonymousMode) { + if (model->validateAddress(address)) { + warningText = tr("You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead."); + } else if (model->validateSparkAddress(address)) { + warningText = tr("You are sending Firo from a transparent address to a Spark address."); + } + } else { + if (model->validateAddress(address)) { + warningText = tr("You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits."); + } else if (model->validateSparkAddress(address)) { + warningText = tr("You are sending Firo from a Spark address to another Spark address. This transaction is fully private."); + } + } } + + const bool hasValidAddress = model->validateAddress(address) || model->validateSparkAddress(address); + ui->textWarning->setText(warningText); + ui->textWarning->setVisible(!warningText.isEmpty() && hasValidAddress); + ui->iconWarning->setVisible(!warningText.isEmpty() && hasValidAddress); } + bool SendCoinsEntry::validate() { if (!model) @@ -230,6 +250,11 @@ bool SendCoinsEntry::isPayToPcode() const return isPcodeEntry; } +void SendCoinsEntry::setfAnonymousMode(bool fAnonymousMode) +{ + this->fAnonymousMode = fAnonymousMode; +} + void SendCoinsEntry::setFocus() { ui->payTo->setFocus(); diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index 2c6bf35242..ed5a0c8b59 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -48,8 +48,9 @@ class SendCoinsEntry : public QStackedWidget QWidget *setupTabChain(QWidget *prev); void setFocus(); - void setWarning(bool fAnonymousMode); - + void setWarning(const bool fAnonymousMode); + void setfAnonymousMode(bool fAnonymousMode); + public Q_SLOTS: void clear(); @@ -71,6 +72,7 @@ private Q_SLOTS: WalletModel *model; const PlatformStyle *platformStyle; bool isPcodeEntry; + bool fAnonymousMode; bool updateLabel(const QString &address); }; From ab96bf1d365372581d79ab1a1abd7edcc36e1f80 Mon Sep 17 00:00:00 2001 From: "levoncrypto1994@gmail.com" Date: Thu, 18 Apr 2024 21:28:13 +0400 Subject: [PATCH 2/7] Add warning messages with sending --- src/qt/sendcoinsentry.cpp | 18 +++++++++++------- src/qt/sendcoinsentry.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index cef34a7bdf..b1cd253df9 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -123,9 +123,17 @@ void SendCoinsEntry::deleteClicked() Q_EMIT removeEntry(this); } -void SendCoinsEntry::setWarning(bool fAnonymousMode) +void SendCoinsEntry::setWarning(bool fAnonymousMode) { + const QString address = ui->payTo->text(); + const QString warningText = generateWarningText(address, fAnonymousMode); + const bool hasValidAddress = model->validateAddress(address) || model->validateSparkAddress(address); + ui->textWarning->setText(warningText); + ui->textWarning->setVisible(!warningText.isEmpty() && hasValidAddress); + ui->iconWarning->setVisible(!warningText.isEmpty() && hasValidAddress); +} + +QString SendCoinsEntry::generateWarningText(const QString& address, const bool fAnonymousMode) { - QString address = ui->payTo->text(); QString warningText; if (address.startsWith("EX")) { @@ -145,11 +153,7 @@ void SendCoinsEntry::setWarning(bool fAnonymousMode) } } } - - const bool hasValidAddress = model->validateAddress(address) || model->validateSparkAddress(address); - ui->textWarning->setText(warningText); - ui->textWarning->setVisible(!warningText.isEmpty() && hasValidAddress); - ui->iconWarning->setVisible(!warningText.isEmpty() && hasValidAddress); + return warningText; } diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index ed5a0c8b59..4bb6e5036b 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -73,7 +73,7 @@ private Q_SLOTS: const PlatformStyle *platformStyle; bool isPcodeEntry; bool fAnonymousMode; - + QString generateWarningText(const QString& address, const bool fAnonymousMode); bool updateLabel(const QString &address); }; From 5a2b7e4d27071f78062475a6c1df6d85a6326fa9 Mon Sep 17 00:00:00 2001 From: "levoncrypto1994@gmail.com" Date: Thu, 18 Apr 2024 21:57:10 +0400 Subject: [PATCH 3/7] Add warning messages with sending (optimize) --- src/qt/sendcoinsdialog.cpp | 28 +++------------------------- src/qt/sendcoinsentry.cpp | 14 +++++++------- src/qt/sendcoinsentry.h | 2 +- 3 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index f72178bcb9..5df00dd43d 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -359,35 +359,13 @@ void SendCoinsDialog::on_sendButton_clicked() QStringList formatted; QString warningMessage; - bool IsExchange = false; - for(int i = 0; i < recipients.size(); ++i){ - std::string address = recipients[i].address.toStdString(); - CBitcoinAddress add(address); - CTxDestination dest = add.Get(); - if (boost::get(&dest)) { - IsExchange = true; + for(int i = 0; i < recipients.size(); ++i) { + warningMessage = entry->generateWarningText(recipients[i].address, fAnonymousMode); + if ((model->validateSparkAddress(recipients[i].address)) || (recipients[i].address.startsWith("EX"))) { break; } } - if (!fAnonymousMode) { - if (model->validateSparkAddress(recipients[0].address)) { - warningMessage = tr(" You are sending Firo from a transparent address to a Spark address."); - } else if (IsExchange) { - warningMessage = tr(" You are sending Firo into an Exchange Address. Exchange Addresses can only receive funds from a transparent address."); - } else { - warningMessage = tr(" You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead."); - } - } else { - for (auto i = 0; i < recipients.size(); ++i) { - if (model->validateSparkAddress(recipients[i].address)) { - warningMessage = tr(" You are sending Firo from a Spark address to another Spark address. This transaction is fully private."); - break; - } - warningMessage = tr(" You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits."); - } - } - if ((fAnonymousMode == false) && (recipients.size() == sparkAddressCount) && spark::IsSparkAllowed()) { for(int i = 0; i < recipients.size(); i++) { diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index b1cd253df9..560ec60f44 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -137,19 +137,19 @@ QString SendCoinsEntry::generateWarningText(const QString& address, const bool f QString warningText; if (address.startsWith("EX")) { - warningText = tr("You are sending Firo to an Exchange Address. Exchange Addresses can only receive funds from a transparent address."); + warningText = tr(" You are sending Firo to an Exchange Address. Exchange Addresses can only receive funds from a transparent address."); } else { if (!fAnonymousMode) { if (model->validateAddress(address)) { - warningText = tr("You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead."); + warningText = tr(" You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead."); } else if (model->validateSparkAddress(address)) { - warningText = tr("You are sending Firo from a transparent address to a Spark address."); + warningText = tr(" You are sending Firo from a transparent address to a Spark address."); } } else { - if (model->validateAddress(address)) { - warningText = tr("You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits."); - } else if (model->validateSparkAddress(address)) { - warningText = tr("You are sending Firo from a Spark address to another Spark address. This transaction is fully private."); + if (model->validateSparkAddress(address)) { + warningText = tr(" You are sending Firo from a Spark address to another Spark address. This transaction is fully private."); + } else if (model->validateAddress(address)) { + warningText = tr(" You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits."); } } } diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index 4bb6e5036b..b24cf93aa3 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -50,6 +50,7 @@ class SendCoinsEntry : public QStackedWidget void setFocus(); void setWarning(const bool fAnonymousMode); void setfAnonymousMode(bool fAnonymousMode); + QString generateWarningText(const QString& address, const bool fAnonymousMode); public Q_SLOTS: void clear(); @@ -73,7 +74,6 @@ private Q_SLOTS: const PlatformStyle *platformStyle; bool isPcodeEntry; bool fAnonymousMode; - QString generateWarningText(const QString& address, const bool fAnonymousMode); bool updateLabel(const QString &address); }; From 466316a8ce35cfee5c40175b56001cf1fd334715 Mon Sep 17 00:00:00 2001 From: "levoncrypto1994@gmail.com" Date: Mon, 29 Apr 2024 22:48:16 +0400 Subject: [PATCH 4/7] QT Tests run --- src/Makefile.am | 4 ++++ src/Makefile.qt.include | 2 +- src/Makefile.qttest.include | 11 +++++++---- src/qt/test/test_main.cpp | 13 +++++++------ src/qt/test/test_sendcoinsentry.cpp | 11 +++++++++++ src/qt/test/test_sendcoinsentry.h | 16 ++++++++++++++++ 6 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 src/qt/test/test_sendcoinsentry.cpp create mode 100644 src/qt/test/test_sendcoinsentry.h diff --git a/src/Makefile.am b/src/Makefile.am index 38b77b65c0..3f43272474 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -923,6 +923,10 @@ if ENABLE_QT include Makefile.qt.include endif +if ENABLE_QT_TESTS +include Makefile.qttest.include +endif + if ENABLE_TESTS include Makefile.test.include else diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index a7dd455242..bbb1b4458a 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -521,7 +521,7 @@ endif qt_firo_qt_LDADD += -ltor qt_firo_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) \ - $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBFIRO_SIGMA) $(LIBLELANTUS) $(LIBSPARK)\ + $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBFIRO_SIGMA) $(LIBLELANTUS) $(LIBSPARK) \ $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BACKTRACE_LIB) $(BOOST_LIBS) $(QT_LIBS) \ $(QT_DBUS_LIBS) $(QR_LIBS) $(BDB_LIBS) $(SSL_LIBS) \ $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) $(LIBBLSSIG_LIBS) $(LIBBLSSIG_DEPENDS) \ diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index 65a4a8951f..6d97a15cec 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -8,7 +8,8 @@ TESTS += qt/test/test_bitcoin-qt TEST_QT_MOC_CPP = \ qt/test/moc_compattests.cpp \ qt/test/moc_rpcnestedtests.cpp \ - qt/test/moc_uritests.cpp + qt/test/moc_uritests.cpp \ + qt/test/moc_test_sendcoinsentry.cpp if ENABLE_WALLET TEST_QT_MOC_CPP += @@ -17,7 +18,8 @@ endif TEST_QT_H = \ qt/test/compattests.h \ qt/test/rpcnestedtests.h \ - qt/test/uritests.h + qt/test/uritests.h \ + qt/test/test_sendcoinsentry.h qt_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ $(QT_INCLUDES) $(QT_TEST_INCLUDES) @@ -27,6 +29,7 @@ qt_test_test_bitcoin_qt_SOURCES = \ qt/test/rpcnestedtests.cpp \ qt/test/test_main.cpp \ qt/test/uritests.cpp \ + qt/test/test_sendcoinsentry.cpp \ $(TEST_QT_H) if ENABLE_WALLET qt_test_test_bitcoin_qt_SOURCES += @@ -43,8 +46,8 @@ qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) \ - $(LIBBITCOIN_UTIL) $(LIBZEROCOIN) $(LIBBITCOIN_CONSENSUS) \ - $(LIBBITCOIN_CRYPTO) $(LIBFIRO_SIGMA) $(LIBLELANTUS) $(LIBUNIVALUE) $(LIBLEVELDB) \ + $(LIBBITCOIN_UTIL) $(LIBZEROCOIN) $(LIBBITCOIN_CONSENSUS) $(LIBBLSSIG_LIBS) $(LIBBLSSIG_DEPENDS) \ + $(LIBBITCOIN_CRYPTO) $(LIBFIRO_SIGMA) $(LIBLELANTUS) $(LIBUNIVALUE) $(LIBSPARK) $(LIBLEVELDB) \ $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \ $(QR_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) \ $(MINIUPNPC_LIBS) $(LIBSECP256K1) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index b8f913d3f5..081471af2a 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -12,11 +12,9 @@ #include "util.h" #include "uritests.h" #include "compattests.h" - +#include "test_sendcoinsentry.h" #include #include -#include - #include #if defined(QT_STATICPLUGIN) && QT_VERSION < 0x050000 @@ -35,7 +33,7 @@ int main(int argc, char *argv[]) ECC_Start(); SetupEnvironment(); SetupNetworking(); - SelectParams(CBaseChainParams::MAIN); + SelectParams(CBaseChainParams::REGTEST); noui_connect(); bool fInvalid = false; @@ -47,10 +45,13 @@ int main(int argc, char *argv[]) SSL_library_init(); - URITests test1; + TestSendCoinsEntry test1; if (QTest::qExec(&test1) != 0) fInvalid = true; - } + + URITests test2; + if (QTest::qExec(&test2) != 0) + fInvalid = true; RPCNestedTests test3; if (QTest::qExec(&test3) != 0) fInvalid = true; diff --git a/src/qt/test/test_sendcoinsentry.cpp b/src/qt/test/test_sendcoinsentry.cpp new file mode 100644 index 0000000000..9cb5d95c2d --- /dev/null +++ b/src/qt/test/test_sendcoinsentry.cpp @@ -0,0 +1,11 @@ +#include "test_sendcoinsentry.h" + +void TestSendCoinsEntry::testGenerateWarningText() +{ + SendCoinsEntry* entry; + QCOMPARE(entry->generateWarningText("EXRSxX8yJHudk4QswGf3N5aPVTUi5Q1ZdX56", false), QObject::tr(" You are sending Firo to an Exchange Address. Exchange Addresses can only receive funds from a transparent address.")); + QCOMPARE(entry->generateWarningText("TLyNUvysvUyt2u6vL74NEkB6ed8LTQd3mz", false), QObject::tr(" You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead.")); + QCOMPARE(entry->generateWarningText("sr1ek2uspg2v4qu0lmccrnj90tfkdpp5zmpykr4ffdprqlf0s4devl8n0674s4d4cthxsa5w9p66s5x0zgw982t80xx9uzmxysxuawmupgfa0xecj9shm6pj7l3rshqxqtg94k88fg5u856r", false), QObject::tr(" You are sending Firo from a transparent address to a Spark address.")); + QCOMPARE(entry->generateWarningText("sr1ek2uspg2v4qu0lmccrnj90tfkdpp5zmpykr4ffdprqlf0s4devl8n0674s4d4cthxsa5w9p66s5x0zgw982t80xx9uzmxysxuawmupgfa0xecj9shm6pj7l3rshqxqtg94k88fg5u856r", true), QObject::tr(" You are sending Firo from a Spark address to another Spark address. This transaction is fully private.")); + QCOMPARE(entry->generateWarningText("TLyNUvysvUyt2u6vL74NEkB6ed8LTQd3mz", true), QObject::tr(" You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits.")); +} diff --git a/src/qt/test/test_sendcoinsentry.h b/src/qt/test/test_sendcoinsentry.h new file mode 100644 index 0000000000..8da54b1f3e --- /dev/null +++ b/src/qt/test/test_sendcoinsentry.h @@ -0,0 +1,16 @@ +#ifndef BITCOIN_QT_TEST_SENDCOINSENTRY_H +#define BITCOIN_QT_TEST_SENDCOINSENTRY_H + +#include +#include +#include "sendcoinsentry.h" + +class TestSendCoinsEntry : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testGenerateWarningText(); +}; + +#endif // BITCOIN_QT_TEST_SENDCOINSENTRY_H \ No newline at end of file From 39d6fbf31afed785d3ac46bfa0b36526cce5c728 Mon Sep 17 00:00:00 2001 From: Narek Geghamyan Date: Tue, 7 May 2024 00:10:41 +0400 Subject: [PATCH 5/7] Linux build fix --- src/Makefile.qttest.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index 6d97a15cec..7d324d4188 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -37,7 +37,7 @@ endif nodist_qt_test_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP) -qt_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER) +qt_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER) -ltor if ENABLE_WALLET qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_WALLET) endif From 4fc081a7958dc8925b7c7faaae9e9f87ebf97ba9 Mon Sep 17 00:00:00 2001 From: levoncrypto Date: Sun, 9 Jun 2024 22:48:34 +0400 Subject: [PATCH 6/7] QT tests and optimization of the warning messages adding function --- src/qt/sendcoinsentry.cpp | 10 +++++----- src/qt/sendcoinsentry.h | 6 +++--- src/qt/test/test_main.cpp | 12 +++++++----- src/qt/test/test_sendcoinsentry.cpp | 11 +++++------ src/qt/test/uritests.cpp | 2 +- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 560ec60f44..8f51b39747 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -11,6 +11,7 @@ #include "optionsmodel.h" #include "platformstyle.h" #include "walletmodel.h" +#include "../wallet/wallet.h" #include #include @@ -140,15 +141,15 @@ QString SendCoinsEntry::generateWarningText(const QString& address, const bool f warningText = tr(" You are sending Firo to an Exchange Address. Exchange Addresses can only receive funds from a transparent address."); } else { if (!fAnonymousMode) { - if (model->validateAddress(address)) { + if (pwalletMain->validateAddress(address.toStdString())) { warningText = tr(" You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead."); - } else if (model->validateSparkAddress(address)) { + } else if (pwalletMain->validateSparkAddress(address.toStdString())) { warningText = tr(" You are sending Firo from a transparent address to a Spark address."); } } else { - if (model->validateSparkAddress(address)) { + if (pwalletMain->validateSparkAddress(address.toStdString())) { warningText = tr(" You are sending Firo from a Spark address to another Spark address. This transaction is fully private."); - } else if (model->validateAddress(address)) { + } else if (pwalletMain->validateAddress(address.toStdString())) { warningText = tr(" You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits."); } } @@ -156,7 +157,6 @@ QString SendCoinsEntry::generateWarningText(const QString& address, const bool f return warningText; } - bool SendCoinsEntry::validate() { if (!model) diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index b24cf93aa3..ee1bc8d3cb 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -48,9 +48,9 @@ class SendCoinsEntry : public QStackedWidget QWidget *setupTabChain(QWidget *prev); void setFocus(); - void setWarning(const bool fAnonymousMode); + void setWarning(bool fAnonymousMode); void setfAnonymousMode(bool fAnonymousMode); - QString generateWarningText(const QString& address, const bool fAnonymousMode); + static QString generateWarningText(const QString& address, const bool fAnonymousMode); public Q_SLOTS: void clear(); @@ -73,7 +73,7 @@ private Q_SLOTS: WalletModel *model; const PlatformStyle *platformStyle; bool isPcodeEntry; - bool fAnonymousMode; + bool fAnonymousMode = false; bool updateLabel(const QString &address); }; diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index 081471af2a..ac8716a22a 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -45,16 +45,18 @@ int main(int argc, char *argv[]) SSL_library_init(); - TestSendCoinsEntry test1; + URITests test1; if (QTest::qExec(&test1) != 0) fInvalid = true; - URITests test2; + TestSendCoinsEntry test2; if (QTest::qExec(&test2) != 0) fInvalid = true; - RPCNestedTests test3; - if (QTest::qExec(&test3) != 0) - fInvalid = true; + + // RPCNestedTests test3; + // if (QTest::qExec(&test3) != 0) + // fInvalid = true; + CompatTests test4; if (QTest::qExec(&test4) != 0) fInvalid = true; diff --git a/src/qt/test/test_sendcoinsentry.cpp b/src/qt/test/test_sendcoinsentry.cpp index 9cb5d95c2d..d79e42174e 100644 --- a/src/qt/test/test_sendcoinsentry.cpp +++ b/src/qt/test/test_sendcoinsentry.cpp @@ -2,10 +2,9 @@ void TestSendCoinsEntry::testGenerateWarningText() { - SendCoinsEntry* entry; - QCOMPARE(entry->generateWarningText("EXRSxX8yJHudk4QswGf3N5aPVTUi5Q1ZdX56", false), QObject::tr(" You are sending Firo to an Exchange Address. Exchange Addresses can only receive funds from a transparent address.")); - QCOMPARE(entry->generateWarningText("TLyNUvysvUyt2u6vL74NEkB6ed8LTQd3mz", false), QObject::tr(" You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead.")); - QCOMPARE(entry->generateWarningText("sr1ek2uspg2v4qu0lmccrnj90tfkdpp5zmpykr4ffdprqlf0s4devl8n0674s4d4cthxsa5w9p66s5x0zgw982t80xx9uzmxysxuawmupgfa0xecj9shm6pj7l3rshqxqtg94k88fg5u856r", false), QObject::tr(" You are sending Firo from a transparent address to a Spark address.")); - QCOMPARE(entry->generateWarningText("sr1ek2uspg2v4qu0lmccrnj90tfkdpp5zmpykr4ffdprqlf0s4devl8n0674s4d4cthxsa5w9p66s5x0zgw982t80xx9uzmxysxuawmupgfa0xecj9shm6pj7l3rshqxqtg94k88fg5u856r", true), QObject::tr(" You are sending Firo from a Spark address to another Spark address. This transaction is fully private.")); - QCOMPARE(entry->generateWarningText("TLyNUvysvUyt2u6vL74NEkB6ed8LTQd3mz", true), QObject::tr(" You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits.")); + QCOMPARE(SendCoinsEntry::generateWarningText("EXRSxX8yJHudk4QswGf3N5aPVTUi5Q1ZdX56", false), QObject::tr(" You are sending Firo to an Exchange Address. Exchange Addresses can only receive funds from a transparent address.")); + QCOMPARE(SendCoinsEntry::generateWarningText("TLyNUvysvUyt2u6vL74NEkB6ed8LTQd3mz", false), QObject::tr(" You are sending Firo from a transparent address to another transparent address. To protect your privacy, we recommend using Spark addresses instead.")); + QCOMPARE(SendCoinsEntry::generateWarningText("sr1ek2uspg2v4qu0lmccrnj90tfkdpp5zmpykr4ffdprqlf0s4devl8n0674s4d4cthxsa5w9p66s5x0zgw982t80xx9uzmxysxuawmupgfa0xecj9shm6pj7l3rshqxqtg94k88fg5u856r", false), QObject::tr(" You are sending Firo from a transparent address to a Spark address.")); + QCOMPARE(SendCoinsEntry::generateWarningText("sr1ek2uspg2v4qu0lmccrnj90tfkdpp5zmpykr4ffdprqlf0s4devl8n0674s4d4cthxsa5w9p66s5x0zgw982t80xx9uzmxysxuawmupgfa0xecj9shm6pj7l3rshqxqtg94k88fg5u856r", true), QObject::tr(" You are sending Firo from a Spark address to another Spark address. This transaction is fully private.")); + QCOMPARE(SendCoinsEntry::generateWarningText("TLyNUvysvUyt2u6vL74NEkB6ed8LTQd3mz", true), QObject::tr(" You are sending Firo from a private Spark pool to a transparent address. Please note that some exchanges do not accept direct Spark deposits.")); } diff --git a/src/qt/test/uritests.cpp b/src/qt/test/uritests.cpp index 518ed28a5b..89bf5c548c 100644 --- a/src/qt/test/uritests.cpp +++ b/src/qt/test/uritests.cpp @@ -51,7 +51,7 @@ void URITests::uriTests() QVERIFY(rv.address == QString("MUVz3KZqgJdC3djwVCLD6ZMpDj5X1FqeKs")); QVERIFY(rv.label == QString()); - QVERIFY(GUIUtil::parseBitcoinURI("firo://MUVz3KZqgJdC3djwVCLD6ZMpDj5X1FqeKs?message=Wikipedia Example Address", &rv)); + QVERIFY(GUIUtil::parseBitcoinURI("firo:MUVz3KZqgJdC3djwVCLD6ZMpDj5X1FqeKs?message=Wikipedia Example Address", &rv)); QVERIFY(rv.address == QString("MUVz3KZqgJdC3djwVCLD6ZMpDj5X1FqeKs")); QVERIFY(rv.label == QString()); From 8dd67ed1ab79ff405221378f876aef96d604e350 Mon Sep 17 00:00:00 2001 From: levonpetrosyan93 Date: Mon, 17 Jun 2024 05:06:07 +0400 Subject: [PATCH 7/7] Linking error fixed --- src/Makefile.qttest.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index 7d324d4188..9ff72747da 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -37,7 +37,7 @@ endif nodist_qt_test_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP) -qt_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER) -ltor +qt_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER) $(TOR_LIBS) if ENABLE_WALLET qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_WALLET) endif @@ -50,9 +50,9 @@ qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_CRYPTO) $(LIBFIRO_SIGMA) $(LIBLELANTUS) $(LIBUNIVALUE) $(LIBSPARK) $(LIBLEVELDB) \ $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \ $(QR_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) \ - $(MINIUPNPC_LIBS) $(LIBSECP256K1) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) + $(MINIUPNPC_LIBS) $(LIBSECP256K1) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(BACKTRACE_LIB) -qt_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +qt_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(LDFLAGS_WRAP_EXCEPTIONS) qt_test_test_bitcoin_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) CLEAN_BITCOIN_QT_TEST = $(TEST_QT_MOC_CPP) qt/test/*.gcda qt/test/*.gcno