Raven Core  3.0.0
P2P Digital Currency
reissueassetdialog.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 
7 #include "reissueassetdialog.h"
8 #include "ui_reissueassetdialog.h"
9 #include "platformstyle.h"
10 #include "walletmodel.h"
11 #include "assettablemodel.h"
12 #include "addresstablemodel.h"
13 #include "core_io.h"
14 #include "univalue.h"
15 #include "assets/assettypes.h"
16 #include "ravenunits.h"
17 #include "optionsmodel.h"
18 #include "sendcoinsdialog.h"
19 #include "coincontroldialog.h"
20 #include "guiutil.h"
21 #include "clientmodel.h"
22 #include "guiconstants.h"
23 
24 #include <validation.h>
25 #include <script/standard.h>
26 #include <wallet/wallet.h>
27 #include <policy/policy.h>
28 #include <base58.h>
29 
30 #include "wallet/coincontrol.h"
31 #include "policy/fees.h"
32 #include "wallet/fees.h"
33 
34 #include <QGraphicsDropShadowEffect>
35 #include <QModelIndex>
36 #include <QDebug>
37 #include <QMessageBox>
38 #include <QClipboard>
39 #include <QSettings>
40 #include <QStringListModel>
41 #include <QSortFilterProxyModel>
42 #include <QCompleter>
43 
44 
45 ReissueAssetDialog::ReissueAssetDialog(const PlatformStyle *_platformStyle, QWidget *parent) :
46  QDialog(parent),
47  ui(new Ui::ReissueAssetDialog),
48  platformStyle(_platformStyle)
49 {
50  ui->setupUi(this);
51  setWindowTitle("Reissue Assets");
52  connect(ui->comboBox, SIGNAL(activated(int)), this, SLOT(onAssetSelected(int)));
53  connect(ui->quantitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onQuantityChanged(double)));
54  connect(ui->ipfsBox, SIGNAL(clicked()), this, SLOT(onIPFSStateChanged()));
55  connect(ui->ipfsText, SIGNAL(textChanged(QString)), this, SLOT(onIPFSHashChanged(QString)));
56  connect(ui->addressText, SIGNAL(textChanged(QString)), this, SLOT(onAddressNameChanged(QString)));
57  connect(ui->reissueAssetButton, SIGNAL(clicked()), this, SLOT(onReissueAssetClicked()));
58  connect(ui->reissuableBox, SIGNAL(clicked()), this, SLOT(onReissueBoxChanged()));
59  connect(ui->unitSpinBox, SIGNAL(valueChanged(int)), this, SLOT(onUnitChanged(int)));
60  connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(onClearButtonClicked()));
61  this->asset = new CNewAsset();
62  asset->SetNull();
63 
64  GUIUtil::setupAddressWidget(ui->lineEditCoinControlChange, this);
65 
66  // Coin Control
67  connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked()));
68  connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int)));
69  connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &)));
70 
71  // Coin Control: clipboard actions
72  QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this);
73  QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this);
74  QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this);
75  QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this);
76  QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this);
77  QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this);
78  QAction *clipboardChangeAction = new QAction(tr("Copy change"), this);
79  connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity()));
80  connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount()));
81  connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee()));
82  connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee()));
83  connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes()));
84  connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput()));
85  connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange()));
86  ui->labelCoinControlQuantity->addAction(clipboardQuantityAction);
87  ui->labelCoinControlAmount->addAction(clipboardAmountAction);
88  ui->labelCoinControlFee->addAction(clipboardFeeAction);
89  ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction);
90  ui->labelCoinControlBytes->addAction(clipboardBytesAction);
91  ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction);
92  ui->labelCoinControlChange->addAction(clipboardChangeAction);
93 
94  // init transaction fee section
95  QSettings settings;
96  if (!settings.contains("fFeeSectionMinimized"))
97  settings.setValue("fFeeSectionMinimized", true);
98  if (!settings.contains("nFeeRadio") && settings.contains("nTransactionFee") && settings.value("nTransactionFee").toLongLong() > 0) // compatibility
99  settings.setValue("nFeeRadio", 1); // custom
100  if (!settings.contains("nFeeRadio"))
101  settings.setValue("nFeeRadio", 0); // recommended
102  if (!settings.contains("nSmartFeeSliderPosition"))
103  settings.setValue("nSmartFeeSliderPosition", 0);
104  if (!settings.contains("nTransactionFee"))
105  settings.setValue("nTransactionFee", (qint64)DEFAULT_TRANSACTION_FEE);
106  if (!settings.contains("fPayOnlyMinFee"))
107  settings.setValue("fPayOnlyMinFee", false);
108  ui->groupFee->setId(ui->radioSmartFee, 0);
109  ui->groupFee->setId(ui->radioCustomFee, 1);
110  ui->groupFee->button((int)std::max(0, std::min(1, settings.value("nFeeRadio").toInt())))->setChecked(true);
111  ui->customFee->setValue(settings.value("nTransactionFee").toLongLong());
112  ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool());
113  minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool());
114 
115  formatGreen = "%1%2 <font color=green><b>%3</b></font>";
116  formatBlack = "%1%2 <font color=black><b>%3</b></font>";
117  if (darkModeEnabled)
118  formatBlack = "%1%2 <font color=white><b>%3</b></font>";
119 
123 
125  stringModel = new QStringListModel;
126 
127  proxy = new QSortFilterProxyModel;
128  proxy->setSourceModel(stringModel);
129  proxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
130 
131  ui->comboBox->setModel(proxy);
132  ui->comboBox->setEditable(true);
133  ui->comboBox->lineEdit()->setPlaceholderText("Select an asset");
134 
135  completer = new QCompleter(proxy,this);
136  completer->setCompletionMode(QCompleter::PopupCompletion);
137  completer->setCaseSensitivity(Qt::CaseInsensitive);
138  ui->comboBox->setCompleter(completer);
139  adjustSize();
140 }
141 
143 {
144  this->clientModel = _clientModel;
145 
146  if (_clientModel) {
147  connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(updateSmartFeeLabel()));
148  }
149 }
150 
152 {
153  this->model = _model;
154 
155  if(_model && _model->getOptionsModel())
156  {
157  setBalance(_model->getBalance(), _model->getUnconfirmedBalance(), _model->getImmatureBalance(),
158  _model->getWatchBalance(), _model->getWatchUnconfirmedBalance(), _model->getWatchImmatureBalance());
159  connect(_model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)));
160  connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
162 
163  // Coin Control
164  connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels()));
165  connect(_model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool)));
166  bool fCoinControlEnabled = _model->getOptionsModel()->getCoinControlFeatures();
167  ui->frameCoinControl->setVisible(fCoinControlEnabled);
168  ui->addressText->setVisible(fCoinControlEnabled);
169  ui->addressLabel->setVisible(fCoinControlEnabled);
171 
172  // Custom Fee Control
173  ui->frameFee->setVisible(_model->getOptionsModel()->getCustomFeeFeatures());
174  connect(_model->getOptionsModel(), SIGNAL(customFeeFeaturesChanged(bool)), this, SLOT(feeControlFeatureChanged(bool)));
175 
176  // fee section
177  for (const int &n : confTargets) {
178  ui->confTargetSelector->addItem(tr("%1 (%2 blocks)").arg(GUIUtil::formatNiceTimeOffset(n*Params().GetConsensus().nPowTargetSpacing)).arg(n));
179  }
180  connect(ui->confTargetSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSmartFeeLabel()));
181  connect(ui->confTargetSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(coinControlUpdateLabels()));
182  connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(updateFeeSectionControls()));
183  connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(coinControlUpdateLabels()));
184  connect(ui->customFee, SIGNAL(valueChanged()), this, SLOT(coinControlUpdateLabels()));
185  connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(setMinimumFee()));
186  connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(updateFeeSectionControls()));
187  connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
188 // connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(updateSmartFeeLabel()));
189 // connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
190  ui->customFee->setSingleStep(GetRequiredFee(1000));
194 
195  // set default rbf checkbox state
196 // ui->optInRBF->setCheckState(model->getDefaultWalletRbf() ? Qt::Checked : Qt::Unchecked);
197  ui->optInRBF->hide();
198 
199  // set the smartfee-sliders default value (wallets default conf.target or last stored value)
200  QSettings settings;
201  if (settings.value("nSmartFeeSliderPosition").toInt() != 0) {
202  // migrate nSmartFeeSliderPosition to nConfTarget
203  // nConfTarget is available since 0.15 (replaced nSmartFeeSliderPosition)
204  int nConfirmTarget = 25 - settings.value("nSmartFeeSliderPosition").toInt(); // 25 == old slider range
205  settings.setValue("nConfTarget", nConfirmTarget);
206  settings.remove("nSmartFeeSliderPosition");
207  }
208  if (settings.value("nConfTarget").toInt() == 0)
209  ui->confTargetSelector->setCurrentIndex(getIndexForConfTarget(model->getDefaultConfirmTarget()));
210  else
211  ui->confTargetSelector->setCurrentIndex(getIndexForConfTarget(settings.value("nConfTarget").toInt()));
212 
213  ui->reissueCostLabel->setText(tr("Cost") + ": " + RavenUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), GetBurnAmount(AssetType::REISSUE)));
214  ui->reissueCostLabel->setStyleSheet("font-weight: bold");
215 
216  // Setup the default values
217  setUpValues();
218 
219  adjustSize();
220  }
221 }
222 
224 {
225  delete ui;
226  delete asset;
227 }
228 
231 {
232  if (!model)
233  return;
234 
235  ui->reissuableBox->setCheckState(Qt::CheckState::Checked);
236  ui->ipfsText->setDisabled(true);
237  hideMessage();
238 
239  ui->unitExampleLabel->setStyleSheet("font-weight: bold");
240 
242 
243  // Set style for current asset data
244  ui->currentAssetData->viewport()->setAutoFillBackground(false);
245  ui->currentAssetData->setFrameStyle(QFrame::NoFrame);
246 
247  // Set style for update asset data
248  ui->updatedAssetData->viewport()->setAutoFillBackground(false);
249  ui->updatedAssetData->setFrameStyle(QFrame::NoFrame);
250 
252 
253  // Hide the reissue Warning Label
254  ui->reissueWarningLabel->hide();
255 
256  disableAll();
257 }
258 
260 {
262  ui->frameCoinControl->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px; border: none;}").arg(platformStyle->WidgetBackGroundColor().name()));
263  ui->widgetCoinControl->setStyleSheet(".QWidget {background-color: transparent;}");
266  ui->frameCoinControl->setGraphicsEffect(GUIUtil::getShadowEffect());
267 
268  ui->labelCoinControlFeatures->setStyleSheet(STRING_LABEL_COLOR);
269  ui->labelCoinControlFeatures->setFont(GUIUtil::getTopLabelFont());
270 
271  ui->labelCoinControlQuantityText->setStyleSheet(STRING_LABEL_COLOR);
272  ui->labelCoinControlQuantityText->setFont(GUIUtil::getSubLabelFont());
273 
274  ui->labelCoinControlAmountText->setStyleSheet(STRING_LABEL_COLOR);
275  ui->labelCoinControlAmountText->setFont(GUIUtil::getSubLabelFont());
276 
277  ui->labelCoinControlFeeText->setStyleSheet(STRING_LABEL_COLOR);
278  ui->labelCoinControlFeeText->setFont(GUIUtil::getSubLabelFont());
279 
280  ui->labelCoinControlAfterFeeText->setStyleSheet(STRING_LABEL_COLOR);
281  ui->labelCoinControlAfterFeeText->setFont(GUIUtil::getSubLabelFont());
282 
283  ui->labelCoinControlBytesText->setStyleSheet(STRING_LABEL_COLOR);
284  ui->labelCoinControlBytesText->setFont(GUIUtil::getSubLabelFont());
285 
286  ui->labelCoinControlLowOutputText->setStyleSheet(STRING_LABEL_COLOR);
287  ui->labelCoinControlLowOutputText->setFont(GUIUtil::getSubLabelFont());
288 
289  ui->labelCoinControlChangeText->setStyleSheet(STRING_LABEL_COLOR);
290  ui->labelCoinControlChangeText->setFont(GUIUtil::getSubLabelFont());
291 
292  // Align the other labels next to the input buttons to the text in the same height
293  ui->labelCoinControlAutomaticallySelected->setStyleSheet(STRING_LABEL_COLOR);
294 
295  // Align the Custom change address checkbox
296  ui->checkBoxCoinControlChange->setStyleSheet(QString(".QCheckBox{ %1; }").arg(STRING_LABEL_COLOR));
297 
298  ui->labelCoinControlQuantity->setFont(GUIUtil::getSubLabelFont());
299  ui->labelCoinControlAmount->setFont(GUIUtil::getSubLabelFont());
300  ui->labelCoinControlFee->setFont(GUIUtil::getSubLabelFont());
301  ui->labelCoinControlAfterFee->setFont(GUIUtil::getSubLabelFont());
302  ui->labelCoinControlBytes->setFont(GUIUtil::getSubLabelFont());
303  ui->labelCoinControlLowOutput->setFont(GUIUtil::getSubLabelFont());
304  ui->labelCoinControlChange->setFont(GUIUtil::getSubLabelFont());
305  ui->checkBoxCoinControlChange->setFont(GUIUtil::getSubLabelFont());
306  ui->lineEditCoinControlChange->setFont(GUIUtil::getSubLabelFont());
307  ui->labelCoinControlInsuffFunds->setFont(GUIUtil::getSubLabelFont());
308  ui->labelCoinControlAutomaticallySelected->setFont(GUIUtil::getSubLabelFont());
309 
310 }
311 
313 {
315  ui->frame->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px; border: none;}").arg(platformStyle->WidgetBackGroundColor().name()));
316  ui->frame->setGraphicsEffect(GUIUtil::getShadowEffect());
317 
318  ui->assetNameLabel->setStyleSheet(STRING_LABEL_COLOR);
319  ui->assetNameLabel->setFont(GUIUtil::getSubLabelFont());
320 
321  ui->addressLabel->setStyleSheet(STRING_LABEL_COLOR);
322  ui->addressLabel->setFont(GUIUtil::getSubLabelFont());
323 
324  ui->quantityLabel->setStyleSheet(STRING_LABEL_COLOR);
325  ui->quantityLabel->setFont(GUIUtil::getSubLabelFont());
326 
327  ui->unitLabel->setStyleSheet(STRING_LABEL_COLOR);
328  ui->unitLabel->setFont(GUIUtil::getSubLabelFont());
329 
330  ui->reissuableBox->setStyleSheet(QString(".QCheckBox{ %1; }").arg(STRING_LABEL_COLOR));
331 
332  ui->ipfsBox->setStyleSheet(QString(".QCheckBox{ %1; }").arg(STRING_LABEL_COLOR));
333 
334  ui->frame_3->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px; border: none;}").arg(platformStyle->WidgetBackGroundColor().name()));
335  ui->frame_3->setGraphicsEffect(GUIUtil::getShadowEffect());
336 
337  ui->frame_2->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px; border: none;}").arg(platformStyle->WidgetBackGroundColor().name()));
338  ui->frame_2->setGraphicsEffect(GUIUtil::getShadowEffect());
339 
340  ui->currentDataLabel->setStyleSheet(STRING_LABEL_COLOR);
341  ui->currentDataLabel->setFont(GUIUtil::getTopLabelFont());
342 
343  ui->reissueAssetDataLabel->setStyleSheet(STRING_LABEL_COLOR);
344  ui->reissueAssetDataLabel->setFont(GUIUtil::getTopLabelFont());
345 
346 }
347 
349 {
351  ui->frameFee->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px; border: none;}").arg(platformStyle->WidgetBackGroundColor().name()));
354  ui->frameFee->setGraphicsEffect(GUIUtil::getShadowEffect());
355 
356  ui->labelFeeHeadline->setStyleSheet(STRING_LABEL_COLOR);
357  ui->labelFeeHeadline->setFont(GUIUtil::getSubLabelFont());
358 
359  ui->labelSmartFee3->setStyleSheet(STRING_LABEL_COLOR);
360  ui->labelCustomPerKilobyte->setStyleSheet(QString(".QLabel{ %1; }").arg(STRING_LABEL_COLOR));
361  ui->radioSmartFee->setStyleSheet(STRING_LABEL_COLOR);
362  ui->radioCustomFee->setStyleSheet(STRING_LABEL_COLOR);
363  ui->checkBoxMinimumFee->setStyleSheet(QString(".QCheckBox{ %1; }").arg(STRING_LABEL_COLOR));
364 
365  ui->buttonChooseFee->setFont(GUIUtil::getSubLabelFont());
366  ui->fallbackFeeWarningLabel->setFont(GUIUtil::getSubLabelFont());
367  ui->buttonMinimizeFee->setFont(GUIUtil::getSubLabelFont());
368  ui->radioSmartFee->setFont(GUIUtil::getSubLabelFont());
369  ui->labelSmartFee2->setFont(GUIUtil::getSubLabelFont());
370  ui->labelSmartFee3->setFont(GUIUtil::getSubLabelFont());
371  ui->confTargetSelector->setFont(GUIUtil::getSubLabelFont());
372  ui->radioCustomFee->setFont(GUIUtil::getSubLabelFont());
373  ui->labelCustomPerKilobyte->setFont(GUIUtil::getSubLabelFont());
374  ui->customFee->setFont(GUIUtil::getSubLabelFont());
375  ui->labelMinFeeWarning->setFont(GUIUtil::getSubLabelFont());
376  ui->optInRBF->setFont(GUIUtil::getSubLabelFont());
377  ui->reissueAssetButton->setFont(GUIUtil::getSubLabelFont());
378  ui->clearButton->setFont(GUIUtil::getSubLabelFont());
379  ui->labelSmartFee->setFont(GUIUtil::getSubLabelFont());
380  ui->labelFeeEstimation->setFont(GUIUtil::getSubLabelFont());
381  ui->labelFeeMinimized->setFont(GUIUtil::getSubLabelFont());
382 
383 }
384 
385 void ReissueAssetDialog::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
386  const CAmount& watchBalance, const CAmount& watchUnconfirmedBalance, const CAmount& watchImmatureBalance)
387 {
388  Q_UNUSED(unconfirmedBalance);
389  Q_UNUSED(immatureBalance);
390  Q_UNUSED(watchBalance);
391  Q_UNUSED(watchUnconfirmedBalance);
392  Q_UNUSED(watchImmatureBalance);
393 
394  ui->labelBalance->setFont(GUIUtil::getSubLabelFont());
395  ui->label->setFont(GUIUtil::getSubLabelFont());
396 
397  if(model && model->getOptionsModel())
398  {
399  ui->labelBalance->setText(RavenUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance));
400  }
401 }
402 
404 {
405  setBalance(model->getBalance(), 0, 0, 0, 0, 0);
406  ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
409 }
410 
412 {
413  if (ui->ipfsBox->isChecked()) {
414  ui->ipfsText->setDisabled(false);
415  } else {
416  ui->ipfsText->setDisabled(true);
417  }
418 
420  CheckFormState();
421 }
422 
424 {
425  ui->messageLabel->setStyleSheet("color: red");
426  ui->messageLabel->setText(string);
427  ui->messageLabel->show();
428 }
429 
431 {
432  ui->messageLabel->setStyleSheet("color: green");
433  ui->messageLabel->setText(string);
434  ui->messageLabel->show();
435 }
436 
438 {
439  ui->messageLabel->hide();
440 }
441 
443 {
444  ui->reissueAssetButton->setDisabled(true);
445 }
446 
448 {
449  ui->reissueAssetButton->setDisabled(false);
450 }
451 
453 {
454  disableReissueButton(); // Disable the button by default
455 
456  // If asset is null
457  if (asset->strName == "") {
458  showMessage(tr("Asset data couldn't be found"));
459  return;
460  }
461 
462  // If the quantity is to large
463  if (asset->nAmount + ui->quantitySpinBox->value() * COIN > MAX_MONEY) {
464  showMessage(tr("Quantity is to large. Max is 21,000,000,000"));
465  return;
466  }
467 
468  // Check the destination address
469  const CTxDestination dest = DecodeDestination(ui->addressText->text().toStdString());
470  if (!ui->addressText->text().isEmpty()) {
471  if (!IsValidDestination(dest)) {
472  showMessage(tr("Invalid Raven Destination Address"));
473  return;
474  }
475  }
476 
477  if (ui->ipfsBox->isChecked())
478  if (!checkIPFSHash(ui->ipfsText->text()))
479  return;
480 
481  // Keep the button disabled if no changes have been made
482  if ((!ui->ipfsBox->isChecked() || (ui->ipfsBox->isChecked() && ui->ipfsText->text().isEmpty())) && ui->reissuableBox->isChecked() && ui->quantitySpinBox->value() == 0 && ui->unitSpinBox->value() == asset->units) {
483  hideMessage();
484  return;
485  }
486 
488  hideMessage();
489 }
490 
492 {
493  ui->quantitySpinBox->setDisabled(true);
494  ui->addressText->setDisabled(true);
495  ui->reissuableBox->setDisabled(true);
496  ui->ipfsBox->setDisabled(true);
497  ui->reissueAssetButton->setDisabled(true);
498  ui->unitSpinBox->setDisabled(true);
499 
500  asset->SetNull();
501 }
502 
504 {
505  ui->quantitySpinBox->setDisabled(false);
506  ui->addressText->setDisabled(false);
507  ui->reissuableBox->setDisabled(false);
508  ui->ipfsBox->setDisabled(false);
509  ui->unitSpinBox->setDisabled(false);
510 }
511 
513 {
514  // Get the display value for the asset quantity
515  auto value = ValueFromAmount(asset->nAmount, asset->units);
516 
517  double newValue = value.get_real() + ui->quantitySpinBox->value();
518 
519  std::stringstream ss;
520  ss.precision(asset->units);
521  ss << std::fixed << newValue;
522 
523  QString reissuable = ui->reissuableBox->isChecked() ? tr("Yes") : tr("No");
524  QString name = formatBlack.arg(tr("Name"), ":", QString::fromStdString(asset->strName)) + "\n";
525 
526  QString quantity;
527  if (ui->quantitySpinBox->value() > 0)
528  quantity = formatGreen.arg(tr("Total Quantity"), ":", QString::fromStdString(ss.str())) + "\n";
529  else
530  quantity = formatBlack.arg(tr("Total Quantity"), ":", QString::fromStdString(ss.str())) + "\n";
531 
532  QString units;
533  if (ui->unitSpinBox->value() != asset->units)
534  units = formatGreen.arg(tr("Units"), ":", QString::number(ui->unitSpinBox->value())) + "\n";
535  else
536  units = formatBlack.arg(tr("Units"), ":", QString::number(ui->unitSpinBox->value())) + "\n";
537 
538  QString reissue;
539  if (ui->reissuableBox->isChecked())
540  reissue = formatBlack.arg(tr("Can Reisssue"), ":", reissuable) + "\n";
541  else
542  reissue = formatGreen.arg(tr("Can Reisssue"), ":", reissuable) + "\n";
543 
544  QString ipfs;
545 
546  if (asset->nHasIPFS && (!ui->ipfsBox->isChecked() || (ui->ipfsBox->isChecked() && ui->ipfsText->text().isEmpty()))) {
547  QString qstr = QString::fromStdString(EncodeAssetData(asset->strIPFSHash));
548  if (qstr.size() == 46) {
549  ipfs = formatBlack.arg(tr("IPFS Hash"), ":", qstr) + "\n";
550  } else if (qstr.size() == 64) {
551  ipfs = formatBlack.arg(tr("Txid Hash"), ":", qstr) + "\n";
552  }
553  } else if (ui->ipfsBox->isChecked() && !ui->ipfsText->text().isEmpty()) {
554  QString qstr = ui->ipfsText->text();
555  if (qstr.size() == 46) {
556  ipfs = formatGreen.arg(tr("IPFS Hash"), ":", qstr) + "\n";
557  } else if (qstr.size() == 64) {
558  ipfs = formatGreen.arg(tr("Txid Hash"), ":", qstr) + "\n";
559  }
560  }
561 
562  ui->updatedAssetData->clear();
563  ui->updatedAssetData->append(name);
564  ui->updatedAssetData->append(quantity);
565  ui->updatedAssetData->append(units);
566  ui->updatedAssetData->append(reissue);
567  ui->updatedAssetData->append(ipfs);
568  ui->updatedAssetData->show();
569  ui->updatedAssetData->setFixedHeight(ui->updatedAssetData->document()->size().height());
570 }
571 
573 {
574  ui->currentAssetData->clear();
575  ui->updatedAssetData->clear();
576  ui->currentAssetData->setText(tr("Please select a asset from the menu to display the assets current settings"));
577  ui->updatedAssetData->setText(tr("Please select a asset from the menu to display the assets updated settings"));
578 }
579 
582 {
583  // Only display asset information when as asset is clicked. The first index is a PlaceHolder
584  if (index > 0) {
585  enableDataEntry();
586  ui->currentAssetData->show();
587  QString qstr_name = ui->comboBox->currentText();
588 
589  LOCK(cs_main);
590  auto currentActiveAssetCache = GetCurrentAssetCache();
591  // Get the asset data
592  if (!currentActiveAssetCache->GetAssetMetaDataIfExists(qstr_name.toStdString(), *asset)) {
593  CheckFormState();
594  disableAll();
595  asset->SetNull();
596  ui->currentAssetData->hide();
597  ui->currentAssetData->clear();
598  return;
599  }
600 
601  // Get the display value for the asset quantity
602  auto value = ValueFromAmount(asset->nAmount, asset->units);
603  std::stringstream ss;
604  ss.precision(asset->units);
605  ss << std::fixed << value.get_real();
606 
607  ui->unitSpinBox->setValue(asset->units);
608  ui->unitSpinBox->setMinimum(asset->units);
609 
610  ui->quantitySpinBox->setMaximum(21000000000 - value.get_real());
611 
612  ui->currentAssetData->clear();
613  // Create the QString to display to the user
614  QString name = formatBlack.arg(tr("Name"), ":", QString::fromStdString(asset->strName)) + "\n";
615  QString quantity = formatBlack.arg(tr("Current Quantity"), ":", QString::fromStdString(ss.str())) + "\n";
616  QString units = formatBlack.arg(tr("Current Units"), ":", QString::number(ui->unitSpinBox->value()));
617  QString reissue = formatBlack.arg(tr("Can Reissue"), ":", tr("Yes")) + "\n";
618  QString assetdatahash = "";
619  if (asset->nHasIPFS) {
620  QString qstr = QString::fromStdString(EncodeAssetData(asset->strIPFSHash));
621  if (qstr.size() == 46) {
622  assetdatahash = formatBlack.arg(tr("IPFS Hash"), ":", qstr) + "\n";
623  } else if (qstr.size() == 64) {
624  assetdatahash = formatBlack.arg(tr("Txid Hash"), ":", qstr) + "\n";
625  }
626  else {
627  assetdatahash = formatBlack.arg(tr("Unknown data hash type"), ":", qstr) + "\n";
628  }
629  }
630 
631  ui->currentAssetData->append(name);
632  ui->currentAssetData->append(quantity);
633  ui->currentAssetData->append(units);
634  ui->currentAssetData->append(reissue);
635  ui->currentAssetData->append(assetdatahash);
636  ui->currentAssetData->setFixedHeight(ui->currentAssetData->document()->size().height());
637 
639 
640  CheckFormState();
641  } else {
642  disableAll();
643  asset->SetNull();
645  }
646 }
647 
649 {
651  CheckFormState();
652 }
653 
655 {
656  toggleIPFSText();
657 }
658 
660 {
661  if (!hash.isEmpty()) {
662  if (!AreMessagingDeployed()) {
663  if (hash.length() > 46) {
664  showMessage(tr("Only IPFS Hashes allowed until RIP5 is activated"));
666  return false;
667  }
668  }
669 
670  std::string error;
671  if (!CheckEncoded(DecodeAssetData(hash.toStdString()), error)) {
672  ui->ipfsText->setStyleSheet(STYLE_INVALID);
673  showMessage(tr("IPFS/Txid Hash must start with 'Qm' and be 46 characters or Txid Hash must have 64 hex characters"));
675  return false;
676  } else if (hash.size() != 46 && hash.size() != 64) {
677  ui->ipfsText->setStyleSheet(STYLE_INVALID);
678  showMessage(tr("IPFS/Txid Hash must have size of 46 characters, or 64 hex characters"));
680  return false;
681  } else if (DecodeAssetData(ui->ipfsText->text().toStdString()).empty()) {
682  ui->ipfsText->setStyleSheet(STYLE_INVALID);
683  showMessage(tr("IPFS/Txid hash is not valid. Please use a valid IPFS/Txid hash"));
685  return false;
686  }
687  }
688 
689  // No problems where found with the hash, reset the border, and hide the messages.
690  hideMessage();
691  ui->ipfsText->setStyleSheet("");
692 
693  return true;
694 }
695 
697 {
698 
699  if (checkIPFSHash(hash))
700  CheckFormState();
701 
703 }
704 
706 {
707  const CTxDestination dest = DecodeDestination(address.toStdString());
708 
709  if (address.isEmpty()) // Nothing entered
710  {
711  hideMessage();
712  ui->addressText->setStyleSheet("");
713  CheckFormState();
714  }
715  else if (!IsValidDestination(dest)) // Invalid address
716  {
717  ui->addressText->setStyleSheet("border: 1px solid red");
718  CheckFormState();
719  }
720  else // Valid address
721  {
722  hideMessage();
723  ui->addressText->setStyleSheet("");
724  CheckFormState();
725  }
726 }
727 
729 {
730  if (!model || !asset) {
731  return;
732  }
733 
735  if(!ctx.isValid())
736  {
737  // Unlock wallet was cancelled
738  return;
739  }
740 
741  QString address;
742  if (ui->addressText->text().isEmpty()) {
744  } else {
745  address = ui->addressText->text();
746  }
747 
748  QString name = ui->comboBox->currentText();
749  CAmount quantity = ui->quantitySpinBox->value() * COIN;
750  bool reissuable = ui->reissuableBox->isChecked();
751  bool hasIPFS = ui->ipfsBox->isChecked() && !ui->ipfsText->text().isEmpty();
752 
753  int unit = ui->unitSpinBox->value();
754  if (unit == asset->units)
755  unit = -1;
756 
757  // Always use a CCoinControl instance, use the CoinControlDialog instance if CoinControl has been enabled
758  CCoinControl ctrl;
761 
763 
764  std::string ipfsDecoded = "";
765  if (hasIPFS)
766  ipfsDecoded = DecodeAssetData(ui->ipfsText->text().toStdString());
767 
768  CReissueAsset reissueAsset(name.toStdString(), quantity, unit, reissuable ? 1 : 0, ipfsDecoded);
769 
770  CWalletTx tx;
771  CReserveKey reservekey(model->getWallet());
772  std::pair<int, std::string> error;
773  CAmount nFeeRequired;
774 
775  // Create the transaction
776  if (!CreateReissueAssetTransaction(model->getWallet(), ctrl, reissueAsset, address.toStdString(), error, tx, reservekey, nFeeRequired)) {
777  showMessage("Invalid: " + QString::fromStdString(error.second));
778  return;
779  }
780 
781  std::string strError = "";
782  if (!ContextualCheckReissueAsset(passets, reissueAsset, strError, *tx.tx.get())) {
783  showMessage("Invalid: " + QString::fromStdString(strError));
784  return;
785  }
786 
787  // Format confirmation message
788  QStringList formatted;
789 
790  // generate bold amount string
791  QString amount = "<b>" + QString::fromStdString(ValueFromAmountString(GetReissueAssetBurnAmount(), 8)) + " RVN";
792  amount.append("</b>");
793  // generate monospace address string
794  QString addressburn = "<span style='font-family: monospace;'>" + QString::fromStdString(Params().ReissueAssetBurnAddress());
795  addressburn.append("</span>");
796 
797  QString recipientElement1;
798  recipientElement1 = tr("%1 to %2").arg(amount, addressburn);
799  formatted.append(recipientElement1);
800 
801  // generate the bold asset amount
802  QString assetAmount = "<b>" + QString::fromStdString(ValueFromAmountString(reissueAsset.nAmount, 8)) + " " + QString::fromStdString(reissueAsset.strName);
803  assetAmount.append("</b>");
804 
805  // generate the monospace address string
806  QString assetAddress = "<span style='font-family: monospace;'>" + address;
807  assetAddress.append("</span>");
808 
809  QString recipientElement2;
810  recipientElement2 = tr("%1 to %2").arg(assetAmount, assetAddress);
811  formatted.append(recipientElement2);
812 
813  QString questionString = tr("Are you sure you want to send?");
814  questionString.append("<br /><br />%1");
815 
816  if(nFeeRequired > 0)
817  {
818  // append fee string if a fee is required
819  questionString.append("<hr /><span style='color:#aa0000;'>");
820  questionString.append(RavenUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), nFeeRequired));
821  questionString.append("</span> ");
822  questionString.append(tr("added as transaction fee"));
823 
824  // append transaction size
825  questionString.append(" (" + QString::number((double)GetVirtualTransactionSize(tx) / 1000) + " kB)");
826  }
827 
828  // add total amount in all subdivision units
829  questionString.append("<hr />");
830  CAmount totalAmount = GetReissueAssetBurnAmount() + nFeeRequired;
831  QStringList alternativeUnits;
833  {
834  if(u != model->getOptionsModel()->getDisplayUnit())
835  alternativeUnits.append(RavenUnits::formatHtmlWithUnit(u, totalAmount));
836  }
837  questionString.append(tr("Total Amount %1")
839  questionString.append(QString("<span style='font-size:10pt;font-weight:normal;'><br />(=%2)</span>")
840  .arg(alternativeUnits.join(" " + tr("or") + "<br />")));
841 
842  SendConfirmationDialog confirmationDialog(tr("Confirm reissue assets"),
843  questionString.arg(formatted.join("<br />")), SEND_CONFIRM_DELAY, this);
844  confirmationDialog.exec();
845  QMessageBox::StandardButton retval = (QMessageBox::StandardButton)confirmationDialog.result();
846 
847  if(retval != QMessageBox::Yes)
848  {
849  return;
850  }
851 
852  // Create the transaction and broadcast it
853  std::string txid;
854  if (!SendAssetTransaction(model->getWallet(), tx, reservekey, error, txid)) {
855  showMessage("Invalid: " + QString::fromStdString(error.second));
856  } else {
857  QMessageBox msgBox;
858  QPushButton *copyButton = msgBox.addButton(tr("Copy"), QMessageBox::ActionRole);
859  copyButton->disconnect();
860  connect(copyButton, &QPushButton::clicked, this, [=](){
861  QClipboard *p_Clipboard = QApplication::clipboard();
862  p_Clipboard->setText(QString::fromStdString(txid), QClipboard::Mode::Clipboard);
863 
864  QMessageBox copiedBox;
865  copiedBox.setText(tr("Transaction ID Copied"));
866  copiedBox.exec();
867  });
868 
869  QPushButton *okayButton = msgBox.addButton(QMessageBox::Ok);
870  msgBox.setText(tr("Asset transaction sent to network:"));
871  msgBox.setInformativeText(QString::fromStdString(txid));
872  msgBox.exec();
873 
874  if (msgBox.clickedButton() == okayButton) {
875  clear();
876 
879  }
880  }
881 }
882 
884 {
885  if (!ui->reissuableBox->isChecked()) {
886  ui->reissueWarningLabel->setText("Warning: Once this asset is reissued with the reissuable flag set to false. It won't be able to be reissued in the future");
887  ui->reissueWarningLabel->setStyleSheet("color: red");
888  ui->reissueWarningLabel->show();
889  } else {
890  ui->reissueWarningLabel->hide();
891  }
892 
894 
895  CheckFormState();
896 }
897 
899 {
900  if (ui->radioCustomFee->isChecked()) {
901  ctrl.m_feerate = CFeeRate(ui->customFee->value());
902  } else {
903  ctrl.m_feerate.reset();
904  }
905  // Avoid using global defaults when sending money from the GUI
906  // Either custom fee will be used or if not selected, the confirmation target from dropdown box
907  ctrl.m_confirm_target = getConfTargetForIndex(ui->confTargetSelector->currentIndex());
908 // ctrl.signalRbf = ui->optInRBF->isChecked();
909 }
910 
912 {
913  if(!model || !model->getOptionsModel())
914  return;
915  CCoinControl coin_control;
916  updateCoinControlState(coin_control);
917  coin_control.m_feerate.reset(); // Explicitly use only fee estimation rate for smart fee labels
918  FeeCalculation feeCalc;
919  CFeeRate feeRate = CFeeRate(GetMinimumFee(1000, coin_control, ::mempool, ::feeEstimator, &feeCalc));
920 
921  ui->labelSmartFee->setText(RavenUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB");
922 
923  if (feeCalc.reason == FeeReason::FALLBACK) {
924  ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)
925  ui->labelFeeEstimation->setText("");
926  ui->fallbackFeeWarningLabel->setVisible(true);
927  int lightness = ui->fallbackFeeWarningLabel->palette().color(QPalette::WindowText).lightness();
928  QColor warning_colour(255 - (lightness / 5), 176 - (lightness / 3), 48 - (lightness / 14));
929  ui->fallbackFeeWarningLabel->setStyleSheet("QLabel { color: " + warning_colour.name() + "; }");
930  ui->fallbackFeeWarningLabel->setIndent(QFontMetrics(ui->fallbackFeeWarningLabel->font()).width("x"));
931  }
932  else
933  {
934  ui->labelSmartFee2->hide();
935  ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", feeCalc.returnedTarget));
936  ui->fallbackFeeWarningLabel->setVisible(false);
937  }
938 
940 }
941 
942 // Coin Control: copy label "Quantity" to clipboard
944 {
945  GUIUtil::setClipboard(ui->labelCoinControlQuantity->text());
946 }
947 
948 // Coin Control: copy label "Amount" to clipboard
950 {
951  GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
952 }
953 
954 // Coin Control: copy label "Fee" to clipboard
956 {
957  GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")).replace(ASYMP_UTF8, ""));
958 }
959 
960 // Coin Control: copy label "After fee" to clipboard
962 {
963  GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")).replace(ASYMP_UTF8, ""));
964 }
965 
966 // Coin Control: copy label "Bytes" to clipboard
968 {
969  GUIUtil::setClipboard(ui->labelCoinControlBytes->text().replace(ASYMP_UTF8, ""));
970 }
971 
972 // Coin Control: copy label "Dust" to clipboard
974 {
975  GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text());
976 }
977 
978 // Coin Control: copy label "Change" to clipboard
980 {
981  GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")).replace(ASYMP_UTF8, ""));
982 }
983 
984 // Coin Control: settings menu - coin control enabled/disabled by user
986 {
987  ui->frameCoinControl->setVisible(checked);
988  ui->addressText->setVisible(checked);
989  ui->addressLabel->setVisible(checked);
990 
991  if (!checked && model) // coin control features disabled
993 
995 }
996 
997 // Coin Control: settings menu - coin control enabled/disabled by user
999 {
1000  ui->frameFee->setVisible(checked);
1001 }
1002 
1003 // Coin Control: button inputs -> show actual coin control dialog
1005 {
1007  dlg.setModel(model);
1008  dlg.exec();
1010 }
1011 
1012 // Coin Control: checkbox custom change address
1014 {
1015  if (state == Qt::Unchecked)
1016  {
1018  ui->labelCoinControlChangeLabel->clear();
1019  }
1020  else
1021  // use this to re-validate an already entered address
1022  coinControlChangeEdited(ui->lineEditCoinControlChange->text());
1023 
1024  ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));
1025 }
1026 
1027 // Coin Control: custom change address changed
1029 {
1030  if (model && model->getAddressTableModel())
1031  {
1032  // Default to no change address until verified
1034  ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
1035 
1036  const CTxDestination dest = DecodeDestination(text.toStdString());
1037 
1038  if (text.isEmpty()) // Nothing entered
1039  {
1040  ui->labelCoinControlChangeLabel->setText("");
1041  }
1042  else if (!IsValidDestination(dest)) // Invalid address
1043  {
1044  ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Raven address"));
1045  }
1046  else // Valid address
1047  {
1048  if (!model->IsSpendable(dest)) {
1049  ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
1050 
1051  // confirmation dialog
1052  QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm custom change address"), tr("The address you selected for change is not part of this wallet. Any or all funds in your wallet may be sent to this address. Are you sure?"),
1053  QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
1054 
1055  if(btnRetVal == QMessageBox::Yes)
1057  else
1058  {
1059  ui->lineEditCoinControlChange->setText("");
1060  ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
1061  ui->labelCoinControlChangeLabel->setText("");
1062  }
1063  }
1064  else // Known change address
1065  {
1066  ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
1067 
1068  // Query label
1069  QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);
1070  if (!associatedLabel.isEmpty())
1071  ui->labelCoinControlChangeLabel->setText(associatedLabel);
1072  else
1073  ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
1074 
1076  }
1077  }
1078  }
1079 }
1080 
1081 // Coin Control: update labels
1083 {
1084  if (!model || !model->getOptionsModel())
1085  return;
1086 
1088 
1089  // set pay amounts
1092 
1094 
1095  if (CoinControlDialog::coinControl->HasSelected())
1096  {
1097  // actual coin control calculation
1099 
1100  // show coin control stats
1101  ui->labelCoinControlAutomaticallySelected->hide();
1102  ui->widgetCoinControl->show();
1103  }
1104  else
1105  {
1106  // hide coin control stats
1107  ui->labelCoinControlAutomaticallySelected->show();
1108  ui->widgetCoinControl->hide();
1109  ui->labelCoinControlInsuffFunds->hide();
1110  }
1111 }
1112 
1114 {
1115  ui->labelFeeMinimized->setVisible(fMinimize);
1116  ui->buttonChooseFee ->setVisible(fMinimize);
1117  ui->buttonMinimizeFee->setVisible(!fMinimize);
1118  ui->frameFeeSelection->setVisible(!fMinimize);
1119  ui->horizontalLayoutSmartFee->setContentsMargins(0, (fMinimize ? 0 : 6), 0, 0);
1120  fFeeMinimized = fMinimize;
1121 }
1122 
1124 {
1125  minimizeFeeSection(false);
1126 }
1127 
1129 {
1131  minimizeFeeSection(true);
1132 }
1133 
1135 {
1136  ui->customFee->setValue(GetRequiredFee(1000));
1137 }
1138 
1140 {
1141  ui->confTargetSelector ->setEnabled(ui->radioSmartFee->isChecked());
1142  ui->labelSmartFee ->setEnabled(ui->radioSmartFee->isChecked());
1143  ui->labelSmartFee2 ->setEnabled(ui->radioSmartFee->isChecked());
1144  ui->labelSmartFee3 ->setEnabled(ui->radioSmartFee->isChecked());
1145  ui->labelFeeEstimation ->setEnabled(ui->radioSmartFee->isChecked());
1146  ui->checkBoxMinimumFee ->setEnabled(ui->radioCustomFee->isChecked());
1147  ui->labelMinFeeWarning ->setEnabled(ui->radioCustomFee->isChecked());
1148  ui->labelCustomPerKilobyte ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked());
1149  ui->customFee ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked());
1150 }
1151 
1153 {
1154  if(!model || !model->getOptionsModel())
1155  return;
1156 
1157  if (ui->radioSmartFee->isChecked())
1158  ui->labelFeeMinimized->setText(ui->labelSmartFee->text());
1159  else {
1160  ui->labelFeeMinimized->setText(RavenUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), ui->customFee->value()) + "/kB");
1161  }
1162 }
1163 
1165 {
1166  if (model && model->getOptionsModel())
1167  ui->checkBoxMinimumFee->setText(tr("Pay only the required fee of %1").arg(
1169  );
1170 }
1171 
1173 {
1174  QString text;
1175  text += "e.g. 1";
1176  // Add the period
1177  if (value > 0)
1178  text += ".";
1179 
1180  // Add the remaining zeros
1181  for (int i = 0; i < value; i++) {
1182  text += "0";
1183  }
1184 
1185  ui->unitExampleLabel->setText(text);
1186 
1187  buildUpdatedData();
1188  CheckFormState();
1189 
1190 }
1191 
1193 {
1194  LOCK(cs_main);
1195  std::vector<std::string> assets;
1197 
1198  QStringList list;
1199  list << "";
1200 
1201  // Load the assets that are reissuable
1202  for (auto item : assets) {
1203  std::string name = QString::fromStdString(item).split("!").first().toStdString();
1204  CNewAsset asset;
1205  if (passets->GetAssetMetaDataIfExists(name, asset)) {
1206  if (asset.nReissuable)
1207  list << QString::fromStdString(asset.strName);
1208  }
1209  }
1210 
1211  stringModel->setStringList(list);
1212 }
1213 
1215 {
1216  ui->comboBox->setCurrentIndex(0);
1217  ui->addressText->clear();
1218  ui->quantitySpinBox->setValue(0);
1219  ui->unitSpinBox->setMinimum(0);
1220  ui->unitSpinBox->setValue(0);
1221  onUnitChanged(0);
1222  ui->reissuableBox->setChecked(true);
1223  ui->ipfsBox->setChecked(false);
1224  ui->ipfsText->setDisabled(true);
1225  ui->ipfsText->clear();
1226  hideMessage();
1227 
1228  disableAll();
1229  asset->SetNull();
1231 
1232  updateAssetsList();
1233 }
1234 
1236 {
1237  clear();
1238 }
1239 
1240 void ReissueAssetDialog::focusReissueAsset(const QModelIndex &index)
1241 {
1242  clear();
1243 
1244  QString name = index.data(AssetTableModel::AssetNameRole).toString();
1245  if (IsAssetNameAnOwner(name.toStdString()))
1246  name = name.left(name.size() - 1);
1247 
1248  ui->comboBox->setCurrentIndex(ui->comboBox->findText(name));
1249  onAssetSelected(ui->comboBox->currentIndex());
1250 
1251  ui->quantitySpinBox->setFocus();
1252 }
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost)
Compute the virtual transaction size (weight reinterpreted as bytes).
Definition: policy.cpp:266
CTxMemPool mempool
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:89
CAmount GetBurnAmount(const int nType)
Definition: assets.cpp:3574
int returnedTarget
Definition: fees.h:131
int8_t units
Definition: assettypes.h:102
QGraphicsDropShadowEffect * getShadowEffect()
Definition: guiutil.cpp:146
void showMessage(QString string)
bool ContextualCheckReissueAsset(CAssetsCache *assetCache, const CReissueAsset &reissue_asset, std::string &strError, const CTransaction &tx)
Definition: assets.cpp:5273
static CCoinControl * coinControl
void coinControlChangeEdited(const QString &)
boost::optional< unsigned int > m_confirm_target
Override the default confirmation target if set.
Definition: coincontrol.h:30
Dialog showing transaction details.
void onQuantityChanged(double qty)
UnlockContext requestUnlock()
FeeReason reason
Definition: fees.h:129
void setUpValues()
Helper Methods.
CCriticalSection cs_main
Global state.
Definition: validation.cpp:72
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
Definition: standard.cpp:402
CTxDestination DecodeDestination(const std::string &str)
Definition: base58.cpp:333
#define SEND_CONFIRM_DELAY
void feeControlFeatureChanged(bool)
std::string strName
Definition: assettypes.h:100
const PlatformStyle * platformStyle
UniValue ValueFromAmount(const CAmount &amount, const int8_t units)
Definition: core_write.cpp:38
CAmount GetRequiredFee(unsigned int nTxBytes)
Return the minimum required fee taking into account the floating relay fee and user set minimum trans...
Definition: fees.cpp:17
AddressTableModel * getAddressTableModel()
std::string strIPFSHash
Definition: assettypes.h:105
Coin Control Features.
Definition: coincontrol.h:17
int8_t nReissuable
Definition: assettypes.h:103
boost::optional< CFeeRate > m_feerate
Override the default payTxFee if set.
Definition: coincontrol.h:28
int getDisplayUnit() const
Definition: optionsmodel.h:68
CAmount getBalance(const CCoinControl *coinControl=nullptr) const
Definition: walletmodel.cpp:72
void minimizeFeeSection(bool fMinimize)
int64_t CAmount
Amount in corbies (Can be negative)
Definition: amount.h:13
int getConfTargetForIndex(int index)
Definition: fees.cpp:1056
CAmount getImmatureBalance() const
Definition: walletmodel.cpp:87
CBlockPolicyEstimator feeEstimator
Definition: validation.cpp:109
static QList< CAmount > payAmounts
void setClientModel(ClientModel *clientModel)
QFont getSubLabelFont()
Definition: guiutil.cpp:86
bool AreMessagingDeployed()
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
Definition: ravenunits.cpp:146
bool darkModeEnabled
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
Definition: guiutil.cpp:201
int8_t nHasIPFS
Definition: assettypes.h:104
std::string DecodeAssetData(std::string encoded)
Decode and Encode IPFS hashes, or OIP hashes.
Definition: assets.cpp:3699
void updateCoinControlState(CCoinControl &ctrl)
bool checkIPFSHash(QString hash)
void onIPFSHashChanged(QString hash)
bool GetAssetMetaDataIfExists(const std::string &name, CNewAsset &asset)
Returns true if an asset with the name exists, and it was able to get the asset metadata from databas...
Definition: assets.cpp:3340
CAssetsCache * GetCurrentAssetCache()
void setClipboard(const QString &str)
Definition: guiutil.cpp:945
#define STRING_LABEL_COLOR
Definition: guiconstants.h:90
void setupFeeControl(const PlatformStyle *platformStyle)
#define LOCK(cs)
Definition: sync.h:176
void SetNull()
Definition: coincontrol.h:46
CTxDestination destChange
Definition: coincontrol.h:20
int getDefaultConfirmTarget() const
ClientModel * clientModel
CAmount getWatchUnconfirmedBalance() const
QString labelForAddress(const QString &address) const
void SetNull()
Definition: assettypes.h:118
ReissueAssetDialog(const PlatformStyle *platformStyle, QWidget *parent=0)
void setupCoinControlFrame(const PlatformStyle *platformStyle)
#define STYLE_INVALID
Definition: guiconstants.h:21
std::string ValueFromAmountString(const CAmount &amount, const int8_t units)
Definition: core_write.cpp:22
static void updateLabels(WalletModel *, QDialog *)
int getIndexForConfTarget(int target)
Definition: fees.cpp:1066
CAmount GetReissueAssetBurnAmount()
Definition: assets.cpp:3534
Model for Raven network client.
Definition: clientmodel.h:39
bool SendAssetTransaction(CWallet *pwallet, CWalletTx &transaction, CReserveKey &reserveKey, std::pair< int, std::string > &error, std::string &txid)
Send any type of asset transaction to the network.
Definition: assets.cpp:4243
void UnSelectAll()
Definition: coincontrol.h:106
void setBalance(const CAmount &balance, const CAmount &unconfirmedBalance, const CAmount &immatureBalance, const CAmount &watchOnlyBalance, const CAmount &watchUnconfBalance, const CAmount &watchImmatureBalance)
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:285
void setModel(WalletModel *model)
bool getCoinControlFeatures() const
Definition: optionsmodel.h:71
void GetAllAdministrativeAssets(CWallet *pwallet, std::vector< std::string > &names, int nMinConf)
Definition: assets.cpp:3499
RVN or name of an asset.
CAssetsCache * passets
Global variable that point to the active assets (protected by cs_main)
Definition: validation.cpp:227
void setModel(WalletModel *model)
CAmount nAmount
Definition: assettypes.h:101
QString addRow(const QString &type, const QString &label, const QString &address)
static bool fSubtractFeeFromAmount
QColor WidgetBackGroundColor() const
#define ASYMP_UTF8
A key allocated from the key pool.
Definition: wallet.h:1193
const CChainParams & Params()
Return the currently selected parameters.
Interface to Raven wallet from Qt view code.
Definition: walletmodel.h:165
bool CreateReissueAssetTransaction(CWallet *pwallet, CCoinControl &coinControl, const CReissueAsset &reissueAsset, const std::string &address, std::pair< int, std::string > &error, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRequired, std::string *verifier_string)
Create a reissue asset transaction.
Definition: assets.cpp:3917
CAmount getWatchBalance() const
Definition: walletmodel.cpp:97
Ui::ReissueAssetDialog * ui
CAmount getUnconfirmedBalance() const
Definition: walletmodel.cpp:82
static QString formatHtmlWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as HTML string (with unit)
Definition: ravenunits.cpp:156
static const QString Receive
Specifies receive address.
void coinControlFeatureChanged(bool)
bool CheckEncoded(const std::string &hash, std::string &strError)
Check the Encoded hash and make sure it is either an IPFS hash or a OIP hash.
Definition: assets.cpp:4282
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:20
void focusReissueAsset(const QModelIndex &index)
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
Definition: ravenunits.cpp:18
bool error(const char *fmt, const Args &... args)
Definition: util.h:168
QFont getTopLabelFont(int weight, int pxsize)
Definition: guiutil.cpp:122
Unit
Raven units.
Definition: ravenunits.h:63
CAmount getWatchImmatureBalance() const
QString formatNiceTimeOffset(qint64 secs)
Definition: guiutil.cpp:1029
void onAddressNameChanged(QString address)
void onAssetSelected(int index)
SLOTS.
CWallet * getWallet() const
void setupAssetDataView(const PlatformStyle *platformStyle)
QSortFilterProxyModel * proxy
bool getCustomFeeFeatures() const
Definition: optionsmodel.h:72
std::string EncodeAssetData(std::string decoded)
Definition: assets.cpp:3716
CAmount GetMinimumFee(unsigned int nTxBytes, const CCoinControl &coin_control, const CTxMemPool &pool, const CBlockPolicyEstimator &estimator, FeeCalculation *feeCalc)
Estimate the minimum fee considering user set parameters and the required fee.
Definition: fees.cpp:23
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
Definition: feerate.h:42
UniValue reissue(const JSONRPCRequest &request)
Definition: assets.cpp:1465
void onUnitChanged(int value)
void showValidMessage(QString string)
OptionsModel * getOptionsModel()
QStringListModel * stringModel
bool IsSpendable(const CTxDestination &dest) const
bool IsAssetNameAnOwner(const std::string &name)
Check if an asset is an owner.
Definition: assets.cpp:296