6#include <qt/forms/ui_coincontroldialog.h>
22#include <QApplication>
25#include <QDialogButtonBox>
39 return data(column, Qt::UserRole).toLongLong() < other.data(column, Qt::UserRole).toLongLong();
40 return QTreeWidgetItem::operator<(other);
44 QDialog(parent,
GUIUtil::dialog_flags),
93 ui->treeWidget->header()->setSectionsClickable(
true);
114 if (
settings.contains(
"nCoinControlMode") && !
settings.value(
"nCoinControlMode").toBool())
115 ui->radioTreeMode->click();
116 if (
settings.contains(
"nCoinControlSortColumn") &&
settings.contains(
"nCoinControlSortOrder"))
117 sortView(
settings.value(
"nCoinControlSortColumn").toInt(), (
static_cast<Qt::SortOrder
>(
settings.value(
"nCoinControlSortOrder").toInt())));
121 if(
_model->getOptionsModel() &&
_model->getAddressTableModel())
132 settings.setValue(
"nCoinControlMode",
ui->radioListMode->isChecked());
142 if (
ui->buttonBox->buttonRole(
button) == QDialogButtonBox::AcceptRole)
143 done(QDialog::Accepted);
149 Qt::CheckState state = Qt::Checked;
150 for (
int i = 0; i <
ui->treeWidget->topLevelItemCount(); i++)
152 if (
ui->treeWidget->topLevelItem(i)->checkState(
COLUMN_CHECKBOX) != Qt::Unchecked)
154 state = Qt::Unchecked;
158 ui->treeWidget->setEnabled(
false);
159 for (
int i = 0; i <
ui->treeWidget->topLevelItemCount(); i++)
162 ui->treeWidget->setEnabled(
true);
163 if (state == Qt::Unchecked)
171 QTreeWidgetItem *
item =
ui->treeWidget->itemAt(point);
296 ui->treeWidget->sortItems(column, order);
310 sortOrder = ((
sortOrder == Qt::AscendingOrder) ? Qt::DescendingOrder : Qt::AscendingOrder);
345 else if (
item->isDisabled())
351 if (
ui->treeWidget->isEnabled())
359 std::vector<COutPoint>
vOutpts;
364 ui->labelLocked->setVisible(
true);
366 else ui->labelLocked->setVisible(
false);
393 if (out.depth_in_main_chain < 0)
continue;
408 nAmount += out.txout.nValue;
427 throw std::runtime_error(
"Trying to spend future segwit version script");
499 QLabel *
l1 =
dialog->findChild<QLabel *>(
"labelCoinControlQuantity");
500 QLabel *
l2 =
dialog->findChild<QLabel *>(
"labelCoinControlAmount");
501 QLabel *
l3 =
dialog->findChild<QLabel *>(
"labelCoinControlFee");
502 QLabel *
l4 =
dialog->findChild<QLabel *>(
"labelCoinControlAfterFee");
503 QLabel *
l5 =
dialog->findChild<QLabel *>(
"labelCoinControlBytes");
504 QLabel *
l8 =
dialog->findChild<QLabel *>(
"labelCoinControlChange");
507 dialog->findChild<QLabel *>(
"labelCoinControlChangeText") ->setEnabled(
nPayAmount > 0);
508 dialog->findChild<QLabel *>(
"labelCoinControlChange") ->setEnabled(
nPayAmount > 0);
534 dialog->findChild<QLabel *>(
"labelCoinControlAfterFeeText") ->
setToolTip(
l4->toolTip());
536 dialog->findChild<QLabel *>(
"labelCoinControlChangeText") ->
setToolTip(
l8->toolTip());
539 QLabel *label =
dialog->findChild<QLabel *>(
"labelCoinControlInsuffFunds");
541 label->setVisible(
nChange < 0);
546 if (
e->type() == QEvent::PaletteChange) {
550 QDialog::changeEvent(
e);
558 bool treeMode =
ui->radioTreeMode->isChecked();
560 ui->treeWidget->clear();
561 ui->treeWidget->setEnabled(
false);
562 ui->treeWidget->setAlternatingRowColors(!
treeMode);
592 for (
const auto&
outpair : coins.second) {
595 nSum += out.txout.nValue;
674 for (
int i = 0; i <
ui->treeWidget->topLevelItemCount(); i++)
675 if (
ui->treeWidget->topLevelItem(i)->checkState(
COLUMN_CHECKBOX) == Qt::PartiallyChecked)
676 ui->treeWidget->topLevelItem(i)->setExpanded(
true);
681 ui->treeWidget->setEnabled(
true);
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a scriptPubKey for the destination.
CKeyID ToKeyID(const PKHash &key_hash)
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
int64_t CAmount
Amount in satoshis (Can be negative)
QString labelForAddress(const QString &address) const
Look up label for address in address book, if not found return empty string.
static QString format(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
Format as string.
static QString removeSpaces(QString text)
static QString formatWithUnit(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
An outpoint - a combination of a transaction hash and an index n into its vout.
An encapsulated public key.
bool IsCompressed() const
Check whether this is a compressed public key.
Serialized script, used inside transaction inputs and outputs.
An output of a transaction.
void headerSectionClicked(int)
QTreeWidgetItem * contextMenuItem
friend class CCoinControlWidgetItem
CoinControlDialog(wallet::CCoinControl &coin_control, WalletModel *model, const PlatformStyle *platformStyle, QWidget *parent=nullptr)
void copyTransactionOutpoint()
const PlatformStyle * platformStyle
void changeEvent(QEvent *e) override
Ui::CoinControlDialog * ui
void sortView(int, Qt::SortOrder)
void showMenu(const QPoint &)
void viewItemChanged(QTreeWidgetItem *, int)
wallet::CCoinControl & m_coin_control
void buttonSelectAllClicked()
QAction * m_copy_transaction_outpoint_action
static QList< CAmount > payAmounts
static void updateLabels(wallet::CCoinControl &m_coin_control, WalletModel *, QDialog *)
static bool fSubtractFeeFromAmount
void buttonBoxClicked(QAbstractButton *)
BitcoinUnit getDisplayUnit() const
Interface to Bitcoin wallet from Qt view code.
interfaces::Node & node() const
AddressTableModel * getAddressTableModel() const
interfaces::Wallet & wallet() const
OptionsModel * getOptionsModel() const
virtual CFeeRate getDustRelayFee()=0
Get dust relay fee.
virtual bool unlockCoin(const COutPoint &output)=0
Unlock coin.
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 bool isLockedCoin(const COutPoint &output)=0
Return whether coin is locked.
virtual void listLockedCoins(std::vector< COutPoint > &outputs)=0
List locked coins.
virtual bool lockCoin(const COutPoint &output, bool write_to_db)=0
Lock coin.
virtual CAmount getMinimumFee(unsigned int tx_bytes, const wallet::CCoinControl &coin_control, int *returned_target, FeeReason *reason)=0
Get minimum fee.
std::string GetHex() const
static std::optional< transaction_identifier > FromHex(std::string_view hex)
bool IsSelected(const COutPoint &outpoint) const
Returns true if the given output is pre-selected.
void UnSelectAll()
Unselects all outputs.
void UnSelect(const COutPoint &outpoint)
Unselects the given output.
PreselectedInput & Select(const COutPoint &outpoint)
Lock-in the given output for spending.
std::vector< COutPoint > ListSelected() const
List the selected inputs.
static const int WITNESS_SCALE_FACTOR
std::string EncodeDestination(const CTxDestination &dest)
Utility functions used by the Bitcoin Qt UI.
void handleCloseWindowShortcut(QWidget *w)
QString dateTimeStr(const QDateTime &date)
void setClipboard(const QString &str)
bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFeeIn)
Wallet transaction output.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.