forked from ezehy/starcashx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverviewpage.cpp
572 lines (476 loc) · 22.6 KB
/
overviewpage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
#include "overviewpage.h"
#include "ui_overviewpage.h"
#include "clientmodel.h"
#include "darksend.h"
#include "darksendconfig.h"
#include "walletmodel.h"
#include "bitcoinunits.h"
#include "optionsmodel.h"
#include "transactiontablemodel.h"
#include "transactionfilterproxy.h"
#include "guiutil.h"
#include "guiconstants.h"
#include <QAbstractItemDelegate>
#include <QPainter>
#include <QScrollArea>
#include <QScroller>
#include <QSettings>
#include <QTimer>
#define DECORATION_SIZE 64
#define ICON_OFFSET 16
#define NUM_ITEMS 6
class TxViewDelegate : public QAbstractItemDelegate
{
Q_OBJECT
public:
TxViewDelegate(): QAbstractItemDelegate(), unit(BitcoinUnits::BTC)
{
}
inline void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index ) const
{
painter->save();
QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
QRect mainRect = option.rect;
mainRect.moveLeft(ICON_OFFSET);
QRect decorationRect(mainRect.topLeft(), QSize(DECORATION_SIZE, DECORATION_SIZE));
int xspace = DECORATION_SIZE + 8;
int ypad = 6;
int halfheight = (mainRect.height() - 2*ypad)/2;
QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace - ICON_OFFSET, halfheight);
QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight);
icon.paint(painter, decorationRect);
QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime();
QString address = index.data(Qt::DisplayRole).toString();
qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong();
bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool();
QVariant value = index.data(Qt::ForegroundRole);
QColor foreground = option.palette.color(QPalette::Text);
if(qVariantCanConvert<QColor>(value))
{
foreground = qvariant_cast<QColor>(value);
}
painter->setPen(fUseBlackTheme ? QColor(255, 255, 255) : foreground);
QRect boundingRect;
painter->drawText(addressRect, Qt::AlignLeft|Qt::AlignVCenter, address, &boundingRect);
if (index.data(TransactionTableModel::WatchonlyRole).toBool())
{
QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole));
QRect watchonlyRect(boundingRect.right() + 5, mainRect.top()+ypad+halfheight, 16, halfheight);
iconWatchonly.paint(painter, watchonlyRect);
}
if(amount < 0)
{
foreground = COLOR_NEGATIVE;
}
else if(!confirmed)
{
foreground = COLOR_UNCONFIRMED;
}
else
{
foreground = option.palette.color(QPalette::Text);
}
painter->setPen(fUseBlackTheme ? QColor(255, 255, 255) : foreground);
QString amountText = BitcoinUnits::formatWithUnit(unit, amount, true);
if(!confirmed)
{
amountText = QString("[") + amountText + QString("]");
}
painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
painter->setPen(fUseBlackTheme ? QColor(96, 101, 110) : option.palette.color(QPalette::Text));
painter->drawText(amountRect, Qt::AlignLeft|Qt::AlignVCenter, GUIUtil::dateTimeStr(date));
painter->restore();
}
inline QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
return QSize(DECORATION_SIZE, DECORATION_SIZE);
}
int unit;
};
#include "overviewpage.moc"
OverviewPage::OverviewPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::OverviewPage),
clientModel(0),
walletModel(0),
currentBalance(-1),
currentStake(-1),
currentUnconfirmedBalance(-1),
currentImmatureBalance(-1),
currentWatchOnlyBalance(-1),
currentWatchOnlyStake(-1),
currentWatchUnconfBalance(-1),
currentWatchImmatureBalance(-1),
txdelegate(new TxViewDelegate()),
filter(0)
{
ui->setupUi(this);
// Recent transactions
ui->listTransactions->setItemDelegate(txdelegate);
ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE));
ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false);
ui->listTransactions->setMinimumWidth(300);
connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex)));
// init "out of sync" warning labels
ui->labelWalletStatus->setText("(" + tr("out of sync") + ")");
ui->labelDarksendSyncStatus->setText("(" + tr("out of sync") + ")");
ui->labelTransactionsStatus->setText("(" + tr("out of sync") + ")");
fLiteMode = GetBoolArg("-litemode", false);
if(fLiteMode){
ui->frameDarksend->setVisible(false);
} else {
if(fMasterNode){
ui->toggleDarksend->setText("(" + tr("Disabled") + ")");
ui->darksendAuto->setText("(" + tr("Disabled") + ")");
ui->darksendReset->setText("(" + tr("Disabled") + ")");
ui->frameDarksend->setEnabled(false);
} else {
if(!fEnableDarksend){
ui->toggleDarksend->setText(tr("Start Darksend Mixing"));
} else {
ui->toggleDarksend->setText(tr("Stop Darksend Mixing"));
}
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(darkSendStatus()));
if(!GetBoolArg("-reindexaddr", false))
timer->start(60000);
}
}
// start with displaying the "out of sync" warnings
showOutOfSyncWarning(true);
if (fUseBlackTheme)
{
const char* whiteLabelQSS = "QLabel { color: rgb(255,255,255); }";
ui->labelBalance->setStyleSheet(whiteLabelQSS);
ui->labelStake->setStyleSheet(whiteLabelQSS);
ui->labelUnconfirmed->setStyleSheet(whiteLabelQSS);
ui->labelImmature->setStyleSheet(whiteLabelQSS);
ui->labelTotal->setStyleSheet(whiteLabelQSS);
}
}
void OverviewPage::handleTransactionClicked(const QModelIndex &index)
{
if(filter)
emit transactionClicked(filter->mapToSource(index));
}
OverviewPage::~OverviewPage()
{
if(!fLiteMode && !fMasterNode) disconnect(timer, SIGNAL(timeout()), this, SLOT(darkSendStatus()));
delete ui;
}
void OverviewPage::setBalance(const CAmount& balance, const CAmount& stake, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& anonymizedBalance, const CAmount& watchOnlyBalance, const CAmount& watchOnlyStake, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance)
{
currentBalance = balance;
currentStake = stake;
currentUnconfirmedBalance = unconfirmedBalance;
currentImmatureBalance = immatureBalance;
currentAnonymizedBalance = anonymizedBalance;
currentWatchOnlyBalance = watchOnlyBalance;
currentWatchOnlyStake = watchOnlyStake;
currentWatchUnconfBalance = watchUnconfBalance;
currentWatchImmatureBalance = watchImmatureBalance;
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, balance));
ui->labelStake->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, stake));
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, unconfirmedBalance));
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, immatureBalance));
ui->labelAnonymized->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, anonymizedBalance));
ui->labelTotal->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, balance + stake + unconfirmedBalance + immatureBalance));
ui->labelWatchAvailable->setText(BitcoinUnits::floorWithUnit(nDisplayUnit, watchOnlyBalance));
ui->labelWatchStake->setText(BitcoinUnits::floorWithUnit(nDisplayUnit, watchOnlyStake));
ui->labelWatchPending->setText(BitcoinUnits::floorWithUnit(nDisplayUnit, watchUnconfBalance));
ui->labelWatchImmature->setText(BitcoinUnits::floorWithUnit(nDisplayUnit, watchImmatureBalance));
ui->labelWatchTotal->setText(BitcoinUnits::floorWithUnit(nDisplayUnit, watchOnlyBalance + watchOnlyStake + watchUnconfBalance + watchImmatureBalance));
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
// for the non-mining users
bool showImmature = immatureBalance != 0;
bool showWatchOnlyImmature = watchImmatureBalance != 0;
// for symmetry reasons also show immature label when the watch-only one is shown
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance
updateDarksendProgress();
static int cachedTxLocks = 0;
if(cachedTxLocks != nCompleteTXLocks){
cachedTxLocks = nCompleteTXLocks;
ui->listTransactions->update();
}
}
// show/hide watch-only labels
void OverviewPage::updateWatchOnlyLabels(bool showWatchOnly)
{
ui->labelSpendable->setVisible(showWatchOnly); // show spendable label (only when watch-only is active)
ui->labelWatchonly->setVisible(showWatchOnly); // show watch-only label
ui->lineWatchBalance->setVisible(showWatchOnly); // show watch-only balance separator line
ui->labelWatchStake->setVisible(showWatchOnly); // show watch-only balance separator line
ui->labelWatchAvailable->setVisible(showWatchOnly); // show watch-only available balance
ui->labelWatchPending->setVisible(showWatchOnly); // show watch-only pending balance
ui->labelWatchTotal->setVisible(showWatchOnly); // show watch-only total balance
if (!showWatchOnly){
ui->labelWatchImmature->hide();
}
else{
ui->labelBalance->setIndent(20);
ui->labelStake->setIndent(20);
ui->labelUnconfirmed->setIndent(20);
ui->labelImmature->setIndent(20);
ui->labelTotal->setIndent(20);
}
}
void OverviewPage::setClientModel(ClientModel *model)
{
this->clientModel = model;
if(model)
{
// Show warning if this is a prerelease version
connect(model, SIGNAL(alertsChanged(QString)), this, SLOT(updateAlerts(QString)));
updateAlerts(model->getStatusBarWarnings());
}
}
void OverviewPage::setWalletModel(WalletModel *model)
{
this->walletModel = model;
if(model && model->getOptionsModel())
{
// Set up transaction list
filter = new TransactionFilterProxy();
filter->setSourceModel(model->getTransactionTableModel());
filter->setLimit(NUM_ITEMS);
filter->setDynamicSortFilter(true);
filter->setSortRole(Qt::EditRole);
filter->setShowInactive(false);
filter->sort(TransactionTableModel::Status, Qt::DescendingOrder);
ui->listTransactions->setModel(filter);
ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress);
// Keep up to date with wallet
setBalance(model->getBalance(), model->getStake(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance(),
model->getWatchBalance(), model->getWatchStake(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance());
connect(model, SIGNAL(balanceChanged(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount)), this, SLOT(setBalance(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
connect(ui->darksendAuto, SIGNAL(clicked()), this, SLOT(darksendAuto()));
connect(ui->darksendReset, SIGNAL(clicked()), this, SLOT(darksendReset()));
connect(ui->toggleDarksend, SIGNAL(clicked()), this, SLOT(toggleDarksend()));
updateWatchOnlyLabels(model->haveWatchOnly());
connect(model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyLabels(bool)));
}
// update the display unit, to not use the default ("BTC")
updateDisplayUnit();
}
void OverviewPage::updateDisplayUnit()
{
if(walletModel && walletModel->getOptionsModel())
{
nDisplayUnit = walletModel->getOptionsModel()->getDisplayUnit();
if(currentBalance != -1)
setBalance(currentBalance, currentStake, currentUnconfirmedBalance, currentImmatureBalance, currentAnonymizedBalance,
currentWatchOnlyBalance, currentWatchOnlyStake, currentWatchUnconfBalance, currentWatchImmatureBalance);
// Update txdelegate->unit with the current unit
txdelegate->unit = nDisplayUnit;
ui->listTransactions->update();
}
}
void OverviewPage::updateAlerts(const QString &warnings)
{
this->ui->labelAlerts->setVisible(!warnings.isEmpty());
this->ui->labelAlerts->setText(warnings);
}
void OverviewPage::showOutOfSyncWarning(bool fShow)
{
ui->labelWalletStatus->setVisible(fShow);
ui->labelDarksendSyncStatus->setVisible(fShow);
ui->labelTransactionsStatus->setVisible(fShow);
}
void OverviewPage::updateDarksendProgress()
{
if(!darkSendPool.IsBlockchainSynced() || ShutdownRequested()) return;
if(!pwalletMain) return;
QString strAmountAndRounds;
QString strAnonymizeStarCashXAmount = BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, nAnonymizeStarCashXAmount * COIN, false, BitcoinUnits::separatorAlways);
if(currentBalance == 0)
{
ui->darksendProgress->setValue(0);
ui->darksendProgress->setToolTip(tr("No inputs detected"));
// when balance is zero just show info from settings
strAnonymizeStarCashXAmount = strAnonymizeStarCashXAmount.remove(strAnonymizeStarCashXAmount.indexOf("."), BitcoinUnits::decimals(nDisplayUnit) + 1);
strAmountAndRounds = strAnonymizeStarCashXAmount + " / " + tr("%n Rounds", "", nDarksendRounds);
ui->labelAmountRounds->setToolTip(tr("No inputs detected"));
ui->labelAmountRounds->setText(strAmountAndRounds);
return;
}
CAmount nDenominatedConfirmedBalance;
CAmount nDenominatedUnconfirmedBalance;
CAmount nAnonymizableBalance;
CAmount nNormalizedAnonymizedBalance;
double nAverageAnonymizedRounds;
{
TRY_LOCK(cs_main, lockMain);
if(!lockMain) return;
nDenominatedConfirmedBalance = pwalletMain->GetDenominatedBalance();
nDenominatedUnconfirmedBalance = pwalletMain->GetDenominatedBalance(true);
nAnonymizableBalance = pwalletMain->GetAnonymizableBalance();
nNormalizedAnonymizedBalance = pwalletMain->GetNormalizedAnonymizedBalance();
nAverageAnonymizedRounds = pwalletMain->GetAverageAnonymizedRounds();
}
//Get the anon threshold
CAmount nMaxToAnonymize = nAnonymizableBalance + currentAnonymizedBalance + nDenominatedUnconfirmedBalance;
// If it's more than the anon threshold, limit to that.
if(nMaxToAnonymize > nAnonymizeStarCashXAmount*COIN) nMaxToAnonymize = nAnonymizeStarCashXAmount*COIN;
if(nMaxToAnonymize == 0) return;
if(nMaxToAnonymize >= nAnonymizeStarCashXAmount * COIN) {
ui->labelAmountRounds->setToolTip(tr("Found enough compatible inputs to anonymize %1")
.arg(strAnonymizeStarCashXAmount));
strAnonymizeStarCashXAmount = strAnonymizeStarCashXAmount.remove(strAnonymizeStarCashXAmount.indexOf("."), BitcoinUnits::decimals(nDisplayUnit) + 1);
strAmountAndRounds = strAnonymizeStarCashXAmount + " / " + tr("%n Rounds", "", nDarksendRounds);
} else {
QString strMaxToAnonymize = BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, nMaxToAnonymize, false, BitcoinUnits::separatorAlways);
ui->labelAmountRounds->setToolTip(tr("Not enough compatible inputs to anonymize <span style='color:red;'>%1</span>,<br>"
"will anonymize <span style='color:red;'>%2</span> instead")
.arg(strAnonymizeStarCashXAmount)
.arg(strMaxToAnonymize));
strMaxToAnonymize = strMaxToAnonymize.remove(strMaxToAnonymize.indexOf("."), BitcoinUnits::decimals(nDisplayUnit) + 1);
strAmountAndRounds = "<span style='color:red;'>" +
QString(BitcoinUnits::factor(nDisplayUnit) == 1 ? "" : "~") + strMaxToAnonymize +
" / " + tr("%n Rounds", "", nDarksendRounds) + "</span>";
}
ui->labelAmountRounds->setText(strAmountAndRounds);
// calculate parts of the progress, each of them shouldn't be higher than 1
// progress of denominating
float denomPart = 0;
// mixing progress of denominated balance
float anonNormPart = 0;
// completeness of full amount anonimization
float anonFullPart = 0;
CAmount denominatedBalance = nDenominatedConfirmedBalance + nDenominatedUnconfirmedBalance;
denomPart = (float)denominatedBalance / nMaxToAnonymize;
denomPart = denomPart > 1 ? 1 : denomPart;
denomPart *= 100;
anonNormPart = (float)nNormalizedAnonymizedBalance / nMaxToAnonymize;
anonNormPart = anonNormPart > 1 ? 1 : anonNormPart;
anonNormPart *= 100;
anonFullPart = (float)currentAnonymizedBalance / nMaxToAnonymize;
anonFullPart = anonFullPart > 1 ? 1 : anonFullPart;
anonFullPart *= 100;
// apply some weights to them ...
float denomWeight = 1;
float anonNormWeight = nDarksendRounds;
float anonFullWeight = 2;
float fullWeight = denomWeight + anonNormWeight + anonFullWeight;
// ... and calculate the whole progress
float denomPartCalc = ceilf((denomPart * denomWeight / fullWeight) * 100) / 100;
float anonNormPartCalc = ceilf((anonNormPart * anonNormWeight / fullWeight) * 100) / 100;
float anonFullPartCalc = ceilf((anonFullPart * anonFullWeight / fullWeight) * 100) / 100;
float progress = denomPartCalc + anonNormPartCalc + anonFullPartCalc;
if(progress >= 100) progress = 100;
ui->darksendProgress->setValue(progress);
QString strToolPip = ("<b>" + tr("Overall progress") + ": %1%</b><br/>" +
tr("Denominated") + ": %2%<br/>" +
tr("Mixed") + ": %3%<br/>" +
tr("Anonymized") + ": %4%<br/>" +
tr("Denominated inputs have %5 of %n rounds on average", "", nDarksendRounds))
.arg(progress).arg(denomPart).arg(anonNormPart).arg(anonFullPart)
.arg(nAverageAnonymizedRounds);
ui->darksendProgress->setToolTip(strToolPip);
}
void OverviewPage::darkSendStatus()
{
static int64_t nLastDSProgressBlockTime = 0;
int nBestHeight = pindexBest->nHeight;
// we we're processing more then 1 block per second, we'll just leave
if(((nBestHeight - darkSendPool.cachedNumBlocks) / (GetTimeMillis() - nLastDSProgressBlockTime + 1) > 1)) return;
nLastDSProgressBlockTime = GetTimeMillis();
if(!fEnableDarksend) {
if(nBestHeight != darkSendPool.cachedNumBlocks)
{
darkSendPool.cachedNumBlocks = nBestHeight;
updateDarksendProgress();
ui->darksendEnabled->setText(tr("Disabled"));
ui->darksendStatus->setText("");
ui->toggleDarksend->setText(tr("Start Darksend Mixing"));
}
return;
}
// check darksend status and unlock if needed
if(nBestHeight != darkSendPool.cachedNumBlocks)
{
// Balance and number of transactions might have changed
darkSendPool.cachedNumBlocks = nBestHeight;
updateDarksendProgress();
ui->darksendEnabled->setText(tr("Enabled"));
}
QString strStatus = QString(darkSendPool.GetStatus().c_str());
QString s = tr("Last Darksend message:\n") + strStatus;
if(s != ui->darksendStatus->text())
LogPrintf("Last Darksend message: %s\n", strStatus.toStdString());
ui->darksendStatus->setText(s);
if(darkSendPool.sessionDenom == 0){
ui->labelSubmittedDenom->setText(tr("N/A"));
} else {
std::string out;
darkSendPool.GetDenominationsToString(darkSendPool.sessionDenom, out);
QString s2(out.c_str());
ui->labelSubmittedDenom->setText(s2);
}
// Get DarkSend Denomination Status
}
void OverviewPage::darksendAuto(){
darkSendPool.DoAutomaticDenominating();
}
void OverviewPage::darksendReset(){
darkSendPool.Reset();
darkSendStatus();
QMessageBox::warning(this, tr("Darksend"),
tr("Darksend was successfully reset."),
QMessageBox::Ok, QMessageBox::Ok);
}
void OverviewPage::toggleDarksend(){
QSettings settings;
// Popup some information on first mixing
QString hasMixed = settings.value("hasMixed").toString();
if(hasMixed.isEmpty()){
QMessageBox::information(this, tr("Darksend"),
tr("If you don't want to see internal Darksend fees/transactions select \"Received By\" as Type on the \"Transactions\" tab."),
QMessageBox::Ok, QMessageBox::Ok);
settings.setValue("hasMixed", "hasMixed");
}
if(!fEnableDarksend){
int64_t balance = currentBalance;
float minAmount = 1.49 * COIN;
if(balance < minAmount){
QString strMinAmount(BitcoinUnits::formatWithUnit(nDisplayUnit, minAmount));
QMessageBox::warning(this, tr("Darksend"),
tr("Darksend requires at least %1 to use.").arg(strMinAmount),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
// if wallet is locked, ask for a passphrase
if (walletModel->getEncryptionStatus() == WalletModel::Locked)
{
WalletModel::UnlockContext ctx(walletModel->requestUnlock());
if(!ctx.isValid())
{
//unlock was cancelled
darkSendPool.cachedNumBlocks = std::numeric_limits<int>::max();
QMessageBox::warning(this, tr("Darksend"),
tr("Wallet is locked and user declined to unlock. Disabling Darksend."),
QMessageBox::Ok, QMessageBox::Ok);
if (fDebug) LogPrintf("Wallet is locked and user declined to unlock. Disabling Darksend.\n");
return;
}
}
}
fEnableDarksend = !fEnableDarksend;
darkSendPool.cachedNumBlocks = std::numeric_limits<int>::max();
if(!fEnableDarksend){
ui->toggleDarksend->setText(tr("Start Darksend Mixing"));
darkSendPool.UnlockCoins();
} else {
ui->toggleDarksend->setText(tr("Stop Darksend Mixing"));
/* show darksend configuration if client has defaults set */
if(nAnonymizeStarCashXAmount == 0){
DarksendConfig dlg(this);
dlg.setModel(walletModel);
dlg.exec();
}
}
}