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.
501QLabel *l3 = dialog->findChild<QLabel *>("labelCoinControlFee");502QLabel *l4 = dialog->findChild<QLabel *>("labelCoinControlAfterFee");503QLabel *l5 = dialog->findChild<QLabel *>("labelCoinControlBytes");504QLabel *l8 = dialog->findChild<QLabel *>("labelCoinControlChange");506// enable/disable "change"507dialog->findChild<QLabel *>("labelCoinControlChangeText") ->setEnabled(nPayAmount > 0);508dialog->findChild<QLabel *>("labelCoinControlChange") ->setEnabled(nPayAmount > 0);510// stats511l1->setText(QString::number(nQuantity)); // Quantity512l2->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAmount)); // Amount513l3->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nPayFee)); // Fee514l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); // After Fee515l5->setText(((nBytes > 0) ? ASYMP_UTF8 : "") + QString::number(nBytes)); // Bytes516l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); // Change517if (nPayFee > 0)518{519l3->setText(ASYMP_UTF8 + l3->text());520l4->setText(ASYMP_UTF8 + l4->text());521if (nChange > 0 && !CoinControlDialog::fSubtractFeeFromAmount)522l8->setText(ASYMP_UTF8 + l8->text());523}525// how many satoshis the estimated fee can vary per byte we guess wrong526double dFeeVary = (nBytes != 0) ? (double)nPayFee / nBytes : 0;528QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);530l3->setToolTip(toolTip4);531l4->setToolTip(toolTip4);532l8->setToolTip(toolTip4);533dialog->findChild<QLabel *>("labelCoinControlFeeText") ->setToolTip(l3->toolTip());534dialog->findChild<QLabel *>("labelCoinControlAfterFeeText") ->setToolTip(l4->toolTip());535dialog->findChild<QLabel *>("labelCoinControlBytesText") ->setToolTip(l5->toolTip());536dialog->findChild<QLabel *>("labelCoinControlChangeText") ->setToolTip(l8->toolTip());538// Insufficient funds539QLabel *label = dialog->findChild<QLabel *>("labelCoinControlInsuffFunds");540if (label)541label->setVisible(nChange < 0);542}544void CoinControlDialog::changeEvent(QEvent* e)545{546if (e->type() == QEvent::PaletteChange) {547updateView();548}550QDialog::changeEvent(e);551}553void CoinControlDialog::updateView()554{555if (!model || !model->getOptionsModel() || !model->getAddressTableModel())556return;558bool treeMode = ui->radioTreeMode->isChecked();560ui->treeWidget->clear();561ui->treeWidget->setEnabled(false); // performance, otherwise updateLabels would be called for every checked checkbox562ui->treeWidget->setAlternatingRowColors(!treeMode);563QFlags<Qt::ItemFlag> flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;564QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate;566BitcoinUnit nDisplayUnit = model->getOptionsModel()->getDisplayUnit();568for (const auto& coins : model->wallet().listCoins()) {569CCoinControlWidgetItem* itemWalletAddress{nullptr};570QString sWalletAddress = QString::fromStdString(EncodeDestination(coins.first));571QString sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress);572if (sWalletLabel.isEmpty())573sWalletLabel = tr("(no label)");575if (treeMode)576{577// wallet address578itemWalletAddress = new CCoinControlWidgetItem(ui->treeWidget);580itemWalletAddress->setFlags(flgTristate);581itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);583// label584itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel);586// address587itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress);588}590CAmount nSum = 0;591int nChildren = 0;592for (const auto& outpair : coins.second) {593const COutPoint& output = std::get<0>(outpair);594const interfaces::WalletTxOut& out = std::get<1>(outpair);595nSum += out.txout.nValue;596nChildren++;598CCoinControlWidgetItem *itemOutput;599if (treeMode) itemOutput = new CCoinControlWidgetItem(itemWalletAddress);600else itemOutput = new CCoinControlWidgetItem(ui->treeWidget);601itemOutput->setFlags(flgCheckbox);602itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked);604// address605CTxDestination outputAddress;606QString sAddress = "";607if(ExtractDestination(out.txout.scriptPubKey, outputAddress))608{609sAddress = QString::fromStdString(EncodeDestination(outputAddress));611// if listMode or change => show bitcoin address. In tree mode, address is not shown again for direct wallet address outputs612if (!treeMode || (!(sAddress == sWalletAddress)))613itemOutput->setText(COLUMN_ADDRESS, sAddress);614}616// label617if (!(sAddress == sWalletAddress)) // change618{619// tooltip from where the change comes from620itemOutput->setToolTip(COLUMN_LABEL, tr("change from %1 (%2)").arg(sWalletLabel).arg(sWalletAddress));621itemOutput->setText(COLUMN_LABEL, tr("(change)"));622}623else if (!treeMode)624{625QString sLabel = model->getAddressTableModel()->labelForAddress(sAddress);626if (sLabel.isEmpty())627sLabel = tr("(no label)");628itemOutput->setText(COLUMN_LABEL, sLabel);629}631// amount632itemOutput->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, out.txout.nValue));633itemOutput->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)out.txout.nValue)); // padding so that sorting works correctly635// date636itemOutput->setText(COLUMN_DATE, GUIUtil::dateTimeStr(out.time));637itemOutput->setData(COLUMN_DATE, Qt::UserRole, QVariant((qlonglong)out.time));639// confirmations640itemOutput->setText(COLUMN_CONFIRMATIONS, QString::number(out.depth_in_main_chain));641itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant((qlonglong)out.depth_in_main_chain));643// transaction hash644itemOutput->setData(COLUMN_ADDRESS, TxHashRole, QString::fromStdString(output.hash.GetHex()));646// vout index647itemOutput->setData(COLUMN_ADDRESS, VOutRole, output.n);649// disable locked coins650if (model->wallet().isLockedCoin(output))651{652m_coin_control.UnSelect(output); // just to be sure653itemOutput->setDisabled(true);654itemOutput->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed"));655}657// set checkbox658if (m_coin_control.IsSelected(output))659itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked);660}662// amount663if (treeMode)664{665itemWalletAddress->setText(COLUMN_CHECKBOX, "(" + QString::number(nChildren) + ")");666itemWalletAddress->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, nSum));667itemWalletAddress->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)nSum));668}669}671// expand all partially selected672if (treeMode)673{674for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++)675if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) == Qt::PartiallyChecked)676ui->treeWidget->topLevelItem(i)->setExpanded(true);677}679// sort view680sortView(sortColumn, sortOrder);681ui->treeWidget->setEnabled(true);682}
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.