8 #include "ui_sendcoinsdialog.h"
31 #include <QMessageBox>
34 #include <QTextDocument>
37 #include <QDesktopServices>
46 fNewRecipientAllowed(true)
52 connect(
ui->addButton, SIGNAL(clicked()),
this, SLOT(
addEntry()));
57 connect(
ui->lineEditCoinControlChange, SIGNAL(textEdited(
const QString&)),
this, SLOT(
coinControlChangeEdited(
const QString&)));
60 QAction* clipboardQuantityAction =
new QAction(tr(
"Copy quantity"),
this);
61 QAction* clipboardAmountAction =
new QAction(tr(
"Copy amount"),
this);
62 QAction* clipboardFeeAction =
new QAction(tr(
"Copy fee"),
this);
63 QAction* clipboardAfterFeeAction =
new QAction(tr(
"Copy after fee"),
this);
64 QAction* clipboardBytesAction =
new QAction(tr(
"Copy bytes"),
this);
65 QAction* clipboardPriorityAction =
new QAction(tr(
"Copy priority"),
this);
66 QAction* clipboardLowOutputAction =
new QAction(tr(
"Copy dust"),
this);
67 QAction* clipboardChangeAction =
new QAction(tr(
"Copy change"),
this);
76 ui->labelCoinControlQuantity->addAction(clipboardQuantityAction);
77 ui->labelCoinControlAmount->addAction(clipboardAmountAction);
78 ui->labelCoinControlFee->addAction(clipboardFeeAction);
79 ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction);
80 ui->labelCoinControlBytes->addAction(clipboardBytesAction);
81 ui->labelCoinControlPriority->addAction(clipboardPriorityAction);
82 ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction);
83 ui->labelCoinControlChange->addAction(clipboardChangeAction);
86 ui->addButton->setVisible(
false);
87 ui->checkBoxCoinControlChange->setVisible(
false);
88 ui->lineEditCoinControlChange->setVisible(
false);
89 ui->splitBlockCheckBox->setVisible(
false);
90 ui->splitBlockLineEdit->setVisible(
false);
91 ui->labelBlockSize->setVisible(
false);
92 ui->labelBlockSizeText->setVisible(
false);
93 ui->labelCoinControlInsuffFunds->setVisible(
false);
96 ui->frameCoinControl->hide();
112 for (
int i = 0; i <
ui->entries->count(); ++i) {
113 SendCoinsEntry* entry = qobject_cast<SendCoinsEntry*>(
ui->entries->itemAt(i)->widget());
125 const CAmount& watchOnlyBalance,
const CAmount& watchUnconfBalance,
const CAmount& watchImmatureBalance)
129 ui->labelBalance->setText(
"Locked; Hidden");
130 }
else if (
settings.value(
"fHideBalance",
false).toBool()) {
131 ui->labelBalance->setText(
"Hidden");
144 msgBox.setWindowTitle(
"Send Disabled - Syncing");
145 msgBox.setText(
"Sending PRCY is disabled when you are still syncing the wallet. Please allow the wallet to fully sync before attempting to send a transaction.");
147 msgBox.setIcon(QMessageBox::Warning);
151 if (!
ui->entries->count())
154 SendCoinsEntry* form = qobject_cast<SendCoinsEntry*>(
ui->entries->itemAt(0)->widget());
156 QString address = recipient.
address;
160 bool isValidAddresss = (
regex_match(address.toStdString(), std::regex(
"[a-zA-z0-9]+")))&&(address.length()==99||address.length()==110);
161 bool isValidAmount = ((recipient.
amount>0) && (recipient.
amount<=balance));
162 bool fAlwaysRequest2FA =
settings.value(
"fAlwaysRequest2FA").toBool();
163 bool fAlwaysRequestPassphrase =
settings.value(
"fAlwaysRequestPassphrase").toBool();
168 if (!isValidAddresss) {
170 msgBox.setWindowTitle(
"Invalid Address");
171 msgBox.setText(
"Invalid address entered. Please make sure you are sending to a Stealth Address.");
173 msgBox.setIcon(QMessageBox::Warning);
178 if (!isValidAmount) {
180 msgBox.setWindowTitle(
"Invalid Amount");
181 msgBox.setText(
"Invalid amount entered. Please enter an amount less than your Spendable Balance.");
183 msgBox.setIcon(QMessageBox::Warning);
202 QStringList formatted;
203 formatted.append(
"<center>");
206 QString recipientElement;
207 recipientElement.append(
"<span class='h1 b'>"+amount+
"</span><br/>");
208 recipientElement.append(
"<br/>to<br/>");
211 recipientElement.append(
"<br/><span class='h3'>"+tr(
"Destination")+
": <br/><b>"+recipient.
address+
"</b></span><br/>");
213 formatted.append(recipientElement);
216 QString questionString =
"<br/><span class='h2'><center><b>"+tr(
"Are you sure you want to send?")+
"</b></center></span>";
217 questionString.append(
"%1");
218 questionString.append(
"<br/><span class='h3'>"+tr(
"Estimated Transaction fee")+
": <br/><b>");
219 questionString.append(strFee+
"</b></span>");
220 questionString.append(
"<br/><br/>");
224 if (recipient.
amount == balance) {
231 questionString.append(tr(
"<span class='h3'>Total Amount = <b>%1</b><br/></center>")
234 if (fAlwaysRequest2FA) {
235 questionString.append(
"<center><br/>Note: Request 2FA authentication code before sending any transactions is enabled.<br/>You will be asked for your 2FA code on the next screen.<br/><br/></center>");
239 QMessageBox::StandardButton retval = QMessageBox::question(
this, tr(
"Confirm Send Coins"),
240 questionString.arg(formatted.join(
"<br />")),
241 QMessageBox::Yes | QMessageBox::Cancel,
242 QMessageBox::Cancel);
244 if (retval != QMessageBox::Yes) {
253 if (recipient.
amount > spendable) {
255 msgBox.setWindowTitle(
"Insufficient Spendable Funds!");
256 msgBox.setText(
"Insufficient spendable funds. Send with smaller amount or wait for your coins become mature");
258 msgBox.setIcon(QMessageBox::Information);
262 msgBox.setWindowTitle(
"Insufficient Reserve Funds!");
263 msgBox.setText(
"Insufficient reserve funds. Send with smaller amount or turn off staking mode.");
265 msgBox.setIcon(QMessageBox::Information);
279 QDateTime current = QDateTime::currentDateTime();
280 uint diffTime = current.toTime_t() - lastTime;
281 if (diffTime <= period * 24 * 60 * 60 || !fAlwaysRequest2FA)
285 codedlg.setWindowTitle(
"2FA Code Verification");
287 connect(&codedlg, SIGNAL(finished (
int)),
this, SLOT(
dialogIsFinished(
int)));
294 bool success =
false;
299 if (
send_amount == spendable && spendable == balance) {
316 }
catch (
const std::exception& err) {
317 std::string errMes(err.what());
318 if (errMes.find(
"You have attempted to send more than 50 UTXOs in a single transaction") != std::string::npos) {
319 QMessageBox::StandardButton reply;
320 reply = QMessageBox::question(
this,
"Transaction Size Too Large", QString(err.what()) + QString(
"\n\nDo you want to combine small UTXOs into a larger one?"), QMessageBox::Yes|QMessageBox::No);
321 if (reply == QMessageBox::Yes) {
331 QString msg =
"Consolidation transaction created!";
333 msgBox.setWindowTitle(
"Information");
334 msgBox.setIcon(QMessageBox::Information);
340 msgBox.setWindowTitle(
"Sweeping Transaction Creation Error");
341 msgBox.setText(QString(
"Sweeping transaction creation failed due to an internal error. Please try again later."));
343 msgBox.setIcon(QMessageBox::Critical);
346 }
catch (
const std::exception& err1) {
349 LogPrintf(
"ERROR:%s: %s\n", __func__, err1.what());
350 msgBox.setWindowTitle(
"Sweeping Transaction Creation Error");
351 msgBox.setText(QString(
"Sweeping transaction creation failed due to an internal error. Please try again later."));
353 msgBox.setIcon(QMessageBox::Critical);
361 QString msg = err.what();
363 msg =
"Unable to create transaction. Please try again later.";
366 msgBox.setWindowTitle(
"Transaction Creation Error");
369 msgBox.setIcon(QMessageBox::Critical);
379 std::string myAddress;
381 bool showCheckBox =
false;
383 if (sendAddress == myAddress) {
384 for (
int i=0; i < (int)resultTx.
vout.size(); i++) {
395 QCheckBox *cb =
new QCheckBox(
"5000 PRCY transaction detected. Would you like to lock this transaction output?");
397 msgBox.setCheckBox(cb);
399 QPushButton *viewButton = msgBox.addButton(tr(
"View on Explorer"), QMessageBox::ActionRole);
400 QPushButton *copyButton = msgBox.addButton(tr(
"Copy"), QMessageBox::ActionRole);
401 QPushButton *okButton = msgBox.addButton(tr(
"OK"), QMessageBox::ActionRole);
402 msgBox.setWindowTitle(
"Transaction Initialized");
403 msgBox.setText(
"Transaction initialized.\n\n" + txhash);
405 msgBox.setIcon(QMessageBox::Information);
408 if (msgBox.clickedButton() == viewButton) {
412 URL =
"https://explorer.prcycoin.com/tx/";
414 URL =
"https://testnet.prcycoin.com/tx/";
417 QDesktopServices::openUrl(QUrl(URL.append(txhash)));
420 if (msgBox.clickedButton() == copyButton) {
424 if ((msgBox.clickedButton() == viewButton || msgBox.clickedButton() == copyButton || msgBox.clickedButton() == okButton) && cb->isChecked()) {
428 LogPrintf(
"Masternode transaction: %s:%i has been locked\n", resultTx.
GetHash().
GetHex().c_str(), indexOut);
434 if(result == QDialog::Accepted){
443 ui->entries->addWidget(entry);
445 ui->scrollAreaWidgetContents->resize(
ui->scrollAreaWidgetContents->sizeHint());
446 qApp->processEvents();
447 QScrollBar* bar =
ui->scrollArea->verticalScrollBar();
449 bar->setSliderPosition(bar->maximum());
467 GUIUtil::setClipboard(
ui->labelCoinControlFee->text().left(
ui->labelCoinControlFee->text().indexOf(
" ")).replace(
"~",
""));
473 GUIUtil::setClipboard(
ui->labelCoinControlAfterFee->text().left(
ui->labelCoinControlAfterFee->text().indexOf(
" ")).replace(
"~",
""));
497 GUIUtil::setClipboard(
ui->labelCoinControlChange->text().left(
ui->labelCoinControlChange->text().indexOf(
" ")).replace(
"~",
""));
503 ui->frameCoinControl->setVisible(checked);
505 if (!checked &&
model)
524 if (state == Qt::Unchecked) {
526 ui->labelCoinControlChangeLabel->clear();
531 ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));
540 ui->labelCoinControlChangeLabel->setStyleSheet(
"QLabel{color:red;}");
546 ui->labelCoinControlChangeLabel->setText(
"");
549 ui->labelCoinControlChangeLabel->setText(tr(
"Warning: Invalid PIVX address"));
557 ui->labelCoinControlChangeLabel->setText(tr(
"Warning: Unknown change address"));
560 ui->labelCoinControlChangeLabel->setStyleSheet(
"QLabel{color:black;}");
564 if (!associatedLabel.isEmpty())
565 ui->labelCoinControlChangeLabel->setText(associatedLabel);
567 ui->labelCoinControlChangeLabel->setText(tr(
"(no label)"));
583 for (
int i = 0; i <
ui->entries->count(); ++i) {
584 SendCoinsEntry* entry = qobject_cast<SendCoinsEntry*>(
ui->entries->itemAt(i)->widget());
594 ui->labelCoinControlAutomaticallySelected->hide();
595 ui->widgetCoinControl->show();
598 ui->labelCoinControlAutomaticallySelected->show();
599 ui->widgetCoinControl->hide();
600 ui->labelCoinControlInsuffFunds->hide();