5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
10#include <qt/forms/ui_coincontroldialog.h>
27#include <QApplication>
30#include <QDialogButtonBox>
44 return data(column, Qt::UserRole).toLongLong() <
45 other.data(column, Qt::UserRole).toLongLong();
47 return QTreeWidgetItem::operator<(other);
81 connect(
ui->treeWidget, &QWidget::customContextMenuRequested,
this,
83 connect(copyAddressAction, &QAction::triggered,
this,
85 connect(copyLabelAction, &QAction::triggered,
this,
129 connect(
ui->radioTreeMode, &QRadioButton::toggled,
this,
131 connect(
ui->radioListMode, &QRadioButton::toggled,
this,
135 connect(
ui->treeWidget, &QTreeWidget::itemChanged,
this,
139 ui->treeWidget->header()->setSectionsClickable(
true);
140 connect(
ui->treeWidget->header(), &QHeaderView::sectionClicked,
this,
144 connect(
ui->buttonBox, &QDialogButtonBox::clicked,
this,
148 connect(
ui->pushButtonSelectAll, &QPushButton::clicked,
this,
163 if (
settings.contains(
"nCoinControlMode") &&
164 !
settings.value(
"nCoinControlMode").toBool()) {
165 ui->radioTreeMode->click();
167 if (
settings.contains(
"nCoinControlSortColumn") &&
168 settings.contains(
"nCoinControlSortOrder")) {
170 (
static_cast<Qt::SortOrder
>(
171 settings.value(
"nCoinControlSortOrder").toInt())));
176 if (
_model->getOptionsModel() &&
_model->getAddressTableModel()) {
185 settings.setValue(
"nCoinControlMode",
ui->radioListMode->isChecked());
194 if (
ui->buttonBox->buttonRole(
button) == QDialogButtonBox::AcceptRole) {
196 done(QDialog::Accepted);
202 Qt::CheckState state = Qt::Checked;
203 for (
int i = 0; i <
ui->treeWidget->topLevelItemCount(); i++) {
206 state = Qt::Unchecked;
210 ui->treeWidget->setEnabled(
false);
211 for (
int i = 0; i <
ui->treeWidget->topLevelItemCount(); i++) {
218 ui->treeWidget->setEnabled(
true);
219 if (state == Qt::Unchecked) {
228 QTreeWidgetItem *item =
ui->treeWidget->itemAt(point);
267 if (
ui->radioTreeMode->isChecked() &&
278 if (
ui->radioTreeMode->isChecked() &&
324 ui->labelCoinControlAmount->text().indexOf(
" ")));
330 ui->labelCoinControlFee->text()
331 .left(
ui->labelCoinControlFee->text().indexOf(
" "))
338 ui->labelCoinControlAfterFee->text()
339 .left(
ui->labelCoinControlAfterFee->text().indexOf(
" "))
346 ui->labelCoinControlBytes->text().replace(
ASYMP_UTF8,
""));
357 ui->labelCoinControlChange->text()
358 .left(
ui->labelCoinControlChange->text().indexOf(
" "))
366 ui->treeWidget->sortItems(column, order);
378 ((
sortOrder == Qt::AscendingOrder) ? Qt::DescendingOrder
379 : Qt::AscendingOrder);
386 : Qt::DescendingOrder);
417 }
else if (item->isDisabled()) {
425 if (
ui->treeWidget->isEnabled()) {
434 std::vector<COutPoint>
vOutpts;
438 ui->labelLocked->setVisible(
true);
440 ui->labelLocked->setVisible(
false);
458 CTxOut txout(amount, CScript() << std::vector<uint8_t>(24, 0));
476 if (out.depth_in_main_chain < 0) {
492 nAmount += out.txout.nValue;
544 CTxOut txout(
nChange, CScript() << std::vector<uint8_t>(24, 0));
571 QLabel *
l1 =
dialog->findChild<QLabel *>(
"labelCoinControlQuantity");
572 QLabel *
l2 =
dialog->findChild<QLabel *>(
"labelCoinControlAmount");
573 QLabel *
l3 =
dialog->findChild<QLabel *>(
"labelCoinControlFee");
574 QLabel *
l4 =
dialog->findChild<QLabel *>(
"labelCoinControlAfterFee");
575 QLabel *
l5 =
dialog->findChild<QLabel *>(
"labelCoinControlBytes");
576 QLabel *
l7 =
dialog->findChild<QLabel *>(
"labelCoinControlLowOutput");
577 QLabel *
l8 =
dialog->findChild<QLabel *>(
"labelCoinControlChange");
580 dialog->findChild<QLabel *>(
"labelCoinControlLowOutputText")
582 dialog->findChild<QLabel *>(
"labelCoinControlLowOutput")
584 dialog->findChild<QLabel *>(
"labelCoinControlChangeText")
586 dialog->findChild<QLabel *>(
"labelCoinControlChange")
614 l7->setStyleSheet((
fDust) ?
"color:red;" :
"");
618 tr(
"This label turns red if any recipient receives an amount smaller "
619 "than the current dust threshold.");
625 tr(
"Can vary +/- %1 satoshi(s) per input.").arg(
dFeeVary);
631 dialog->findChild<QLabel *>(
"labelCoinControlFeeText")
633 dialog->findChild<QLabel *>(
"labelCoinControlAfterFeeText")
635 dialog->findChild<QLabel *>(
"labelCoinControlBytesText")
637 dialog->findChild<QLabel *>(
"labelCoinControlLowOutputText")
639 dialog->findChild<QLabel *>(
"labelCoinControlChangeText")
643 QLabel *label =
dialog->findChild<QLabel *>(
"labelCoinControlInsuffFunds");
660 bool treeMode =
ui->radioTreeMode->isChecked();
662 ui->treeWidget->clear();
665 ui->treeWidget->setEnabled(
false);
666 ui->treeWidget->setAlternatingRowColors(!
treeMode);
668 Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
670 Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable |
701 for (
const auto &
outpair : coins.second) {
702 const COutPoint &output = std::get<0>(
outpair);
769 QString::fromStdString(output.GetTxId().GetHex()));
803 for (
int i = 0; i <
ui->treeWidget->topLevelItemCount(); i++) {
805 Qt::PartiallyChecked) {
806 ui->treeWidget->topLevelItem(i)->setExpanded(
true);
813 ui->treeWidget->setEnabled(
true);
static constexpr Amount SATOSHI
std::string EncodeCashAddr(const CTxDestination &dst, const CChainParams ¶ms)
QString labelForAddress(const QString &address) const
Look up label for address in address book, if not found return empty string.
static QString formatWithUnit(int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
static QString removeSpaces(QString text)
static QString format(int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
Format as string.
bool IsSelected(const COutPoint &output) const
void Select(const COutPoint &output)
void UnSelect(const COutPoint &output)
void ListSelected(std::vector< COutPoint > &vOutpoints) const
An encapsulated public key.
bool IsCompressed() const
Check whether this is a compressed public key.
An output of a transaction.
void headerSectionClicked(int)
static COutPoint buildOutPoint(const QTreeWidgetItem *item)
QTreeWidgetItem * contextMenuItem
static QList< Amount > payAmounts
friend class CCoinControlWidgetItem
static void updateLabels(CCoinControl &m_coin_control, WalletModel *, QDialog *)
const PlatformStyle * platformStyle
CCoinControl & m_coin_control
QAction * copyTransactionHashAction
Ui::CoinControlDialog * ui
void sortView(int, Qt::SortOrder)
CoinControlDialog(CCoinControl &coin_control, WalletModel *model, const PlatformStyle *platformStyle, QWidget *parent=nullptr)
void showMenu(const QPoint &)
void copyTransactionHash()
void viewItemChanged(QTreeWidgetItem *, int)
void clipboardLowOutput()
void buttonSelectAllClicked()
static bool fSubtractFeeFromAmount
void buttonBoxClicked(QAbstractButton *)
int getDisplayUnit() const
Interface to Bitcoin wallet from Qt view code.
interfaces::Node & node() const
const CChainParams & getChainParams() const
AddressTableModel * getAddressTableModel()
OptionsModel * getOptionsModel()
interfaces::Wallet & wallet() const
void SetHex(const char *psz)
const uint8_t * data() const
virtual CFeeRate getDustRelayFee()=0
Get dust relay fee.
virtual CoinsList listCoins()=0
virtual bool getPubKey(const CScript &script, const CKeyID &address, CPubKey &pub_key)=0
Get public key.
virtual std::vector< WalletTxOut > getCoins(const std::vector< COutPoint > &outputs)=0
Return wallet transaction output information.
virtual void unlockCoin(const COutPoint &output)=0
Unlock coin.
virtual bool isLockedCoin(const COutPoint &output)=0
Return whether coin is locked.
virtual void listLockedCoins(std::vector< COutPoint > &outputs)=0
List locked coins.
virtual void lockCoin(const COutPoint &output)=0
Lock coin.
virtual Amount getMinimumFee(unsigned int tx_bytes, const CCoinControl &coin_control)=0
Get minimum fee.
static constexpr Amount MIN_CHANGE
target minimum change amount
void handleCloseWindowShortcut(QWidget *w)
QString dateTimeStr(const QDateTime &date)
void setClipboard(const QString &str)
bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFeeIn)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
CKeyID ToKeyID(const PKHash &key_hash)
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
static constexpr Amount zero() noexcept
A TxId is the identifier of a transaction.
Wallet transaction output.