Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2011-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <qt/transactionfilterproxy.h>7#include <qt/transactiontablemodel.h>8#include <qt/transactionrecord.h>10#include <algorithm>11#include <cstdlib>12#include <optional>14TransactionFilterProxy::TransactionFilterProxy(QObject* parent)15: QSortFilterProxyModel(parent)16{17}19bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const20{21QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);23int status = index.data(TransactionTableModel::StatusRole).toInt();24if (!showInactive && status == TransactionStatus::Conflicted)25return false;27int type = index.data(TransactionTableModel::TypeRole).toInt();28if (!(TYPE(type) & typeFilter))29return false;31QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();32if (dateFrom && datetime < *dateFrom) return false;33if (dateTo && datetime > *dateTo) return false;35QString address = index.data(TransactionTableModel::AddressRole).toString();36QString label = index.data(TransactionTableModel::LabelRole).toString();37QString txid = index.data(TransactionTableModel::TxHashRole).toString();38if (!address.contains(m_search_string, Qt::CaseInsensitive) &&39! label.contains(m_search_string, Qt::CaseInsensitive) &&40! txid.contains(m_search_string, Qt::CaseInsensitive)) {41return false;42}44qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());45if (amount < minAmount)46return false;48return true;49}51void TransactionFilterProxy::setDateRange(const std::optional<QDateTime>& from, const std::optional<QDateTime>& to)52{53#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)54beginFilterChange();55#endif57dateFrom = from;58dateTo = to;60#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)61endFilterChange(QSortFilterProxyModel::Direction::Rows);62#else63invalidateFilter();64#endif65}67void TransactionFilterProxy::setSearchString(const QString &search_string)68{69if (m_search_string == search_string) return;71#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)72beginFilterChange();73#endif75m_search_string = search_string;77#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)78endFilterChange(QSortFilterProxyModel::Direction::Rows);79#else80invalidateFilter();81#endif82}84void TransactionFilterProxy::setTypeFilter(quint32 modes)85{86#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)87beginFilterChange();88#endif90this->typeFilter = modes;92#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)93endFilterChange(QSortFilterProxyModel::Direction::Rows);94#else95invalidateFilter();96#endif97}99void TransactionFilterProxy::setMinAmount(const CAmount& minimum)100{101#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)102beginFilterChange();103#endif105this->minAmount = minimum;107#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)108endFilterChange(QSortFilterProxyModel::Direction::Rows);109#else110invalidateFilter();111#endif112}114void TransactionFilterProxy::setShowInactive(bool _showInactive)115{116#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)117beginFilterChange();118#endif120this->showInactive = _showInactive;122#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)123endFilterChange(QSortFilterProxyModel::Direction::Rows);124#else125invalidateFilter();126#endif127}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.