6 #include "ui_sendconfirmdialog.h"
22 isConfirmDialog(_isConfirmDialog)
26 this->setStyleSheet(parent->styleSheet());
34 setCssProperty({
ui->labelAmount,
ui->labelSend,
ui->labelInputs,
ui->labelFee,
ui->labelChange,
ui->labelId,
ui->labelSize,
ui->labelStatus,
ui->labelConfirmations,
ui->labelDate,
ui->labelMemo},
"text-subtitle");
35 setCssProperty({
ui->labelDividerID,
ui->labelDividerOutputs,
ui->labelDividerPrevtx,
ui->labelDividerFeeSize,
ui->labelDividerChange,
ui->labelDividerConfs,
ui->labelDividerMemo},
"container-divider");
36 setCssProperty({
ui->textAmount,
ui->textSendLabel,
ui->textInputs,
ui->textFee,
ui->textChange,
ui->textId,
ui->textSize,
ui->textStatus,
ui->textConfirmations,
ui->textDate,
ui->textMemo} ,
"text-body3-dialog");
42 ui->labelWarning->setVisible(
false);
43 ui->gridInputs->setVisible(
false);
44 ui->outputsScrollArea->setVisible(
false);
47 ui->contentChangeAddress->setVisible(
false);
48 ui->labelDividerChange->setVisible(
false);
51 ui->textMemo->setProperty(
"cssClass",
"edit-primary-no-border");
56 ui->labelTitle->setText(tr(
"Confirm Your Transaction"));
58 ui->btnSave->setText(tr(
"SEND"));
60 if (!warningStr.isEmpty()) {
61 ui->labelWarning->setVisible(
true);
62 ui->labelWarning->setText(warningStr);
64 ui->labelWarning->setVisible(
false);
68 ui->contentID->setVisible(
false);
69 ui->labelDividerID->setVisible(
false);
70 ui->gridConfDateStatus->setVisible(
false);
71 ui->labelDividerConfs->setVisible(
false);
72 ui->contentSize->setVisible(
false);
74 connect(
ui->btnCancel, &QPushButton::clicked,
this, &TxDetailDialog::close);
75 connect(
ui->btnSave, &QPushButton::clicked, [
this](){accept();});
77 ui->labelTitle->setText(tr(
"Transaction Details"));
78 ui->containerButtons->setVisible(
false);
81 connect(
ui->btnEsc, &QPushButton::clicked,
this, &TxDetailDialog::close);
88 if (
tx->sapData &&
tx->sapData->vShieldedSpend.empty()) {
89 ui->labelTitlePrevTx->setText(tr(
"Previous Transaction"));
90 ui->labelOutputIndex->setText(tr(
"Output Index"));
92 ui->labelTitlePrevTx->setText(tr(
"Note From Address"));
93 ui->labelOutputIndex->setText(tr(
"Index"));
102 QString address = index.data(Qt::DisplayRole).toString();
105 ui->textAmount->setText(amountText);
110 QString hash = QString::fromStdString(_tx->
GetHash().
GetHex());
111 ui->textId->setText(hash.left(20) +
"..." + hash.right(20));
112 ui->textId->setTextInteractionFlags(Qt::TextSelectableByMouse);
115 if (_tx->
tx->vout.size() == 1 || (_tx->
tx->sapData && _tx->
tx->sapData->vShieldedOutput.size() == 1)) {
116 ui->textSendLabel->setText((address.size() < 40) ? address : address.left(20) +
"..." + address.right(20));
118 ui->textSendLabel->setText(QString::number(_tx->
tx->vout.size() +
119 (_tx->
tx->sapData ? _tx->
tx->sapData->vShieldedOutput.size() : 0)) +
" recipients");
121 ui->textSend->setVisible(
false);
125 QString shieldedInputsExtraMsg =
"";
127 ui->pushInputs->setVisible(
false);
128 shieldedInputsExtraMsg =
" shielded";
132 int inputsSize = (_tx->
tx->sapData && !_tx->
tx->sapData->vShieldedSpend.empty()) ? _tx->
tx->sapData->vShieldedSpend.size() : _tx->
tx->vin.size();
133 ui->textInputs->setText(QString::number(inputsSize) + shieldedInputsExtraMsg);
134 ui->textConfirmations->setText(QString::number(rec->
status.
depth));
137 ui->textSize->setText(QString::number(rec->
size) +
" bytes");
141 ui->textMemo->insertPlainText(QString::fromStdString(*rec->
memo));
142 ui->contentMemo->setVisible(
true);
143 ui->labelDividerMemo->setVisible(
true);
144 ui->textMemo->adjustSize();
145 ui->textMemo->moveCursor(QTextCursor::Start);
146 ui->textMemo->ensureCursorVisible();
148 ui->contentMemo->setVisible(
false);
149 ui->labelDividerMemo->setVisible(
false);
153 connect(
ui->pushCopy, &QPushButton::clicked, [
this](){
154 GUIUtil::setClipboard(QString::fromStdString(this->txHash.GetHex()));
155 if (!snackBar) snackBar = new SnackBar(nullptr, this);
156 snackBar->setText(tr(
"ID copied"));
157 snackBar->resize(this->width(), snackBar->height());
158 openDialog(snackBar, this);
161 connect(
ui->pushCopyMemo, &QPushButton::clicked, [
this, rec](){
162 GUIUtil::setClipboard(QString::fromStdString(*rec->memo));
163 if (!snackBar) snackBar = new SnackBar(nullptr, this);
164 snackBar->setText(tr(
"Memo copied"));
165 snackBar->resize(this->width(), snackBar->height());
166 openDialog(snackBar, this);
174 QString addressToShow;
175 if (address.size() > 60) {
176 addressToShow = address.left(57) +
"\n" + address.mid(57);
178 addressToShow = address;
180 return addressToShow;
185 this->
model = _model;
199 int nRecipients = recipients.size();
200 if (nRecipients == 1) {
203 ui->labelSend->setText(tr(
"Delegating to"));
206 ui->labelSend->setText(tr(
"Shielding to"));
208 if (recipient.
label.isEmpty()) {
209 ui->textSend->setVisible(
false);
213 ui->textSendLabel->setText(recipient.
label);
215 ui->pushOutputs->setVisible(
false);
218 if (!recipient.
message.isEmpty()) {
219 ui->textMemo->insertPlainText(recipient.
message);
220 ui->contentMemo->setVisible(
true);
221 ui->labelDividerMemo->setVisible(
true);
222 ui->textMemo->moveCursor(QTextCursor::Start);
223 ui->textMemo->ensureCursorVisible();
225 ui->contentMemo->setVisible(
false);
226 ui->labelDividerMemo->setVisible(
false);
229 ui->textSendLabel->setText(QString::number(nRecipients) +
" recipients");
230 ui->textSend->setVisible(
false);
231 ui->contentMemo->setVisible(
false);
232 ui->labelDividerMemo->setVisible(
false);
235 int inputsSize = (walletTx->sapData && !walletTx->sapData->vShieldedSpend.empty()) ? walletTx->sapData->vShieldedSpend.size() : walletTx->vin.size();
236 ui->textInputs->setText(QString::number(inputsSize));
249 void loadInputs(
const QString& leftLabel,
const QString& rightLabel, QGridLayout *gridLayoutInput,
int pos)
251 QLabel *label_txid =
new QLabel(leftLabel);
252 QLabel *label_txidn =
new QLabel(rightLabel);
253 label_txidn->setAlignment(Qt::AlignCenter | Qt::AlignRight);
256 gridLayoutInput->addWidget(label_txid, pos, 0);
257 gridLayoutInput->addWidget(label_txidn, pos, 1);
262 if (
ui->gridInputs->isVisible()) {
263 ui->gridInputs->setVisible(
false);
271 if (walletTx->sapData && walletTx->sapData->vShieldedSpend.empty()) {
273 ui->gridInputs->setMinimumHeight(50 + (50 * walletTx->vin.size()));
275 for (
const CTxIn& in : walletTx->vin) {
277 loadInputs(hash.left(18) +
"..." + hash.right(18),
279 ui->gridLayoutInput, i);
283 ui->gridInputs->setMinimumHeight(50 + (50 * walletTx->sapData->vShieldedSpend.size()));
284 bool fInfoAvailable =
false;
285 for (
int i = 0; i < (int) walletTx->sapData->vShieldedSpend.size(); ++i) {
288 QString addr = *opAddr;
289 loadInputs(addr.left(18) +
"..." + addr.right(18),
291 ui->gridLayoutInput, i + 1);
292 fInfoAvailable =
true;
296 if (!fInfoAvailable) {
305 ui->gridInputs->setVisible(showGrid);
309 void appendOutput(QGridLayout* layoutGrid,
int gridPosition, QString labelRes,
CAmount nValue,
int nDisplayUnit)
311 QLabel *label_address =
new QLabel(labelRes);
313 label_value->setAlignment(Qt::AlignCenter | Qt::AlignRight);
314 setCssProperty({label_address, label_value},
"text-body2-dialog");
315 layoutGrid->addWidget(label_address, gridPosition, 0);
316 layoutGrid->addWidget(label_value, gridPosition, 0);
321 if (
ui->outputsScrollArea->isVisible()) {
322 ui->outputsScrollArea->setVisible(
false);
324 ui->outputsScrollArea->setVisible(
true);
327 QGridLayout* layoutGrid =
new QGridLayout(
this);
328 layoutGrid->setContentsMargins(0,0,12,0);
329 ui->container_outputs_base->setLayout(layoutGrid);
336 for (
int i = 0; i < recipients.size(); ++i) {
337 const auto& recipient = recipients[i];
338 CAmount rcp_amt = recipient.amount - (recipient.fSubtractFee ? rcp_fee : 0);
339 int charsSize = recipient.isShieldedAddr ? 18 : 16;
340 QString labelRes = recipient.address.left(charsSize) +
"..." + recipient.address.right(charsSize);
346 if (!walletTx)
return;
350 for (
const CTxOut& out : walletTx->
tx->vout) {
357 labelRes = QString::fromStdString(address);
358 labelRes = labelRes.left(16) +
"..." + labelRes.right(16);
360 labelRes = tr(
"Unknown");
367 if (walletTx->
tx->sapData) {
368 for (
int j = 0; j < (int) walletTx->
tx->sapData->vShieldedOutput.size(); ++j) {
int64_t CAmount
Amount in PIV (Can be negative)
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
bool IsPayToColdStaking() const
bool IsPayToExchangeAddress() const
An input of a transaction.
An output of a transaction.
A transaction with a bunch of additional info that only the owner cares about.
mapSaplingNoteData_t mapSaplingNoteData
const uint256 & GetHash() const
Optional< CAmount > amount
Cached note amount.
An outpoint - a combination of a transaction hash and an index n into its sapling output description ...
UI model for a transaction.
std::string statusToString()
Return transaction status.
TransactionStatus status
Status: can change with block chain update.
Optional< std::string > memo
@ DateRole
Date and time this transaction was created.
@ AmountRole
Net amount of transaction.
WalletModel::SendCoinsReturn sendStatus
bool isShieldedToShieldedRecv
void setInputsType(CTransactionRef _tx)
TxDetailDialog(QWidget *parent=nullptr, bool isConfirmDialog=true, const QString &warningStr=QString())
void setData(WalletModel *model, WalletModelTransaction *tx)
WalletModelTransaction * tx
Interface to PIVX wallet from Qt view code.
QString getSaplingAddressString(const CWalletTx *wtx, const SaplingOutPoint &op) const
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
Optional< QString > getShieldedAddressFromSpendDesc(const uint256 &txHash, int index)
const CWalletTx * getTx(uint256 id)
Data model for a walletmodel transaction.
unsigned int subtractFeeFromRecipents() const
CAmount getTotalTransactionAmount()
QList< SendCoinsRecipient > getRecipients()
CTransactionRef & getTransaction()
CAmount getTransactionFee()
std::string GetHex() const
QString dateTimeStrWithSeconds(const QDateTime &date)
std::string EncodeDestination(const CWDestination &address, const CChainParams::Base58Type addrType)
boost::optional< T > Optional
Substitute for C++17 std::optional.
void setCssProperty(std::initializer_list< QWidget * > args, const QString &value)
void setCssBtnPrimary(QPushButton *btn, bool forceUpdate)
void appendOutput(QGridLayout *layoutGrid, int gridPosition, QString labelRes, CAmount nValue, int nDisplayUnit)
QString formatAdressToShow(const QString &address)
void loadInputs(const QString &leftLabel, const QString &rightLabel, QGridLayout *gridLayoutInput, int pos)
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet, bool fColdStake)
Parse a standard scriptPubKey for the destination address.
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.
std::shared_ptr< const CTransaction > CTransactionRef