44 QDialog(parent,
GUIUtil::dialog_flags),
64 QAction *clipboardQuantityAction =
new QAction(tr(
"Copy quantity"),
this);
65 QAction *clipboardAmountAction =
new QAction(tr(
"Copy amount"),
this);
66 QAction *clipboardFeeAction =
new QAction(tr(
"Copy fee"),
this);
67 QAction *clipboardAfterFeeAction =
new QAction(tr(
"Copy after fee"),
this);
68 QAction *clipboardBytesAction =
new QAction(tr(
"Copy bytes"),
this);
69 QAction *clipboardChangeAction =
new QAction(tr(
"Copy change"),
this);
78 ui->labelCoinControlQuantity->addAction(clipboardQuantityAction);
79 ui->labelCoinControlAmount->addAction(clipboardAmountAction);
80 ui->labelCoinControlFee->addAction(clipboardFeeAction);
81 ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction);
82 ui->labelCoinControlBytes->addAction(clipboardBytesAction);
83 ui->labelCoinControlChange->addAction(clipboardChangeAction);
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())));
377 nPayAmount += amount;
384 unsigned int nBytes = 0;
385 unsigned int nBytesInputs = 0;
386 unsigned int nQuantity = 0;
387 bool fWitness =
false;
392 for (
const auto& out :
model->wallet().getCoins(vCoinControl)) {
393 if (out.depth_in_main_chain < 0)
continue;
397 const COutPoint& outpt = vCoinControl[i++];
408 nAmount += out.txout.nValue;
412 int witnessversion = 0;
413 std::vector<unsigned char> witnessprogram;
414 if (out.txout.scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram))
417 nBytesInputs += (32 + 4 + 1 + 4);
419 if (witnessversion == 0) {
422 }
else if (witnessversion == 1) {
427 throw std::runtime_error(
"Trying to spend future segwit version script");
434 PKHash* pkhash = std::get_if<PKHash>(&address);
435 if (pkhash &&
model->wallet().getPubKey(out.txout.scriptPubKey,
ToKeyID(*pkhash), pubkey))
442 else nBytesInputs += 148;
461 if (nAmount - nPayAmount == 0)
469 nChange = nAmount - nPayAmount;
475 CTxOut txout(nChange,
CScript() << std::vector<unsigned char>(24, 0));
477 if (
IsDust(txout,
model->node().getDustRelayFee()))
491 nAfterFee = std::max<CAmount>(nAmount - nPayFee, 0);
497 nDisplayUnit =
model->getOptionsModel()->getDisplayUnit();
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);
511 l1->setText(QString::number(nQuantity));
515 l5->setText(((nBytes > 0) ?
ASYMP_UTF8 :
"") + QString::number(nBytes));
526 double dFeeVary = (nBytes != 0) ? (
double)nPayFee / nBytes : 0;
528 QString toolTip4 = tr(
"Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);
530 l3->setToolTip(toolTip4);
531 l4->setToolTip(toolTip4);
532 l8->setToolTip(toolTip4);
533 dialog->findChild<QLabel *>(
"labelCoinControlFeeText") ->setToolTip(l3->toolTip());
534 dialog->findChild<QLabel *>(
"labelCoinControlAfterFeeText") ->setToolTip(l4->toolTip());
535 dialog->findChild<QLabel *>(
"labelCoinControlBytesText") ->setToolTip(l5->toolTip());
536 dialog->findChild<QLabel *>(
"labelCoinControlChangeText") ->setToolTip(l8->toolTip());
539 QLabel *label = dialog->findChild<QLabel *>(
"labelCoinControlInsuffFunds");
541 label->setVisible(nChange < 0);
555 if (!
model || !
model->getOptionsModel() || !
model->getAddressTableModel())
558 bool treeMode =
ui->radioTreeMode->isChecked();
560 ui->treeWidget->clear();
561 ui->treeWidget->setEnabled(
false);
562 ui->treeWidget->setAlternatingRowColors(!treeMode);
563 QFlags<Qt::ItemFlag> flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
564 QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate;
568 for (
const auto& coins :
model->wallet().listCoins()) {
571 QString sWalletLabel =
model->getAddressTableModel()->labelForAddress(sWalletAddress);
572 if (sWalletLabel.isEmpty())
573 sWalletLabel = tr(
"(no label)");
580 itemWalletAddress->setFlags(flgTristate);
592 for (
const auto& outpair : coins.second) {
593 const COutPoint& output = std::get<0>(outpair);
595 nSum += out.txout.nValue;
601 itemOutput->setFlags(flgCheckbox);
606 QString sAddress =
"";
612 if (!treeMode || (!(sAddress == sWalletAddress)))
617 if (!(sAddress == sWalletAddress))
620 itemOutput->setToolTip(
COLUMN_LABEL, tr(
"change from %1 (%2)").arg(sWalletLabel).arg(sWalletAddress));
625 QString sLabel =
model->getAddressTableModel()->labelForAddress(sAddress);
626 if (sLabel.isEmpty())
627 sLabel = tr(
"(no label)");
633 itemOutput->setData(
COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)out.txout.nValue));
637 itemOutput->setData(
COLUMN_DATE, Qt::UserRole, QVariant((qlonglong)out.time));
641 itemOutput->setData(
COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant((qlonglong)out.depth_in_main_chain));
650 if (
model->wallet().isLockedCoin(output))
653 itemOutput->setDisabled(
true);
665 itemWalletAddress->setText(
COLUMN_CHECKBOX,
"(" + QString::number(nChildren) +
")");
667 itemWalletAddress->setData(
COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)nSum));
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);
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.