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.
251transactionProxyModel->setDateRange(252std::nullopt,253std::nullopt);254break;255case Today:256transactionProxyModel->setDateRange(257GUIUtil::StartOfDay(current),258std::nullopt);259break;260case ThisWeek: {261// Find last Monday262QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));263transactionProxyModel->setDateRange(264GUIUtil::StartOfDay(startOfWeek),265std::nullopt);267} break;268case ThisMonth:269transactionProxyModel->setDateRange(270GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1)),271std::nullopt);272break;273case LastMonth:274transactionProxyModel->setDateRange(275GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1).addMonths(-1)),276GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1)));277break;278case ThisYear:279transactionProxyModel->setDateRange(280GUIUtil::StartOfDay(QDate(current.year(), 1, 1)),281std::nullopt);282break;283case Range:284dateRangeWidget->setVisible(true);285dateRangeChanged();286break;287}288}290void TransactionView::chooseType(int idx)291{292if(!transactionProxyModel)293return;294transactionProxyModel->setTypeFilter(295typeWidget->itemData(idx).toInt());296}298void TransactionView::changedSearch()299{300if(!transactionProxyModel)301return;302transactionProxyModel->setSearchString(search_widget->text());303}305void TransactionView::changedAmount()306{307if(!transactionProxyModel)308return;309CAmount amount_parsed = 0;310if (BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amountWidget->text(), &amount_parsed)) {311transactionProxyModel->setMinAmount(amount_parsed);312}313else314{315transactionProxyModel->setMinAmount(0);316}317}319void TransactionView::exportClicked()320{321if (!model || !model->getOptionsModel()) {322return;323}325// CSV is currently the only supported format326QString filename = GUIUtil::getSaveFileName(this,327tr("Export Transaction History"), QString(),328/*: Expanded name of the CSV file format.329See: https://en.wikipedia.org/wiki/Comma-separated_values. */330tr("Comma separated file") + QLatin1String(" (*.csv)"), nullptr);332if (filename.isNull())333return;335CSVModelWriter writer(filename);337// name, column, role338writer.setModel(transactionProxyModel);339writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole);340writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole);341writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole);342writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole);343writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole);344writer.addColumn(BitcoinUnits::getAmountColumnTitle(model->getOptionsModel()->getDisplayUnit()), 0, TransactionTableModel::FormattedAmountRole);345writer.addColumn(tr("ID"), 0, TransactionTableModel::TxHashRole);347if(!writer.write()) {348Q_EMIT message(tr("Exporting Failed"), tr("There was an error trying to save the transaction history to %1.").arg(filename),349CClientUIInterface::MSG_ERROR);350}351else {352Q_EMIT message(tr("Exporting Successful"), tr("The transaction history was successfully saved to %1.").arg(filename),353CClientUIInterface::MSG_INFORMATION);354}355}357void TransactionView::contextualMenu(const QPoint &point)358{359QModelIndex index = transactionView->indexAt(point);360QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);361if (selection.empty())362return;364// If the hash from the TxHashRole (QVariant / QString) is invalid, exit365QString hashQStr = selection.at(0).data(TransactionTableModel::TxHashRole).toString();366std::optional<Txid> maybeHash = Txid::FromHex(hashQStr.toStdString());367if (!maybeHash)368return;370Txid hash = *maybeHash;371abandonAction->setEnabled(model->wallet().transactionCanBeAbandoned(hash));372bumpFeeAction->setEnabled(model->wallet().transactionCanBeBumped(hash));373copyAddressAction->setEnabled(GUIUtil::hasEntryData(transactionView, 0, TransactionTableModel::AddressRole));374copyLabelAction->setEnabled(GUIUtil::hasEntryData(transactionView, 0, TransactionTableModel::LabelRole));376if (index.isValid()) {377GUIUtil::PopupMenu(contextMenu, transactionView->viewport()->mapToGlobal(point));378}379}381void TransactionView::abandonTx()382{383if(!transactionView || !transactionView->selectionModel())384return;385QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);387// get the hash from the TxHashRole (QVariant / QString)388QString hashQStr = selection.at(0).data(TransactionTableModel::TxHashRole).toString();389Txid hash = Txid::FromHex(hashQStr.toStdString()).value();391// Abandon the wallet transaction over the walletModel392model->wallet().abandonTransaction(hash);393}395void TransactionView::bumpFee([[maybe_unused]] bool checked)396{397if(!transactionView || !transactionView->selectionModel())398return;399QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);401// get the hash from the TxHashRole (QVariant / QString)402QString hashQStr = selection.at(0).data(TransactionTableModel::TxHashRole).toString();403Txid hash = Txid::FromHex(hashQStr.toStdString()).value();405// Bump tx fee over the walletModel406Txid newHash;407if (model->bumpFee(hash, newHash)) {408// Update the table409transactionView->selectionModel()->clearSelection();410model->getTransactionTableModel()->updateTransaction(hashQStr, CT_UPDATED, true);412qApp->processEvents();413Q_EMIT bumpedFee(newHash);414}415}417void TransactionView::copyAddress()418{419GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::AddressRole);420}422void TransactionView::copyLabel()423{424GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::LabelRole);425}427void TransactionView::copyAmount()428{429GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::FormattedAmountRole);430}432void TransactionView::copyTxID()433{434GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxHashRole);435}437void TransactionView::copyTxHex()438{439GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxHexRole);440}442void TransactionView::copyTxPlainText()443{444GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxPlainTextRole);445}447void TransactionView::editLabel()448{449if(!transactionView->selectionModel() ||!model)450return;451QModelIndexList selection = transactionView->selectionModel()->selectedRows();452if(!selection.isEmpty())453{454AddressTableModel *addressBook = model->getAddressTableModel();455if(!addressBook)456return;457QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString();458if(address.isEmpty())459{460// If this transaction has no associated address, exit461return;462}463// Is address in address book? Address book can miss address when a transaction is464// sent from outside the UI.465int idx = addressBook->lookupAddress(address);466if(idx != -1)467{468// Edit sending / receiving address469QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex());470// Determine type of address, launch appropriate editor dialog type471QString type = modelIdx.data(AddressTableModel::TypeRole).toString();473auto dlg = new EditAddressDialog(474type == AddressTableModel::Receive475? EditAddressDialog::EditReceivingAddress476: EditAddressDialog::EditSendingAddress, this);477dlg->setModel(addressBook);478dlg->loadRow(idx);479GUIUtil::ShowModalDialogAsynchronously(dlg);480}481else482{483// Add sending address484auto dlg = new EditAddressDialog(EditAddressDialog::NewSendingAddress,485this);486dlg->setModel(addressBook);487dlg->setAddress(address);488GUIUtil::ShowModalDialogAsynchronously(dlg);489}490}491}493void TransactionView::showDetails()494{495if(!transactionView->selectionModel())496return;497QModelIndexList selection = transactionView->selectionModel()->selectedRows();498if(!selection.isEmpty())499{500TransactionDescDialog *dlg = new TransactionDescDialog(selection.at(0));
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.