diff --git a/doc/release-notes-6337.md b/doc/release-notes-6337.md new file mode 100644 index 0000000000..e10943ee2a --- /dev/null +++ b/doc/release-notes-6337.md @@ -0,0 +1,5 @@ +GUI changes +----------- + +A new option has been added in to the "Main" tab in "Options" that allow +users to enable RPC server functionality. diff --git a/share/qt/Info.plist.in b/share/qt/Info.plist.in index fbdfbd983d..2ea3204cd2 100644 --- a/share/qt/Info.plist.in +++ b/share/qt/Info.plist.in @@ -16,6 +16,11 @@ CFBundlePackageType APPL + CFBundleSupportedPlatforms + + MacOSX + + CFBundleShortVersionString @CLIENT_VERSION_MAJOR@.@CLIENT_VERSION_MINOR@.@CLIENT_VERSION_BUILD@ diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 1e29750bdd..d550e13136 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -582,7 +582,7 @@ int GuiMain(int argc, char* argv[]) return EXIT_FAILURE; } #ifdef ENABLE_WALLET - // Parse URIs on command line -- this can affect Params() + // Parse URIs on command line PaymentServer::ipcParseCommandLine(argc, argv); #endif diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 98ba9297da..9cdd8851dc 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -112,14 +112,15 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle, { /** Create wallet frame*/ walletFrame = new WalletFrame(this); - connect(walletFrame, &WalletFrame::message, [this](const QString& title, const QString& message, unsigned int style) { - this->message(title, message, style); - }); connect(walletFrame, &WalletFrame::createWalletButtonClicked, [this] { auto activity = new CreateWalletActivity(getWalletController(), this); connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater); activity->create(); }); + connect(walletFrame, &WalletFrame::message, [this](const QString& title, const QString& message, unsigned int style) { + this->message(title, message, style); + }); + connect(walletFrame, &WalletFrame::currentWalletSet, [this] { updateWalletStatus(); }); } else #endif // ENABLE_WALLET { @@ -819,8 +820,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections); connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive); - modalOverlay->setKnownBestHeight(tip_info->header_height, QDateTime::fromTime_t(tip_info->header_time)); - setNumBlocks(tip_info->block_height, QDateTime::fromTime_t(tip_info->block_time), QString::fromStdString(tip_info->block_hash.ToString()), tip_info->verification_progress, false, SynchronizationState::INIT_DOWNLOAD); + modalOverlay->setKnownBestHeight(tip_info->header_height, QDateTime::fromSecsSinceEpoch(tip_info->header_time)); + setNumBlocks(tip_info->block_height, QDateTime::fromSecsSinceEpoch(tip_info->block_time), QString::fromStdString(tip_info->block_hash.ToString()), tip_info->verification_progress, false, SynchronizationState::INIT_DOWNLOAD); connect(_clientModel, &ClientModel::numBlocksChanged, this, &BitcoinGUI::setNumBlocks); connect(_clientModel, &ClientModel::additionalDataSyncProgressChanged, this, &BitcoinGUI::setAdditionalDataSyncProgress); @@ -932,7 +933,6 @@ void BitcoinGUI::addWallet(WalletModel* walletModel) }); connect(wallet_view, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus); connect(wallet_view, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction); - connect(wallet_view, &WalletView::hdEnabledStatusChanged, this, &BitcoinGUI::updateWalletStatus); connect(this, &BitcoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy); wallet_view->setPrivacy(isPrivacyModeActivated()); const QString display_name = walletModel->getDisplayName(); @@ -1281,7 +1281,7 @@ void BitcoinGUI::updateNetworkState() } if (fNetworkBecameActive || fNetworkBecameInactive) { - setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false, SynchronizationState::INIT_DOWNLOAD); + setNumBlocks(m_node.getNumBlocks(), QDateTime::fromSecsSinceEpoch(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false, SynchronizationState::INIT_DOWNLOAD); } nCountPrev = count; @@ -1545,7 +1545,7 @@ void BitcoinGUI::setAdditionalDataSyncProgress(double nSyncProgress) // If masternodeSync->Reset() has been called make sure status bar shows the correct information. if (nSyncProgress == -1) { - setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false, SynchronizationState::INIT_DOWNLOAD); + setNumBlocks(m_node.getNumBlocks(), QDateTime::fromSecsSinceEpoch(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false, SynchronizationState::INIT_DOWNLOAD); if (clientModel->getNumConnections()) { labelBlocksIcon->show(); startSpinner(); @@ -1679,7 +1679,9 @@ void BitcoinGUI::changeEvent(QEvent *e) if (e->type() == QEvent::StyleChange) { updateNetworkState(); #ifdef ENABLE_WALLET - updateWalletStatus(); + if (walletFrame) { + updateWalletStatus(); + } #endif if (m_node.masternodeSync().isSynced()) { labelBlocksIcon->setPixmap(GUIUtil::getIcon("synced", GUIUtil::ThemedColor::GREEN).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); @@ -1911,9 +1913,8 @@ void BitcoinGUI::setEncryptionStatus(int status) void BitcoinGUI::updateWalletStatus() { - if (!walletFrame) { - return; - } + assert(walletFrame); + WalletView * const walletView = walletFrame->currentWalletView(); if (!walletView) { return; diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index ea1df1ac6b..d604e3ac79 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -251,7 +251,7 @@ bool ClientModel::isReleaseVersion() const QString ClientModel::formatClientStartupTime() const { - return QDateTime::fromTime_t(GetStartupTime()).toString(); + return QDateTime::fromSecsSinceEpoch(GetStartupTime()).toString(); } QString ClientModel::dataDir() const @@ -329,7 +329,7 @@ static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_ bool invoked = QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection, Q_ARG(int, tip.block_height), - Q_ARG(QDateTime, QDateTime::fromTime_t(tip.block_time)), + Q_ARG(QDateTime, QDateTime::fromSecsSinceEpoch(tip.block_time)), Q_ARG(QString, QString::fromStdString(tip.block_hash.ToString())), Q_ARG(double, verificationProgress), Q_ARG(bool, fHeader), diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 7ac2e5de6c..ba685d77f8 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -1587,10 +1587,10 @@ - Whether we relay addresses to this peer. + Whether we relay addresses to this peer. - Address Relay + Address Relay @@ -1613,10 +1613,10 @@ - Total number of addresses processed, excluding those dropped due to rate-limiting. + The total number of addresses received from this peer that were processed (excludes addresses that were dropped due to rate-limiting). - Addresses Processed + Addresses Processed @@ -1639,10 +1639,10 @@ - Total number of addresses dropped due to rate-limiting. + The total number of addresses received from this peer that were dropped (not processed) due to rate-limiting. - Addresses Rate-Limited + Addresses Rate-Limited diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 300e2520e9..6773f6a2ca 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -291,13 +291,23 @@ 40 - 20 + 40 + + + + This allows you or a third party tool to communicate with the node through command-line and JSON-RPC commands. + + + Enable R&PC server + + + diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 40f74f73e7..84afe40bba 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -263,7 +263,7 @@ QString dateTimeStr(const QDateTime &date) QString dateTimeStr(qint64 nTime) { - return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); + return dateTimeStr(QDateTime::fromSecsSinceEpoch((qint32)nTime)); } QFont fixedPitchFont(bool use_embedded_font) diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp index c84607c033..a90535acbc 100644 --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -293,7 +293,7 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable ui->freeSpace->setText(""); } else { m_bytes_available = bytesAvailable; - if (ui->prune->isEnabled()) { + if (ui->prune->isEnabled() && !(gArgs.IsArgSet("-prune") && gArgs.GetArg("-prune", 0) == 0)) { ui->prune->setChecked(m_bytes_available < (m_blockchain_size_gb + m_chain_state_size_gb + 10) * GB_BYTES); } UpdateFreeSpaceLabel(); diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 5337fb163c..08da36cff8 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -267,6 +267,7 @@ void OptionsDialog::setModel(OptionsModel *_model) connect(ui->spendZeroConfChange, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning); /* Network */ connect(ui->allowIncoming, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning); + connect(ui->enableServer, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning); connect(ui->connectSocks, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning); connect(ui->connectSocksTor, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning); /* Display */ @@ -344,6 +345,7 @@ void OptionsDialog::setMapper() mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); mapper->addMapping(ui->mapPortNatpmp, OptionsModel::MapPortNatpmp); mapper->addMapping(ui->allowIncoming, OptionsModel::Listen); + mapper->addMapping(ui->enableServer, OptionsModel::Server); mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse); mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index fcf84bf5ec..7a58dbb400 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -280,6 +280,13 @@ void OptionsModel::Init(bool resetSettings) gArgs.SoftSetBoolArg("-listenonion", false); } + if (!settings.contains("server")) { + settings.setValue("server", false); + } + if (!gArgs.SoftSetBoolArg("-server", settings.value("server").toBool())) { + addOverriddenOption("-server"); + } + if (!settings.contains("fUseProxy")) settings.setValue("fUseProxy", false); if (!settings.contains("addrProxy")) @@ -536,6 +543,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return settings.value("nThreadsScriptVerif"); case Listen: return settings.value("fListen"); + case Server: + return settings.value("server"); default: return QVariant(); } @@ -806,6 +815,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in setRestartRequired(true); } break; + case Server: + if (settings.value("server") != value) { + settings.setValue("server", value); + setRestartRequired(true); + } + break; default: break; } diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 4ce93d406f..9fb8e4b7b9 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -86,6 +86,7 @@ public: CoinJoinDenomsHardCap,// int CoinJoinMultiSession, // bool Listen, // bool + Server, // bool OptionIDRowCount, }; diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index de76e1625b..72553e81bb 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -79,32 +79,11 @@ void PaymentServer::ipcParseCommandLine(int argc, char* argv[]) for (int i = 1; i < argc; i++) { QString arg(argv[i]); - if (arg.startsWith("-")) - continue; + if (arg.startsWith("-")) continue; - // If the dash: URI contains a payment request, we are not able to detect the - // network as that would require fetching and parsing the payment request. - // That means clicking such an URI which contains a testnet payment request - // will start a mainnet instance and throw a "wrong network" error. if (arg.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // dash: URI { - if (savedPaymentRequests.contains(arg)) continue; savedPaymentRequests.insert(arg); - - SendCoinsRecipient r; - if (GUIUtil::parseBitcoinURI(arg, &r) && !r.address.isEmpty()) - { - auto tempChainParams = CreateChainParams(gArgs, CBaseChainParams::MAIN); - - if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) { - SelectParams(CBaseChainParams::MAIN); - } else { - tempChainParams = CreateChainParams(gArgs, CBaseChainParams::TESTNET); - if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) { - SelectParams(CBaseChainParams::TESTNET); - } - } - } } } } diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index ed43c513d4..c1086cae65 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -74,8 +74,13 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const case Age: return GUIUtil::FormatPeerAge(rec->nodeStats.m_connected); case Address: - // prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection - return QString::fromStdString((rec->nodeStats.fInbound ? "↓ " : "↑ ") + rec->nodeStats.m_addr_name); + return QString::fromStdString(rec->nodeStats.m_addr_name); + case Direction: + return QString(rec->nodeStats.fInbound ? + //: An Inbound Connection from a Peer. + tr("Inbound") : + //: An Outbound Connection to a Peer. + tr("Outbound")); case ConnectionType: return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false); case Network: @@ -97,6 +102,7 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const return QVariant(Qt::AlignRight | Qt::AlignVCenter); case Address: return {}; + case Direction: case ConnectionType: case Network: return QVariant(Qt::AlignCenter); diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h index 03fc2b45da..84ecebc219 100644 --- a/src/qt/peertablemodel.h +++ b/src/qt/peertablemodel.h @@ -49,6 +49,7 @@ public: NetNodeId = 0, Age, Address, + Direction, ConnectionType, Network, Ping, @@ -88,6 +89,9 @@ private: /*: Title of Peers Table column which contains the IP/Onion/I2P address of the connected peer. */ tr("Address"), + /*: Title of Peers Table column which indicates the direction + the peer connection was initiated from. */ + tr("Direction"), /*: Title of Peers Table column which describes the type of peer connection. The "type" describes why the connection exists. */ tr("Type"), diff --git a/src/qt/peertablesortproxy.cpp b/src/qt/peertablesortproxy.cpp index 6d716366fa..9b280f7dea 100644 --- a/src/qt/peertablesortproxy.cpp +++ b/src/qt/peertablesortproxy.cpp @@ -28,6 +28,8 @@ bool PeerTableSortProxy::lessThan(const QModelIndex& left_index, const QModelInd return left_stats.m_connected > right_stats.m_connected; case PeerTableModel::Address: return left_stats.m_addr_name.compare(right_stats.m_addr_name) < 0; + case PeerTableModel::Direction: + return left_stats.fInbound > right_stats.fInbound; // default sort Inbound, then Outbound case PeerTableModel::ConnectionType: return left_stats.m_conn_type < right_stats.m_conn_type; case PeerTableModel::Network: diff --git a/src/qt/recentrequeststablemodel.cpp b/src/qt/recentrequeststablemodel.cpp index c28fef6490..9474b6d397 100644 --- a/src/qt/recentrequeststablemodel.cpp +++ b/src/qt/recentrequeststablemodel.cpp @@ -234,7 +234,7 @@ bool RecentRequestEntryLessThan::operator()(const RecentRequestEntry& left, cons switch(column) { case RecentRequestsTableModel::Date: - return pLeft->date.toTime_t() < pRight->date.toTime_t(); + return pLeft->date.toSecsSinceEpoch() < pRight->date.toSecsSinceEpoch(); case RecentRequestsTableModel::Label: return pLeft->recipient.label < pRight->recipient.label; case RecentRequestsTableModel::Message: diff --git a/src/qt/recentrequeststablemodel.h b/src/qt/recentrequeststablemodel.h index ee2cd405cb..0b323482e9 100644 --- a/src/qt/recentrequeststablemodel.h +++ b/src/qt/recentrequeststablemodel.h @@ -7,6 +7,8 @@ #include +#include + #include #include #include @@ -26,9 +28,9 @@ public: SERIALIZE_METHODS(RecentRequestEntry, obj) { unsigned int date_timet; - SER_WRITE(obj, date_timet = obj.date.toTime_t()); + SER_WRITE(obj, date_timet = obj.date.toSecsSinceEpoch()); READWRITE(obj.nVersion, obj.id, date_timet, obj.recipient); - SER_READ(obj, obj.date = QDateTime::fromTime_t(date_timet)); + SER_READ(obj, obj.date = QDateTime::fromSecsSinceEpoch(date_timet)); } }; diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 5c623b6ac6..a69aee8909 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -697,7 +697,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_ setNumConnections(model->getNumConnections()); connect(model, &ClientModel::numConnectionsChanged, this, &RPCConsole::setNumConnections); - setNumBlocks(bestblock_height, QDateTime::fromTime_t(bestblock_date), QString::fromStdString(bestblock_hash.ToString()), verification_progress, false); + setNumBlocks(bestblock_height, QDateTime::fromSecsSinceEpoch(bestblock_date), QString::fromStdString(bestblock_hash.ToString()), verification_progress, false); connect(model, &ClientModel::numBlocksChanged, this, &RPCConsole::setNumBlocks); connect(model, &ClientModel::chainLockChanged, this, &RPCConsole::setChainLock); @@ -963,7 +963,11 @@ void RPCConsole::clear(bool keep_prompt) ui->lineEdit->setFocus(); // Set default style sheet +#ifdef Q_OS_MAC + ui->messagesWidget->setFont(GUIUtil::fixedPitchFont(/*use_embedded_font=*/true)); +#else ui->messagesWidget->setFont(GUIUtil::fixedPitchFont()); +#endif ui->messagesWidget->document()->setDefaultStyleSheet( QString( "table { }" diff --git a/src/qt/test/apptests.cpp b/src/qt/test/apptests.cpp index 872099a1bd..2793d55db1 100644 --- a/src/qt/test/apptests.cpp +++ b/src/qt/test/apptests.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #if defined(HAVE_CONFIG_H) @@ -21,9 +20,11 @@ #include #include +#include #include #include #include +#include #include #include #include @@ -31,6 +32,13 @@ #include namespace { +//! Regex find a string group inside of the console output +QString FindInConsole(const QString& output, const QString& pattern) +{ + const QRegularExpression re(pattern); + return re.match(output).captured(1); +} + //! Call getblockchaininfo RPC and check first field of JSON output. void TestRpcCommand(RPCConsole* console) { @@ -42,10 +50,9 @@ void TestRpcCommand(RPCConsole* console) QTest::keyClick(lineEdit, Qt::Key_Return); QVERIFY(mw_spy.wait(1000)); QCOMPARE(mw_spy.count(), 4); - QString output = messagesWidget->toPlainText(); - UniValue value; - value.read(output.right(output.size() - output.indexOf("{")).toStdString()); - QCOMPARE(value["chain"].get_str(), std::string("regtest")); + const QString output = messagesWidget->toPlainText(); + const QString pattern = QStringLiteral("\"chain\": \"(\\w+)\""); + QCOMPARE(FindInConsole(output, pattern), QString("regtest")); } } // namespace diff --git a/src/qt/transactionfilterproxy.cpp b/src/qt/transactionfilterproxy.cpp index 58fbfbdfec..1e515c22fc 100644 --- a/src/qt/transactionfilterproxy.cpp +++ b/src/qt/transactionfilterproxy.cpp @@ -7,17 +7,12 @@ #include #include +#include #include - -// Earliest date that can be represented (far in the past) -const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0); -// Last date that can be represented (far in the future) -const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF); +#include TransactionFilterProxy::TransactionFilterProxy(QObject *parent) : QSortFilterProxyModel(parent), - dateFrom(MIN_DATE.toTime_t()), - dateTo(MAX_DATE.toTime_t()), m_search_string(), typeFilter(COMMON_TYPES), watchOnlyFilter(WatchOnlyFilter_All), @@ -44,9 +39,10 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & return false; if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes) return false; - qint64 datetime = index.data(TransactionTableModel::DateRoleInt).toLongLong(); - if (datetime < dateFrom || datetime > dateTo) - return false; + + QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime(); + if (dateFrom && datetime < *dateFrom) return false; + if (dateTo && datetime > *dateTo) return false; QString address = index.data(TransactionTableModel::AddressRole).toString(); QString label = index.data(TransactionTableModel::LabelRole).toString(); @@ -64,10 +60,10 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & return true; } -void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to) +void TransactionFilterProxy::setDateRange(const std::optional& from, const std::optional& to) { - this->dateFrom = from.toTime_t(); - this->dateTo = to.toTime_t(); + dateFrom = from; + dateTo = to; invalidateFilter(); } diff --git a/src/qt/transactionfilterproxy.h b/src/qt/transactionfilterproxy.h index 0996289928..38695e21b0 100644 --- a/src/qt/transactionfilterproxy.h +++ b/src/qt/transactionfilterproxy.h @@ -10,6 +10,8 @@ #include #include +#include + /** Filter the transaction list according to pre-specified rules. */ class TransactionFilterProxy : public QSortFilterProxyModel { @@ -18,10 +20,6 @@ class TransactionFilterProxy : public QSortFilterProxyModel public: explicit TransactionFilterProxy(QObject *parent = nullptr); - /** Earliest date that can be represented (far in the past) */ - static const QDateTime MIN_DATE; - /** Last date that can be represented (far in the future) */ - static const QDateTime MAX_DATE; /** Type filter bit field (all types) */ static const quint32 ALL_TYPES = 0xFFFFFFFF; /** Type filter bit field (all types but Darksend-SPAM) */ @@ -36,7 +34,8 @@ public: WatchOnlyFilter_No }; - void setDateRange(const QDateTime &from, const QDateTime &to); + /** Filter transactions between date range. Use std::nullopt for open range. */ + void setDateRange(const std::optional& from, const std::optional& to); void setSearchString(const QString &); /** @note Type filter takes a bit field created with TYPE() or ALL_TYPES @@ -57,8 +56,8 @@ protected: bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override; private: - qint64 dateFrom; - qint64 dateTo; + std::optional dateFrom; + std::optional dateTo; QString m_search_string; quint32 typeFilter; WatchOnlyFilter watchOnlyFilter; diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index ed5aa41aeb..01de92c61d 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -694,7 +694,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const case TypeRole: return rec->type; case DateRole: - return QDateTime::fromTime_t(static_cast(rec->time)); + return QDateTime::fromSecsSinceEpoch(rec->time); case DateRoleInt: return qint64(rec->time); case WatchonlyRole: diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 80e030c24f..55760147c5 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include #include #include @@ -265,26 +267,26 @@ void TransactionView::chooseDate(int idx) { case All: transactionProxyModel->setDateRange( - TransactionFilterProxy::MIN_DATE, - TransactionFilterProxy::MAX_DATE); + std::nullopt, + std::nullopt); break; case Today: transactionProxyModel->setDateRange( GUIUtil::StartOfDay(current), - TransactionFilterProxy::MAX_DATE); + std::nullopt); break; case ThisWeek: { // Find last Monday QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1)); transactionProxyModel->setDateRange( GUIUtil::StartOfDay(startOfWeek), - TransactionFilterProxy::MAX_DATE); + std::nullopt); } break; case ThisMonth: transactionProxyModel->setDateRange( GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1)), - TransactionFilterProxy::MAX_DATE); + std::nullopt); break; case LastMonth: transactionProxyModel->setDateRange( @@ -294,7 +296,7 @@ void TransactionView::chooseDate(int idx) case ThisYear: transactionProxyModel->setDateRange( GUIUtil::StartOfDay(QDate(current.year(), 1, 1)), - TransactionFilterProxy::MAX_DATE); + std::nullopt); break; case Range: dateRangeWidget->setVisible(true); diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index 0148003e20..d97b1d7553 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -123,7 +123,8 @@ void WalletFrame::setCurrentWallet(WalletModel* wallet_model) walletView->updateGeometry(); walletStack->setCurrentWidget(walletView); - walletView->updateEncryptionStatus(); + + Q_EMIT currentWalletSet(); } void WalletFrame::removeWallet(WalletModel* wallet_model) diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index 4b76dc40ec..948af49ad6 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -50,6 +50,7 @@ public: Q_SIGNALS: void message(const QString& title, const QString& message, unsigned int style); + void currentWalletSet(); void createWalletButtonClicked(); diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 6869854ced..1a99436660 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -177,10 +177,6 @@ void WalletView::setWalletModel(WalletModel *_walletModel) // Handle changes in encryption status connect(_walletModel, &WalletModel::encryptionStatusChanged, this, &WalletView::encryptionStatusChanged); - updateEncryptionStatus(); - - // update HD status - Q_EMIT hdEnabledStatusChanged(); // Balloon pop-up for new transaction connect(_walletModel->getTransactionTableModel(), &TransactionTableModel::rowsInserted, this, &WalletView::processNewTransaction); @@ -304,11 +300,6 @@ void WalletView::showOutOfSyncWarning(bool fShow) overviewPage->showOutOfSyncWarning(fShow); } -void WalletView::updateEncryptionStatus() -{ - Q_EMIT encryptionStatusChanged(); -} - void WalletView::encryptWallet() { if(!walletModel) @@ -317,7 +308,7 @@ void WalletView::encryptWallet() dlg.setModel(walletModel); dlg.exec(); - updateEncryptionStatus(); + Q_EMIT encryptionStatusChanged(); } void WalletView::backupWallet() diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 05f0aaad1e..fa281690a7 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -116,9 +116,6 @@ public Q_SLOTS: /** Show used receiving addresses */ void usedReceivingAddresses(); - /** Re-emit encryption status signal */ - void updateEncryptionStatus(); - /** Show progress dialog e.g. for rescan */ void showProgress(const QString &title, int nProgress); @@ -132,8 +129,6 @@ Q_SIGNALS: void message(const QString &title, const QString &message, unsigned int style); /** Encryption status of wallet changed */ void encryptionStatusChanged(); - /** HD-Enabled status of wallet changed (only possible during startup) */ - void hdEnabledStatusChanged(); /** Notify that a new transaction appeared */ void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName); /** Notify that the out of sync warning icon has been pressed */