Raven Core  3.0.0
P2P Digital Currency
createassetdialog.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 #include "createassetdialog.h"
7 #include "ui_createassetdialog.h"
8 #include "platformstyle.h"
9 #include "walletmodel.h"
10 #include "addresstablemodel.h"
11 #include "sendcoinsdialog.h"
12 #include "coincontroldialog.h"
13 #include "guiutil.h"
14 #include "ravenunits.h"
15 #include "clientmodel.h"
16 #include "optionsmodel.h"
17 #include "guiconstants.h"
18 
19 #include "wallet/coincontrol.h"
20 #include "policy/fees.h"
21 #include "wallet/fees.h"
22 
23 #include <script/standard.h>
24 #include <base58.h>
25 #include <validation.h> // mempool and minRelayTxFee
26 #include <wallet/wallet.h>
27 #include <core_io.h>
28 #include <policy/policy.h>
29 #include "assets/assettypes.h"
30 #include "assettablemodel.h"
31 
32 #include <QGraphicsDropShadowEffect>
33 #include <QModelIndex>
34 #include <QDebug>
35 #include <QMessageBox>
36 #include <QClipboard>
37 #include <QSettings>
38 #include <QStringListModel>
39 #include <QSortFilterProxyModel>
40 #include <QCompleter>
41 
42 CreateAssetDialog::CreateAssetDialog(const PlatformStyle *_platformStyle, QWidget *parent) :
43  QDialog(parent, Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint),
44  ui(new Ui::CreateAssetDialog),
45  platformStyle(_platformStyle)
46 {
47  ui->setupUi(this);
48  setWindowTitle("Create Assets");
49  connect(ui->ipfsBox, SIGNAL(clicked()), this, SLOT(ipfsStateChanged()));
50  connect(ui->availabilityButton, SIGNAL(clicked()), this, SLOT(checkAvailabilityClicked()));
51  connect(ui->nameText, SIGNAL(textChanged(QString)), this, SLOT(onNameChanged(QString)));
52  connect(ui->addressText, SIGNAL(textChanged(QString)), this, SLOT(onAddressNameChanged(QString)));
53  connect(ui->ipfsText, SIGNAL(textChanged(QString)), this, SLOT(onIPFSHashChanged(QString)));
54  connect(ui->createAssetButton, SIGNAL(clicked()), this, SLOT(onCreateAssetClicked()));
55  connect(ui->unitBox, SIGNAL(valueChanged(int)), this, SLOT(onUnitChanged(int)));
56  connect(ui->assetType, SIGNAL(activated(int)), this, SLOT(onAssetTypeActivated(int)));
57  connect(ui->assetList, SIGNAL(activated(int)), this, SLOT(onAssetListActivated(int)));
58  connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(onClearButtonClicked()));
59 
60  GUIUtil::setupAddressWidget(ui->lineEditCoinControlChange, this);
61 
62  // Coin Control
63  connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked()));
64  connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int)));
65  connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &)));
66 
67  // Coin Control: clipboard actions
68  QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this);
69  QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this);
70  QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this);
71  QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this);
72  QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this);
73  QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this);
74  QAction *clipboardChangeAction = new QAction(tr("Copy change"), this);
75  connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity()));
76  connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount()));
77  connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee()));
78  connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee()));
79  connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes()));
80  connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput()));
81  connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange()));
82  ui->labelCoinControlQuantity->addAction(clipboardQuantityAction);
83  ui->labelCoinControlAmount->addAction(clipboardAmountAction);
84  ui->labelCoinControlFee->addAction(clipboardFeeAction);
85  ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction);
86  ui->labelCoinControlBytes->addAction(clipboardBytesAction);
87  ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction);
88  ui->labelCoinControlChange->addAction(clipboardChangeAction);
89 
90  // init transaction fee section
91  QSettings settings;
92  if (!settings.contains("fFeeSectionMinimized"))
93  settings.setValue("fFeeSectionMinimized", true);
94  if (!settings.contains("nFeeRadio") && settings.contains("nTransactionFee") && settings.value("nTransactionFee").toLongLong() > 0) // compatibility
95  settings.setValue("nFeeRadio", 1); // custom
96  if (!settings.contains("nFeeRadio"))
97  settings.setValue("nFeeRadio", 0); // recommended
98  if (!settings.contains("nSmartFeeSliderPosition"))
99  settings.setValue("nSmartFeeSliderPosition", 0);
100  if (!settings.contains("nTransactionFee"))
101  settings.setValue("nTransactionFee", (qint64)DEFAULT_TRANSACTION_FEE);
102  if (!settings.contains("fPayOnlyMinFee"))
103  settings.setValue("fPayOnlyMinFee", false);
104  ui->groupFee->setId(ui->radioSmartFee, 0);
105  ui->groupFee->setId(ui->radioCustomFee, 1);
106  ui->groupFee->button((int)std::max(0, std::min(1, settings.value("nFeeRadio").toInt())))->setChecked(true);
107  ui->customFee->setValue(settings.value("nTransactionFee").toLongLong());
108  ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool());
109  minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool());
110 
111  format = "%1<font color=green>%2%3</font>";
112 
116 
118  stringModel = new QStringListModel;
119 
120  proxy = new QSortFilterProxyModel;
121  proxy->setSourceModel(stringModel);
122  proxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
123 
124  ui->assetList->setModel(proxy);
125  ui->assetList->setEditable(true);
126  ui->assetList->lineEdit()->setPlaceholderText("Select an asset");
127 
128  completer = new QCompleter(proxy,this);
129  completer->setCompletionMode(QCompleter::PopupCompletion);
130  completer->setCaseSensitivity(Qt::CaseInsensitive);
131  ui->assetList->setCompleter(completer);
132 
133  ui->nameText->installEventFilter(this);
134  ui->assetList->installEventFilter(this);
135 }
136 
138 {
139  this->clientModel = _clientModel;
140 
141  if (_clientModel) {
142  connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(updateSmartFeeLabel()));
143  }
144 }
145 
147 {
148  this->model = _model;
149 
150  if(_model && _model->getOptionsModel())
151  {
152  setBalance(_model->getBalance(), _model->getUnconfirmedBalance(), _model->getImmatureBalance(),
153  _model->getWatchBalance(), _model->getWatchUnconfirmedBalance(), _model->getWatchImmatureBalance());
154  connect(_model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)));
155  connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
157 
158  // Coin Control
159  connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels()));
160  connect(_model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool)));
161  bool fCoinControlEnabled = _model->getOptionsModel()->getCoinControlFeatures();
162  ui->frameCoinControl->setVisible(fCoinControlEnabled);
163  ui->addressText->setVisible(fCoinControlEnabled);
164  ui->addressLabel->setVisible(fCoinControlEnabled);
166 
167  // Custom Fee Control
168  ui->frameFee->setVisible(_model->getOptionsModel()->getCustomFeeFeatures());
169  connect(_model->getOptionsModel(), SIGNAL(customFeeFeaturesChanged(bool)), this, SLOT(feeControlFeatureChanged(bool)));
170 
171  // fee section
172  for (const int &n : confTargets) {
173  ui->confTargetSelector->addItem(tr("%1 (%2 blocks)").arg(GUIUtil::formatNiceTimeOffset(n*Params().GetConsensus().nPowTargetSpacing)).arg(n));
174  }
175  connect(ui->confTargetSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSmartFeeLabel()));
176  connect(ui->confTargetSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(coinControlUpdateLabels()));
177  connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(updateFeeSectionControls()));
178  connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(coinControlUpdateLabels()));
179  connect(ui->customFee, SIGNAL(valueChanged()), this, SLOT(coinControlUpdateLabels()));
180  connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(setMinimumFee()));
181  connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(updateFeeSectionControls()));
182  connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
183 // connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(updateSmartFeeLabel()));
184 // connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
185  ui->customFee->setSingleStep(GetRequiredFee(1000));
189 
190  // set default rbf checkbox state
191 // ui->optInRBF->setCheckState(model->getDefaultWalletRbf() ? Qt::Checked : Qt::Unchecked);
192  ui->optInRBF->hide();
193 
194  // set the smartfee-sliders default value (wallets default conf.target or last stored value)
195  QSettings settings;
196  if (settings.value("nSmartFeeSliderPosition").toInt() != 0) {
197  // migrate nSmartFeeSliderPosition to nConfTarget
198  // nConfTarget is available since 0.15 (replaced nSmartFeeSliderPosition)
199  int nConfirmTarget = 25 - settings.value("nSmartFeeSliderPosition").toInt(); // 25 == old slider range
200  settings.setValue("nConfTarget", nConfirmTarget);
201  settings.remove("nSmartFeeSliderPosition");
202  }
203  if (settings.value("nConfTarget").toInt() == 0)
204  ui->confTargetSelector->setCurrentIndex(getIndexForConfTarget(model->getDefaultConfirmTarget()));
205  else
206  ui->confTargetSelector->setCurrentIndex(getIndexForConfTarget(settings.value("nConfTarget").toInt()));
207 
208 
209  // Setup the default values
210  setUpValues();
211 
212  adjustSize();
213  }
214 }
215 
216 
218 {
219  delete ui;
220 }
221 
222 bool CreateAssetDialog::eventFilter(QObject *sender, QEvent *event)
223 {
224  if (sender == ui->nameText)
225  {
226  if(event->type()== QEvent::FocusIn)
227  {
228  ui->nameText->setStyleSheet("");
229  }
230  }
231  else if (sender == ui->assetList)
232  {
233  if(event->type()== QEvent::FocusIn)
234  {
235  ui->assetList->lineEdit()->setStyleSheet("");
236  }
237  }
238  return QWidget::eventFilter(sender,event);
239 }
240 
243 {
244  ui->unitBox->setValue(0);
245  ui->reissuableBox->setCheckState(Qt::CheckState::Checked);
246  ui->ipfsText->hide();
247  hideMessage();
248  CheckFormState();
249  ui->availabilityButton->setDisabled(true);
250 
251  ui->unitExampleLabel->setStyleSheet("font-weight: bold");
252 
253  // Setup the asset types
254  QStringList list;
255  list.append(tr("Main Asset") + " (" + RavenUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), GetBurnAmount(AssetType::ROOT)) + ")");
256  list.append(tr("Sub Asset") + " (" + RavenUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), GetBurnAmount(AssetType::SUB)) + ")");
257  list.append(tr("Unique Asset") + " (" + RavenUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), GetBurnAmount(AssetType::UNIQUE)) + ")");
258  ui->assetType->addItems(list);
260  ui->assetTypeLabel->setText(tr("Asset Type") + ":");
261 
262  // Setup the asset list
263  ui->assetList->hide();
264  updateAssetList();
265 
266  ui->assetFullName->setTextFormat(Qt::RichText);
267  ui->assetFullName->setStyleSheet("font-weight: bold");
268 
269  ui->assetType->setStyleSheet("font-weight: bold");
270 }
271 
273 {
275  ui->frameCoinControl->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px; border: none;}").arg(platformStyle->WidgetBackGroundColor().name()));
276  ui->widgetCoinControl->setStyleSheet(".QWidget {background-color: transparent;}");
279  ui->frameCoinControl->setGraphicsEffect(GUIUtil::getShadowEffect());
280 
281  ui->labelCoinControlFeatures->setStyleSheet(STRING_LABEL_COLOR);
282  ui->labelCoinControlFeatures->setFont(GUIUtil::getTopLabelFont());
283 
284  ui->labelCoinControlQuantityText->setStyleSheet(STRING_LABEL_COLOR);
285  ui->labelCoinControlQuantityText->setFont(GUIUtil::getSubLabelFont());
286 
287  ui->labelCoinControlAmountText->setStyleSheet(STRING_LABEL_COLOR);
288  ui->labelCoinControlAmountText->setFont(GUIUtil::getSubLabelFont());
289 
290  ui->labelCoinControlFeeText->setStyleSheet(STRING_LABEL_COLOR);
291  ui->labelCoinControlFeeText->setFont(GUIUtil::getSubLabelFont());
292 
293  ui->labelCoinControlAfterFeeText->setStyleSheet(STRING_LABEL_COLOR);
294  ui->labelCoinControlAfterFeeText->setFont(GUIUtil::getSubLabelFont());
295 
296  ui->labelCoinControlBytesText->setStyleSheet(STRING_LABEL_COLOR);
297  ui->labelCoinControlBytesText->setFont(GUIUtil::getSubLabelFont());
298 
299  ui->labelCoinControlLowOutputText->setStyleSheet(STRING_LABEL_COLOR);
300  ui->labelCoinControlLowOutputText->setFont(GUIUtil::getSubLabelFont());
301 
302  ui->labelCoinControlChangeText->setStyleSheet(STRING_LABEL_COLOR);
303  ui->labelCoinControlChangeText->setFont(GUIUtil::getSubLabelFont());
304 
305  // Align the other labels next to the input buttons to the text in the same height
306  ui->labelCoinControlAutomaticallySelected->setStyleSheet(STRING_LABEL_COLOR);
307 
308  // Align the Custom change address checkbox
309  ui->checkBoxCoinControlChange->setStyleSheet(QString(".QCheckBox{ %1; }").arg(STRING_LABEL_COLOR));
310 
311 }
312 
314 {
317  ui->frameAssetData->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px; border: none;}").arg(platformStyle->WidgetBackGroundColor().name()));
318  ui->frameAssetData->setGraphicsEffect(GUIUtil::getShadowEffect());
319 
320  ui->assetTypeLabel->setStyleSheet(STRING_LABEL_COLOR);
321  ui->assetTypeLabel->setFont(GUIUtil::getSubLabelFont());
322 
323  ui->assetNameLabel->setStyleSheet(STRING_LABEL_COLOR);
324  ui->assetNameLabel->setFont(GUIUtil::getSubLabelFont());
325 
326  ui->addressLabel->setStyleSheet(STRING_LABEL_COLOR);
327  ui->addressLabel->setFont(GUIUtil::getSubLabelFont());
328 
329  ui->quantityLabel->setStyleSheet(STRING_LABEL_COLOR);
330  ui->quantityLabel->setFont(GUIUtil::getSubLabelFont());
331 
332  ui->unitsLabel->setStyleSheet(STRING_LABEL_COLOR);
333  ui->unitsLabel->setFont(GUIUtil::getSubLabelFont());
334 
335  ui->reissuableBox->setStyleSheet(QString(".QCheckBox{ %1; }").arg(STRING_LABEL_COLOR));
336  ui->ipfsBox->setStyleSheet(QString(".QCheckBox{ %1; }").arg(STRING_LABEL_COLOR));
337 
338 }
339 
341 {
343  ui->frameFee->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px; border: none;}").arg(platformStyle->WidgetBackGroundColor().name()));
346  ui->frameFee->setGraphicsEffect(GUIUtil::getShadowEffect());
347 
348  ui->labelFeeHeadline->setStyleSheet(STRING_LABEL_COLOR);
349  ui->labelFeeHeadline->setFont(GUIUtil::getSubLabelFont());
350 
351  ui->labelSmartFee3->setStyleSheet(STRING_LABEL_COLOR);
352  ui->labelCustomPerKilobyte->setStyleSheet(QString(".QLabel{ %1; }").arg(STRING_LABEL_COLOR));
353  ui->radioSmartFee->setStyleSheet(STRING_LABEL_COLOR);
354  ui->radioCustomFee->setStyleSheet(STRING_LABEL_COLOR);
355  ui->checkBoxMinimumFee->setStyleSheet(QString(".QCheckBox{ %1; }").arg(STRING_LABEL_COLOR));
356 
357  ui->buttonChooseFee->setFont(GUIUtil::getSubLabelFont());
358  ui->fallbackFeeWarningLabel->setFont(GUIUtil::getSubLabelFont());
359  ui->buttonMinimizeFee->setFont(GUIUtil::getSubLabelFont());
360  ui->radioSmartFee->setFont(GUIUtil::getSubLabelFont());
361  ui->labelSmartFee2->setFont(GUIUtil::getSubLabelFont());
362  ui->labelSmartFee3->setFont(GUIUtil::getSubLabelFont());
363  ui->confTargetSelector->setFont(GUIUtil::getSubLabelFont());
364  ui->radioCustomFee->setFont(GUIUtil::getSubLabelFont());
365  ui->labelCustomPerKilobyte->setFont(GUIUtil::getSubLabelFont());
366  ui->customFee->setFont(GUIUtil::getSubLabelFont());
367  ui->labelMinFeeWarning->setFont(GUIUtil::getSubLabelFont());
368  ui->optInRBF->setFont(GUIUtil::getSubLabelFont());
369  ui->createAssetButton->setFont(GUIUtil::getSubLabelFont());
370  ui->clearButton->setFont(GUIUtil::getSubLabelFont());
371  ui->labelSmartFee->setFont(GUIUtil::getSubLabelFont());
372  ui->labelFeeEstimation->setFont(GUIUtil::getSubLabelFont());
373  ui->labelFeeMinimized->setFont(GUIUtil::getSubLabelFont());
374 
375 }
376 
377 void CreateAssetDialog::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
378  const CAmount& watchBalance, const CAmount& watchUnconfirmedBalance, const CAmount& watchImmatureBalance)
379 {
380  Q_UNUSED(unconfirmedBalance);
381  Q_UNUSED(immatureBalance);
382  Q_UNUSED(watchBalance);
383  Q_UNUSED(watchUnconfirmedBalance);
384  Q_UNUSED(watchImmatureBalance);
385 
386  ui->labelBalance->setFont(GUIUtil::getSubLabelFont());
387  ui->label->setFont(GUIUtil::getSubLabelFont());
388 
389  if(model && model->getOptionsModel())
390  {
391  ui->labelBalance->setText(RavenUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance));
392  }
393 }
394 
396 {
397  setBalance(model->getBalance(), 0, 0, 0, 0, 0);
398  ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
401 }
402 
404 {
405  if (ui->ipfsBox->isChecked()) {
406  ui->ipfsText->show();
407  } else {
408  ui->ipfsText->hide();
409  ui->ipfsText->clear();
410  }
411 
412  CheckFormState();
413 }
414 
415 void CreateAssetDialog::showMessage(QString string)
416 {
417  ui->messageLabel->setStyleSheet("color: red; font-size: 15pt;font-weight: bold;");
418  ui->messageLabel->setText(string);
419  ui->messageLabel->show();
420 }
421 
423 {
424  ui->messageLabel->setStyleSheet("color: green; font-size: 15pt;font-weight: bold;");
425  ui->messageLabel->setText(string);
426  ui->messageLabel->show();
427 }
428 
430 {
431  ui->nameText->setStyleSheet("");
432  ui->addressText->setStyleSheet("");
433  if (ui->ipfsBox->isChecked())
434  ui->ipfsText->setStyleSheet("");
435 
436  ui->messageLabel->hide();
437 }
438 
440 {
441  ui->createAssetButton->setDisabled(true);
442 }
443 
445 {
446  if (checkedAvailablity)
447  ui->createAssetButton->setDisabled(false);
448 }
449 
451 {
452  if (!hash.isEmpty()) {
453  std::string error;
454  if (!CheckEncoded(DecodeAssetData(hash.toStdString()), error)) {
455  ui->ipfsText->setStyleSheet("border: 2px solid red");
456  showMessage(tr("IPFS/Txid Hash must start with 'Qm' and be 46 characters or Txid Hash must have 64 hex characters"));
458  return false;
459  }
460  else if (hash.size() != 46 && hash.size() != 64) {
461  ui->ipfsText->setStyleSheet("border: 2px solid red");
462  showMessage(tr("IPFS/Txid Hash must have size of 46 characters, or 64 hex characters"));
464  return false;
465  } else if (DecodeAssetData(hash.toStdString()).empty()) {
466  showMessage(tr("IPFS/Txid hash is not valid. Please use a valid IPFS/Txid hash"));
468  return false;
469  }
470  }
471 
472  // No problems where found with the hash, reset the border, and hide the messages.
473  hideMessage();
474  ui->ipfsText->setStyleSheet("");
475 
476  return true;
477 }
478 
480 {
481  disableCreateButton(); // Disable the button by default
482  hideMessage();
483 
484  const CTxDestination dest = DecodeDestination(ui->addressText->text().toStdString());
485 
486  QString name = GetAssetName();
487 
488  std::string error;
489  bool assetNameValid = IsTypeCheckNameValid(AssetTypeFromInt(type), name.toStdString(), error);
490 
492  if (ui->assetList->currentText() == "")
493  {
494  ui->assetList->lineEdit()->setStyleSheet(STYLE_INVALID);
495  ui->availabilityButton->setDisabled(true);
496  return;
497  }
498  }
499 
500  if (!assetNameValid && name.size() != 0) {
501  ui->nameText->setStyleSheet(STYLE_INVALID);
502  showMessage(error.c_str());
503  ui->availabilityButton->setDisabled(true);
504  return;
505  }
506 
507  if (!(ui->addressText->text().isEmpty() || IsValidDestination(dest)) && assetNameValid) {
508  ui->addressText->setStyleSheet(STYLE_INVALID);
509  showMessage(tr("Warning: Invalid Raven address"));
510  return;
511  }
512 
513  if (ui->ipfsBox->isChecked())
514  if (!checkIPFSHash(ui->ipfsText->text()))
515  return;
516 
517  if (checkedAvailablity) {
518  showValidMessage(tr("Valid Asset"));
520  ui->availabilityButton->setDisabled(true);
521  } else {
523  ui->availabilityButton->setDisabled(false);
524  }
525 }
526 
529 {
530  toggleIPFSText();
531 }
532 
534 {
535  QString name = GetAssetName();
536 
537  LOCK(cs_main);
538  auto currentActiveAssetCache = GetCurrentAssetCache();
539  if (currentActiveAssetCache) {
540  CNewAsset asset;
541  if (currentActiveAssetCache->GetAssetMetaDataIfExists(name.toStdString(), asset)) {
542  ui->nameText->setStyleSheet(STYLE_INVALID);
543  showMessage(tr("Invalid: Asset name already in use"));
545  checkedAvailablity = false;
546  return;
547  } else {
548  checkedAvailablity = true;
549  ui->nameText->setStyleSheet(STYLE_VALID);
550  }
551  } else {
552  checkedAvailablity = false;
553  showMessage(tr("Error: Asset Database not in sync"));
555  return;
556  }
557 
558  CheckFormState();
559 }
560 
562 {
563  // Update the displayed name to uppercase if the type only accepts uppercase
564  name = type == IntFromAssetType(AssetType::UNIQUE) ? name : name.toUpper();
566 
567  QString assetName = name;
568 
569  // Get the identifier for the asset type
570  QString identifier = GetSpecialCharacter();
571 
572  if (name.size() == 0) {
573  hideMessage();
574  ui->availabilityButton->setDisabled(true);
576  return;
577  }
578 
580  std::string error;
581  auto strName = GetAssetName();
582  if (IsTypeCheckNameValid(AssetType::ROOT, strName.toStdString(), error)) {
583  hideMessage();
584  ui->availabilityButton->setDisabled(false);
585  } else {
586  ui->nameText->setStyleSheet(STYLE_INVALID);
587  showMessage(tr(error.c_str()));
588  ui->availabilityButton->setDisabled(true);
589  }
591  if (name.size() == 0) {
592  hideMessage();
593  ui->availabilityButton->setDisabled(true);
594  }
595 
596  // If an asset isn't selected. Mark the lineedit with invalid style sheet
597  if (ui->assetList->currentText() == "")
598  {
599  ui->assetList->lineEdit()->setStyleSheet(STYLE_INVALID);
600  ui->availabilityButton->setDisabled(true);
601  return;
602  }
603 
604  std::string error;
605  auto assetType = AssetTypeFromInt(type);
606  auto strName = GetAssetName();
607  if (IsTypeCheckNameValid(assetType, strName.toStdString(), error)) {
608  hideMessage();
609  ui->availabilityButton->setDisabled(false);
610  } else {
611  ui->nameText->setStyleSheet(STYLE_INVALID);
612  showMessage(tr(error.c_str()));
613  ui->availabilityButton->setDisabled(true);
614  }
615  }
616 
617  // Set the assetName
618  updatePresentedAssetName(format.arg(type == IntFromAssetType(AssetType::ROOT) ? "" : ui->assetList->currentText(), identifier, name));
619 
620  checkedAvailablity = false;
622 }
623 
625 {
626  CheckFormState();
627 }
628 
630 {
631  if (checkIPFSHash(hash))
632  CheckFormState();
633 }
634 
636 {
638  if(!ctx.isValid())
639  {
640  // Unlock wallet was cancelled
641  return;
642  }
643 
644  QString name = GetAssetName();
645  CAmount quantity = ui->quantitySpinBox->value() * COIN;
646  int units = ui->unitBox->value();
647  bool reissuable = ui->reissuableBox->isChecked();
648  bool hasIPFS = ui->ipfsBox->isChecked() && !ui->ipfsText->text().isEmpty();
649 
650  std::string ipfsDecoded = "";
651  if (hasIPFS)
652  ipfsDecoded = DecodeAssetData(ui->ipfsText->text().toStdString());
653 
654  CNewAsset asset(name.toStdString(), quantity, units, reissuable ? 1 : 0, hasIPFS ? 1 : 0, ipfsDecoded);
655 
656  CWalletTx tx;
657  CReserveKey reservekey(model->getWallet());
658  std::pair<int, std::string> error;
659  CAmount nFeeRequired;
660 
661  // Always use a CCoinControl instance, use the CoinControlDialog instance if CoinControl has been enabled
662  CCoinControl ctrl;
665 
667 
668  QString address;
669  if (ui->addressText->text().isEmpty()) {
671  } else {
672  address = ui->addressText->text();
673  }
674 
675  // Create the transaction
676  if (!CreateAssetTransaction(model->getWallet(), ctrl, asset, address.toStdString(), error, tx, reservekey, nFeeRequired)) {
677  showMessage("Invalid: " + QString::fromStdString(error.second));
678  return;
679  }
680 
681  // Format confirmation message
682  QStringList formatted;
683 
684  // generate bold amount string
685  QString amount = "<b>" + QString::fromStdString(ValueFromAmountString(GetBurnAmount(type), 8)) + " RVN";
686  amount.append("</b>");
687  // generate monospace address string
688  QString addressburn = "<span style='font-family: monospace;'>" + QString::fromStdString(GetBurnAddress(type));
689  addressburn.append("</span>");
690 
691  QString recipientElement1;
692  recipientElement1 = tr("%1 to %2").arg(amount, addressburn);
693  formatted.append(recipientElement1);
694 
695  // generate the bold asset amount
696  QString assetAmount = "<b>" + QString::fromStdString(ValueFromAmountString(asset.nAmount, asset.units)) + " " + QString::fromStdString(asset.strName);
697  assetAmount.append("</b>");
698 
699  // generate the monospace address string
700  QString assetAddress = "<span style='font-family: monospace;'>" + address;
701  assetAddress.append("</span>");
702 
703  QString recipientElement2;
704  recipientElement2 = tr("%1 to %2").arg(assetAmount, assetAddress);
705  formatted.append(recipientElement2);
706 
707  QString questionString = tr("Are you sure you want to send?");
708  questionString.append("<br /><br />%1");
709 
710  if(nFeeRequired > 0)
711  {
712  // append fee string if a fee is required
713  questionString.append("<hr /><span style='color:#aa0000;'>");
714  questionString.append(RavenUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), nFeeRequired));
715  questionString.append("</span> ");
716  questionString.append(tr("added as transaction fee"));
717 
718  // append transaction size
719  questionString.append(" (" + QString::number((double)GetVirtualTransactionSize(tx) / 1000) + " kB)");
720  }
721 
722  // add total amount in all subdivision units
723  questionString.append("<hr />");
724  CAmount totalAmount = GetBurnAmount(type) + nFeeRequired;
725  QStringList alternativeUnits;
727  {
728  if(u != model->getOptionsModel()->getDisplayUnit())
729  alternativeUnits.append(RavenUnits::formatHtmlWithUnit(u, totalAmount));
730  }
731  questionString.append(tr("Total Amount %1")
733  questionString.append(QString("<span style='font-size:10pt;font-weight:normal;'><br />(=%2)</span>")
734  .arg(alternativeUnits.join(" " + tr("or") + "<br />")));
735 
736  SendConfirmationDialog confirmationDialog(tr("Confirm send assets"),
737  questionString.arg(formatted.join("<br />")), SEND_CONFIRM_DELAY, this);
738  confirmationDialog.exec();
739  QMessageBox::StandardButton retval = (QMessageBox::StandardButton)confirmationDialog.result();
740 
741  if(retval != QMessageBox::Yes)
742  {
743  return;
744  }
745 
746  // Create the transaction and broadcast it
747  std::string txid;
748  if (!SendAssetTransaction(model->getWallet(), tx, reservekey, error, txid)) {
749  showMessage(tr("Invalid: ") + QString::fromStdString(error.second));
750  } else {
751  QMessageBox msgBox;
752  QPushButton *copyButton = msgBox.addButton(tr("Copy"), QMessageBox::ActionRole);
753  copyButton->disconnect();
754  connect(copyButton, &QPushButton::clicked, this, [=](){
755  QClipboard *p_Clipboard = QApplication::clipboard();
756  p_Clipboard->setText(QString::fromStdString(txid), QClipboard::Mode::Clipboard);
757 
758  QMessageBox copiedBox;
759  copiedBox.setText(tr("Transaction ID Copied"));
760  copiedBox.exec();
761  });
762 
763  QPushButton *okayButton = msgBox.addButton(QMessageBox::Ok);
764  msgBox.setText(tr("Asset transaction sent to network:"));
765  msgBox.setInformativeText(QString::fromStdString(txid));
766  msgBox.exec();
767 
768  if (msgBox.clickedButton() == okayButton) {
769  clear();
770 
773  }
774  }
775 }
776 
778 {
779  QString text;
780  text += "e.g. 1";
781  // Add the period
782  if (value > 0)
783  text += ".";
784 
785  // Add the remaining zeros
786  for (int i = 0; i < value; i++) {
787  text += "0";
788  }
789 
790  ui->unitExampleLabel->setText(text);
791 }
792 
793 void CreateAssetDialog::onChangeAddressChanged(QString changeAddress)
794 {
795  CheckFormState();
796 }
797 
799 {
801  checkedAvailablity = false;
802 
803  // Update the selected type
804  type = index;
805 
806  // Make sure the type is only the the supported issue types
809 
810  // If the type is UNIQUE, set the units and amount to the correct value, and disable them.
813  else
814  clearSelected();
815 
816  // Get the identifier for the asset type
817  QString identifier = GetSpecialCharacter();
818 
819  if (index != 0) {
820  ui->assetList->show();
821  } else {
822  ui->assetList->hide();
823  }
824 
826 
827  // Set assetName
828  updatePresentedAssetName(format.arg(type == IntFromAssetType(AssetType::ROOT) ? "" : ui->assetList->currentText(), identifier, ui->nameText->text()));
829 
830  if (ui->nameText->text().size())
831  ui->availabilityButton->setDisabled(false);
832  else
833  ui->availabilityButton->setDisabled(true);
834  ui->createAssetButton->setDisabled(true);
835 
836  // Update coinControl so it can change the amount that is being spent
838 }
839 
841 {
842  // Get the identifier for the asset type
843  QString identifier = GetSpecialCharacter();
844 
846 
847  // Set assetName
848  updatePresentedAssetName(format.arg(type == IntFromAssetType(AssetType::ROOT) ? "" : ui->assetList->currentText(), identifier, ui->nameText->text()));
849 
850  if (ui->nameText->text().size())
851  ui->availabilityButton->setDisabled(false);
852  else
853  ui->availabilityButton->setDisabled(true);
854  ui->createAssetButton->setDisabled(true);
855 }
856 
858 {
859  ui->assetFullName->setText(name);
860 }
861 
863 {
865  return "/";
867  return "#";
868 
869  return "";
870 }
871 
873 {
875  return ui->nameText->text();
876  else if (type == IntFromAssetType(AssetType::SUB))
877  return ui->assetList->currentText() + "/" + ui->nameText->text();
879  return ui->assetList->currentText() + "#" + ui->nameText->text();
880  return "";
881 }
882 
884 {
886  ui->nameText->setMaxLength(30);
888  ui->nameText->setMaxLength(30 - (ui->assetList->currentText().size() + 1));
889  }
890 }
891 
893 {
895  ui->nameText->setText(ui->nameText->text().toUpper());
896  }
897 }
898 
900 {
901  if (ui->radioCustomFee->isChecked()) {
902  ctrl.m_feerate = CFeeRate(ui->customFee->value());
903  } else {
904  ctrl.m_feerate.reset();
905  }
906  // Avoid using global defaults when sending money from the GUI
907  // Either custom fee will be used or if not selected, the confirmation target from dropdown box
908  ctrl.m_confirm_target = getConfTargetForIndex(ui->confTargetSelector->currentIndex());
909 // ctrl.signalRbf = ui->optInRBF->isChecked();
910 }
911 
913 {
914  if(!model || !model->getOptionsModel())
915  return;
916  CCoinControl coin_control;
917  updateCoinControlState(coin_control);
918  coin_control.m_feerate.reset(); // Explicitly use only fee estimation rate for smart fee labels
919  FeeCalculation feeCalc;
920  CFeeRate feeRate = CFeeRate(GetMinimumFee(1000, coin_control, ::mempool, ::feeEstimator, &feeCalc));
921 
922  ui->labelSmartFee->setText(RavenUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB");
923 
924  if (feeCalc.reason == FeeReason::FALLBACK) {
925  ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)
926  ui->labelFeeEstimation->setText("");
927  ui->fallbackFeeWarningLabel->setVisible(true);
928  int lightness = ui->fallbackFeeWarningLabel->palette().color(QPalette::WindowText).lightness();
929  QColor warning_colour(255 - (lightness / 5), 176 - (lightness / 3), 48 - (lightness / 14));
930  ui->fallbackFeeWarningLabel->setStyleSheet("QLabel { color: " + warning_colour.name() + "; }");
931  ui->fallbackFeeWarningLabel->setIndent(QFontMetrics(ui->fallbackFeeWarningLabel->font()).width("x"));
932  }
933  else
934  {
935  ui->labelSmartFee2->hide();
936  ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", feeCalc.returnedTarget));
937  ui->fallbackFeeWarningLabel->setVisible(false);
938  }
939 
941 }
942 
943 // Coin Control: copy label "Quantity" to clipboard
945 {
946  GUIUtil::setClipboard(ui->labelCoinControlQuantity->text());
947 }
948 
949 // Coin Control: copy label "Amount" to clipboard
951 {
952  GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
953 }
954 
955 // Coin Control: copy label "Fee" to clipboard
957 {
958  GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")).replace(ASYMP_UTF8, ""));
959 }
960 
961 // Coin Control: copy label "After fee" to clipboard
963 {
964  GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")).replace(ASYMP_UTF8, ""));
965 }
966 
967 // Coin Control: copy label "Bytes" to clipboard
969 {
970  GUIUtil::setClipboard(ui->labelCoinControlBytes->text().replace(ASYMP_UTF8, ""));
971 }
972 
973 // Coin Control: copy label "Dust" to clipboard
975 {
976  GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text());
977 }
978 
979 // Coin Control: copy label "Change" to clipboard
981 {
982  GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")).replace(ASYMP_UTF8, ""));
983 }
984 
985 // Coin Control: settings menu - coin control enabled/disabled by user
987 {
988  ui->frameCoinControl->setVisible(checked);
989  ui->addressText->setVisible(checked);
990  ui->addressLabel->setVisible(checked);
991 
992  if (!checked && model) // coin control features disabled
994 
996 }
997 
998 // Coin Control: settings menu - coin control enabled/disabled by user
1000 {
1001  ui->frameFee->setVisible(checked);
1002 }
1003 
1004 // Coin Control: button inputs -> show actual coin control dialog
1006 {
1008  dlg.setModel(model);
1009  dlg.exec();
1011 }
1012 
1013 // Coin Control: checkbox custom change address
1015 {
1016  if (state == Qt::Unchecked)
1017  {
1019  ui->labelCoinControlChangeLabel->clear();
1020  }
1021  else
1022  // use this to re-validate an already entered address
1023  coinControlChangeEdited(ui->lineEditCoinControlChange->text());
1024 
1025  ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));
1026 }
1027 
1028 // Coin Control: custom change address changed
1030 {
1031  if (model && model->getAddressTableModel())
1032  {
1033  // Default to no change address until verified
1035  ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
1036 
1037  const CTxDestination dest = DecodeDestination(text.toStdString());
1038 
1039  if (text.isEmpty()) // Nothing entered
1040  {
1041  ui->labelCoinControlChangeLabel->setText("");
1042  }
1043  else if (!IsValidDestination(dest)) // Invalid address
1044  {
1045  ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Raven address"));
1046  }
1047  else // Valid address
1048  {
1049  if (!model->IsSpendable(dest)) {
1050  ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
1051 
1052  // confirmation dialog
1053  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?"),
1054  QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
1055 
1056  if(btnRetVal == QMessageBox::Yes)
1058  else
1059  {
1060  ui->lineEditCoinControlChange->setText("");
1061  ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
1062  ui->labelCoinControlChangeLabel->setText("");
1063  }
1064  }
1065  else // Known change address
1066  {
1067  ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
1068 
1069  // Query label
1070  QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);
1071  if (!associatedLabel.isEmpty())
1072  ui->labelCoinControlChangeLabel->setText(associatedLabel);
1073  else
1074  ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
1075 
1077  }
1078  }
1079  }
1080 }
1081 
1082 // Coin Control: update labels
1084 {
1085  if (!model || !model->getOptionsModel())
1086  return;
1087 
1089 
1090  // set pay amounts
1093 
1095 
1096  if (CoinControlDialog::coinControl->HasSelected())
1097  {
1098  // actual coin control calculation
1100 
1101  // show coin control stats
1102  ui->labelCoinControlAutomaticallySelected->hide();
1103  ui->widgetCoinControl->show();
1104  }
1105  else
1106  {
1107  // hide coin control stats
1108  ui->labelCoinControlAutomaticallySelected->show();
1109  ui->widgetCoinControl->hide();
1110  ui->labelCoinControlInsuffFunds->hide();
1111  }
1112 }
1113 
1115 {
1116  ui->labelFeeMinimized->setVisible(fMinimize);
1117  ui->buttonChooseFee ->setVisible(fMinimize);
1118  ui->buttonMinimizeFee->setVisible(!fMinimize);
1119  ui->frameFeeSelection->setVisible(!fMinimize);
1120  ui->horizontalLayoutSmartFee->setContentsMargins(0, (fMinimize ? 0 : 6), 0, 0);
1121  fFeeMinimized = fMinimize;
1122 }
1123 
1125 {
1126  minimizeFeeSection(false);
1127 }
1128 
1130 {
1132  minimizeFeeSection(true);
1133 }
1134 
1136 {
1137  ui->customFee->setValue(GetRequiredFee(1000));
1138 }
1139 
1141 {
1142  ui->confTargetSelector ->setEnabled(ui->radioSmartFee->isChecked());
1143  ui->labelSmartFee ->setEnabled(ui->radioSmartFee->isChecked());
1144  ui->labelSmartFee2 ->setEnabled(ui->radioSmartFee->isChecked());
1145  ui->labelSmartFee3 ->setEnabled(ui->radioSmartFee->isChecked());
1146  ui->labelFeeEstimation ->setEnabled(ui->radioSmartFee->isChecked());
1147  ui->checkBoxMinimumFee ->setEnabled(ui->radioCustomFee->isChecked());
1148  ui->labelMinFeeWarning ->setEnabled(ui->radioCustomFee->isChecked());
1149  ui->labelCustomPerKilobyte ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked());
1150  ui->customFee ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked());
1151 }
1152 
1154 {
1155  if(!model || !model->getOptionsModel())
1156  return;
1157 
1158  if (ui->radioSmartFee->isChecked())
1159  ui->labelFeeMinimized->setText(ui->labelSmartFee->text());
1160  else {
1161  ui->labelFeeMinimized->setText(RavenUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), ui->customFee->value()) + "/kB");
1162  }
1163 }
1164 
1166 {
1167  if (model && model->getOptionsModel())
1168  ui->checkBoxMinimumFee->setText(tr("Pay only the required fee of %1").arg(
1170  );
1171 }
1172 
1174 {
1175  ui->reissuableBox->setChecked(false);
1176  ui->quantitySpinBox->setValue(1);
1177  ui->unitBox->setValue(0);
1178  ui->reissuableBox->setDisabled(true);
1179  ui->unitBox->setDisabled(true);
1180  ui->quantitySpinBox->setDisabled(true);
1181 }
1182 
1184 {
1185  ui->reissuableBox->setDisabled(false);
1186  ui->unitBox->setDisabled(false);
1187  ui->quantitySpinBox->setDisabled(false);
1188  ui->reissuableBox->setChecked(true);
1189  ui->unitBox->setValue(0);
1190 }
1191 
1193 {
1194  QStringList list;
1195  list << "";
1196 
1197  std::vector<std::string> names;
1199  for (auto item : names) {
1200  std::string name = QString::fromStdString(item).split("!").first().toStdString();
1201  if (name.size() != 30)
1202  list << QString::fromStdString(name);
1203  }
1204 
1205  stringModel->setStringList(list);
1206 }
1207 
1209 {
1210  ui->assetType->setCurrentIndex(0);
1211  ui->nameText->clear();
1212  ui->addressText->clear();
1213  ui->quantitySpinBox->setValue(1);
1214  ui->unitBox->setValue(0);
1215  ui->reissuableBox->setChecked(true);
1216  ui->ipfsBox->setChecked(false);
1217  ui->ipfsText->hide();
1218  ui->assetList->hide();
1219  ui->assetList->setCurrentIndex(0);
1220  type = 0;
1221  ui->assetFullName->clear();
1222  ui->unitBox->setDisabled(false);
1223  ui->quantitySpinBox->setDisabled(false);
1224  hideMessage();
1226 }
1227 
1229 {
1230  clear();
1231 }
1232 
1233 void CreateAssetDialog::focusSubAsset(const QModelIndex &index)
1234 {
1235  selectTypeName(1,index.data(AssetTableModel::AssetNameRole).toString());
1236 }
1237 
1238 void CreateAssetDialog::focusUniqueAsset(const QModelIndex &index)
1239 {
1240  selectTypeName(2,index.data(AssetTableModel::AssetNameRole).toString());
1241 }
1242 
1244 {
1245  clear();
1246 
1247  if (IsAssetNameAnOwner(name.toStdString()))
1248  name = name.left(name.size() - 1);
1249 
1250  ui->assetType->setCurrentIndex(type);
1251  onAssetTypeActivated(type);
1252 
1253  ui->assetList->setCurrentIndex(ui->assetList->findText(name));
1254  onAssetListActivated(ui->assetList->currentIndex());
1255 
1256  ui->nameText->setFocus();
1257 }
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
bool CreateAssetTransaction(CWallet *pwallet, CCoinControl &coinControl, const CNewAsset &asset, const std::string &address, std::pair< int, std::string > &error, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRequired, std::string *verifier_string)
Creates new asset issuance transaction.
Definition: assets.cpp:3745
int returnedTarget
Definition: fees.h:131
ClientModel * clientModel
QGraphicsDropShadowEffect * getShadowEffect()
Definition: guiutil.cpp:146
static CCoinControl * coinControl
QCompleter * completer
boost::optional< unsigned int > m_confirm_target
Override the default confirmation target if set.
Definition: coincontrol.h:30
std::string GetBurnAddress(const int nType)
Definition: assets.cpp:3609
void ipfsStateChanged()
SLOTS.
void setUpValues()
Helper Methods.
int IntFromAssetType(AssetType type)
Definition: assettypes.cpp:8
UnlockContext requestUnlock()
void onAssetListActivated(int index)
#define STYLE_VALID
Definition: guiconstants.h:22
FeeReason reason
Definition: fees.h:129
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
void onNameChanged(QString name)
#define SEND_CONFIRM_DELAY
CreateAssetDialog(const PlatformStyle *platformStyle, QWidget *parent=0)
void setClientModel(ClientModel *clientModel)
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
AssetType AssetTypeFromInt(int nType)
Definition: assettypes.cpp:12
AddressTableModel * getAddressTableModel()
void showMessage(QString string)
Coin Control Features.
Definition: coincontrol.h:17
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 focusSubAsset(const QModelIndex &index)
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
QFont getSubLabelFont()
Definition: guiutil.cpp:86
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
Definition: ravenunits.cpp:146
Ui::CreateAssetDialog * ui
void updateCoinControlState(CCoinControl &ctrl)
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
Definition: guiutil.cpp:201
std::string DecodeAssetData(std::string encoded)
Decode and Encode IPFS hashes, or OIP hashes.
Definition: assets.cpp:3699
void onAddressNameChanged(QString address)
void setModel(WalletModel *model)
void minimizeFeeSection(bool fMinimize)
CAssetsCache * GetCurrentAssetCache()
void setClipboard(const QString &str)
Definition: guiutil.cpp:945
#define STRING_LABEL_COLOR
Definition: guiconstants.h:90
#define LOCK(cs)
Definition: sync.h:176
void SetNull()
Definition: coincontrol.h:46
CTxDestination destChange
Definition: coincontrol.h:20
int getDefaultConfirmTarget() const
CAmount getWatchUnconfirmedBalance() const
QString labelForAddress(const QString &address) const
void onChangeAddressChanged(QString changeAddress)
void coinControlChangeEdited(const QString &)
void selectTypeName(int type, QString name)
void showValidMessage(QString string)
void setBalance(const CAmount &balance, const CAmount &unconfirmedBalance, const CAmount &immatureBalance, const CAmount &watchOnlyBalance, const CAmount &watchUnconfBalance, const CAmount &watchImmatureBalance)
#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
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
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:285
QSortFilterProxyModel * proxy
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.
void feeControlFeatureChanged(bool)
void updatePresentedAssetName(QString name)
void coinControlFeatureChanged(bool)
void setModel(WalletModel *model)
QString addRow(const QString &type, const QString &label, const QString &address)
static bool fSubtractFeeFromAmount
QColor WidgetBackGroundColor() const
#define ASYMP_UTF8
bool checkIPFSHash(QString hash)
A key allocated from the key pool.
Definition: wallet.h:1193
void onIPFSHashChanged(QString hash)
const CChainParams & Params()
Return the currently selected parameters.
Interface to Raven wallet from Qt view code.
Definition: walletmodel.h:165
CAmount getWatchBalance() const
Definition: walletmodel.cpp:97
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 onUnitChanged(int value)
Dialog showing transaction details.
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
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
bool IsTypeCheckNameValid(const AssetType type, const std::string &name, std::string &error)
Given a type, and an asset name, return if that name is valid based on the type.
Definition: assets.cpp:317
QString formatNiceTimeOffset(qint64 secs)
Definition: guiutil.cpp:1029
CWallet * getWallet() const
void coinControlChangeChecked(int)
QStringListModel * stringModel
void setupCoinControlFrame(const PlatformStyle *platformStyle)
const PlatformStyle * platformStyle
bool getCustomFeeFeatures() const
Definition: optionsmodel.h:72
WalletModel * model
void setupFeeControl(const PlatformStyle *platformStyle)
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
void focusUniqueAsset(const QModelIndex &index)
OptionsModel * getOptionsModel()
void onAssetTypeActivated(int index)
bool IsSpendable(const CTxDestination &dest) const
void setupAssetDataView(const PlatformStyle *platformStyle)
bool IsAssetNameAnOwner(const std::string &name)
Check if an asset is an owner.
Definition: assets.cpp:296
bool eventFilter(QObject *sender, QEvent *event)