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.
751fFeeMinimized = fMinimize;752}754void SendCoinsDialog::on_buttonChooseFee_clicked()755{756minimizeFeeSection(false);757}759void SendCoinsDialog::on_buttonMinimizeFee_clicked()760{761updateFeeMinimizedLabel();762minimizeFeeSection(true);763}765void SendCoinsDialog::useAvailableBalance(SendCoinsEntry* entry)766{767// Same behavior as send: if we have selected coins, only obtain their available balance.768// Copy to avoid modifying the member's data.769CCoinControl coin_control = *m_coin_control;770coin_control.m_allow_other_inputs = !coin_control.HasSelected();772// Calculate available amount to send.773CAmount amount = model->getAvailableBalance(&coin_control);774for (int i = 0; i < ui->entries->count(); ++i) {775SendCoinsEntry* e = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());776if (e && !e->isHidden() && e != entry) {777amount -= e->getValue().amount;778}779}781if (amount > 0) {782entry->checkSubtractFeeFromAmount();783entry->setAmount(amount);784} else {785entry->setAmount(0);786}787}789void SendCoinsDialog::updateFeeSectionControls()790{791ui->confTargetSelector ->setEnabled(ui->radioSmartFee->isChecked());792ui->labelSmartFee ->setEnabled(ui->radioSmartFee->isChecked());793ui->labelSmartFee2 ->setEnabled(ui->radioSmartFee->isChecked());794ui->labelSmartFee3 ->setEnabled(ui->radioSmartFee->isChecked());795ui->labelFeeEstimation ->setEnabled(ui->radioSmartFee->isChecked());796ui->labelCustomFeeWarning ->setEnabled(ui->radioCustomFee->isChecked());797ui->labelCustomPerKilobyte ->setEnabled(ui->radioCustomFee->isChecked());798ui->customFee ->setEnabled(ui->radioCustomFee->isChecked());799}801void SendCoinsDialog::updateFeeMinimizedLabel()802{803if(!model || !model->getOptionsModel())804return;806if (ui->radioSmartFee->isChecked())807ui->labelFeeMinimized->setText(ui->labelSmartFee->text());808else {809ui->labelFeeMinimized->setText(tr("%1/kvB").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), ui->customFee->value())));810}811}813void SendCoinsDialog::updateCoinControlState()814{815if (ui->radioCustomFee->isChecked()) {816m_coin_control->m_feerate = CFeeRate(ui->customFee->value());817} else {818m_coin_control->m_feerate.reset();819}820// Avoid using global defaults when sending money from the GUI821// Either custom fee will be used or if not selected, the confirmation target from dropdown box822m_coin_control->m_confirm_target = getConfTargetForIndex(ui->confTargetSelector->currentIndex());823}825void SendCoinsDialog::updateNumberOfBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state) {826// During shutdown, clientModel will be nullptr. Attempting to update views at this point may cause a crash827// due to accessing backend models that might no longer exist.828if (!clientModel) return;829// Process event830if (sync_state == SynchronizationState::POST_INIT) {831updateSmartFeeLabel();832}833}835void SendCoinsDialog::updateSmartFeeLabel()836{837if(!model || !model->getOptionsModel())838return;839updateCoinControlState();840m_coin_control->m_feerate.reset(); // Explicitly use only fee estimation rate for smart fee labels841std::optional<int> returned_target;842FeeReason reason;843CFeeRate feeRate = CFeeRate(model->wallet().getMinimumFee(1000, *m_coin_control, &returned_target, &reason));845ui->labelSmartFee->setText(tr("%1/kvB").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK())));847if (reason == FeeReason::FALLBACK) {848ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)849ui->labelFeeEstimation->setText("");850ui->fallbackFeeWarningLabel->setVisible(true);851int lightness = ui->fallbackFeeWarningLabel->palette().color(QPalette::WindowText).lightness();852QColor warning_colour(255 - (lightness / 5), 176 - (lightness / 3), 48 - (lightness / 14));853ui->fallbackFeeWarningLabel->setStyleSheet("QLabel { color: " + warning_colour.name() + "; }");854ui->fallbackFeeWarningLabel->setIndent(GUIUtil::TextWidth(QFontMetrics(ui->fallbackFeeWarningLabel->font()), "x"));855}856else857{858ui->labelSmartFee2->hide();859ui->labelFeeEstimation->setText("");860if (returned_target) {861ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", *returned_target));862}863ui->fallbackFeeWarningLabel->setVisible(false);864}866updateFeeMinimizedLabel();867}869// Coin Control: copy label "Quantity" to clipboard870void SendCoinsDialog::coinControlClipboardQuantity()871{872GUIUtil::setClipboard(ui->labelCoinControlQuantity->text());873}875// Coin Control: copy label "Amount" to clipboard876void SendCoinsDialog::coinControlClipboardAmount()877{878GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));879}881// Coin Control: copy label "Fee" to clipboard882void SendCoinsDialog::coinControlClipboardFee()883{884GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")).replace(ASYMP_UTF8, ""));885}887// Coin Control: copy label "After fee" to clipboard888void SendCoinsDialog::coinControlClipboardAfterFee()889{890GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")).replace(ASYMP_UTF8, ""));891}893// Coin Control: copy label "Bytes" to clipboard894void SendCoinsDialog::coinControlClipboardBytes()895{896GUIUtil::setClipboard(ui->labelCoinControlBytes->text().replace(ASYMP_UTF8, ""));897}899// Coin Control: copy label "Change" to clipboard900void SendCoinsDialog::coinControlClipboardChange()901{902GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")).replace(ASYMP_UTF8, ""));903}905// Coin Control: settings menu - coin control enabled/disabled by user906void SendCoinsDialog::coinControlFeatureChanged(bool checked)907{908ui->frameCoinControl->setVisible(checked);910if (!checked && model) { // coin control features disabled911m_coin_control = std::make_unique<CCoinControl>();912}914coinControlUpdateLabels();915}917// Coin Control: button inputs -> show actual coin control dialog918void SendCoinsDialog::coinControlButtonClicked()919{920auto dlg = new CoinControlDialog(*m_coin_control, model, platformStyle);921connect(dlg, &QDialog::finished, this, &SendCoinsDialog::coinControlUpdateLabels);922GUIUtil::ShowModalDialogAsynchronously(dlg);923}925// Coin Control: checkbox custom change address926#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))927void SendCoinsDialog::coinControlChangeChecked(Qt::CheckState state)928#else929void SendCoinsDialog::coinControlChangeChecked(int state)930#endif931{932if (state == Qt::Unchecked)933{934m_coin_control->destChange = CNoDestination();935ui->labelCoinControlChangeLabel->clear();936}937else938// use this to re-validate an already entered address939coinControlChangeEdited(ui->lineEditCoinControlChange->text());941ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));942}944// Coin Control: custom change address changed945void SendCoinsDialog::coinControlChangeEdited(const QString& text)946{947if (model && model->getAddressTableModel())948{949// Default to no change address until verified950m_coin_control->destChange = CNoDestination();951ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");953const CTxDestination dest = DecodeDestination(text.toStdString());955if (text.isEmpty()) // Nothing entered956{957ui->labelCoinControlChangeLabel->setText("");958}959else if (!IsValidDestination(dest)) // Invalid address960{961ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Bitcoin address"));962}963else // Valid address964{965if (!model->wallet().isSpendable(dest)) {966ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));968// confirmation dialog969QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm custom change address"), tr("The address you selected for change is not part of this wallet. Any or all funds in your wallet may be sent to this address. Are you sure?"),970QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);972if(btnRetVal == QMessageBox::Yes)973m_coin_control->destChange = dest;974else975{976ui->lineEditCoinControlChange->setText("");977ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");978ui->labelCoinControlChangeLabel->setText("");979}980}981else // Known change address982{983ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");985// Query label986QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);987if (!associatedLabel.isEmpty())988ui->labelCoinControlChangeLabel->setText(associatedLabel);989else990ui->labelCoinControlChangeLabel->setText(tr("(no label)"));992m_coin_control->destChange = dest;993}994}995}996}998// Coin Control: update labels999void SendCoinsDialog::coinControlUpdateLabels()1000{
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.