Added Darksend to v11

This commit is contained in:
Evan Duffield 2014-12-22 19:28:52 -07:00
parent 692ec7c328
commit 67330fbb51
5 changed files with 1034 additions and 5 deletions

View File

@ -89,6 +89,7 @@ QT_FORMS_UI = \
forms/addressbookpage.ui \
forms/askpassphrasedialog.ui \
forms/coincontroldialog.ui \
forms/darksendconfig.ui \
forms/editaddressdialog.ui \
forms/helpmessagedialog.ui \
forms/intro.ui \
@ -115,6 +116,7 @@ QT_MOC_CPP = \
moc_coincontroldialog.cpp \
moc_coincontroltreewidget.cpp \
moc_csvmodelwriter.cpp \
moc_darksendconfig.cpp \
moc_editaddressdialog.cpp \
moc_guiutil.cpp \
moc_intro.cpp \
@ -177,6 +179,7 @@ BITCOIN_QT_H = \
coincontroldialog.h \
coincontroltreewidget.h \
csvmodelwriter.h \
darksendconfig.h \
editaddressdialog.h \
guiconstants.h \
guiutil.h \
@ -268,6 +271,7 @@ BITCOIN_QT_CPP = \
bitcoinunits.cpp \
clientmodel.cpp \
csvmodelwriter.cpp \
darksendconfig.cpp \
guiutil.cpp \
intro.cpp \
monitoreddatamapper.cpp \
@ -289,6 +293,7 @@ BITCOIN_QT_CPP += \
askpassphrasedialog.cpp \
coincontroldialog.cpp \
coincontroltreewidget.cpp \
darksendconfig.cpp \
editaddressdialog.cpp \
openuridialog.cpp \
overviewpage.cpp \

View File

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DarksendConfig</class>
<widget class="QDialog" name="DarksendConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>630</width>
<height>307</height>
</rect>
</property>
<property name="windowTitle">
<string>Configure Darksend+</string>
</property>
<widget class="QPushButton" name="buttonBasic">
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>151</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Basic Privacy</string>
</property>
</widget>
<widget class="QPushButton" name="buttonHigh">
<property name="geometry">
<rect>
<x>20</x>
<y>140</y>
<width>151</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>High Privacy</string>
</property>
</widget>
<widget class="QPushButton" name="buttonMax">
<property name="geometry">
<rect>
<x>20</x>
<y>210</y>
<width>151</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Maximum Privacy</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>30</x>
<y>20</y>
<width>571</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Please select an privacy level. </string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>190</x>
<y>70</y>
<width>421</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Use 2 separate masternodes to mix funds up to 1000DRK</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>190</x>
<y>140</y>
<width>411</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Use 4 separate masternodes to mix funds up to 1000DRK</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>190</x>
<y>210</y>
<width>421</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Use 8 separate masternodes</string>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>40</x>
<y>100</y>
<width>561</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>This option is the quickest and will cost about ~0.025DRK to anonymize 1000DRK</string>
</property>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>40</x>
<y>170</y>
<width>561</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>This option is moderately fast and will cost about 0.05DRK to anonymize 1000DRK</string>
</property>
</widget>
<widget class="QLabel" name="label_8">
<property name="geometry">
<rect>
<x>40</x>
<y>240</y>
<width>561</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>This is the slowest and most secure option. Using maximum anonymity will cost</string>
</property>
</widget>
<widget class="QLabel" name="label_9">
<property name="geometry">
<rect>
<x>40</x>
<y>260</y>
<width>561</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>0.1DRK per 1000DRK you anonymize.</string>
</property>
</widget>
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<width>601</width>
<height>16</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="line_2">
<property name="geometry">
<rect>
<x>10</x>
<y>190</y>
<width>601</width>
<height>16</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -254,6 +254,621 @@
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frameDarksend">
<property name="minimumSize">
<size>
<width>0</width>
<height>275</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>293</width>
<height>121</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="horizontalSpacing">
<number>12</number>
</property>
<property name="verticalSpacing">
<number>12</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="darksendEnabled">
<property name="text">
<string>Enabled/Disabled</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Completion:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QProgressBar" name="darksendProgress">
<property name="maximumSize">
<size>
<width>154</width>
<height>16777215</height>
</size>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelAnonymizedText">
<property name="text">
<string>Darksend Balance:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="labelAnonymized">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>0 DRK</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Amount and Rounds:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="labelAmountRounds">
<property name="text">
<string>1000 DRK / 8 Rounds</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>66</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Darksend</string>
</property>
</widget>
<widget class="QPushButton" name="runAutoDenom">
<property name="geometry">
<rect>
<x>251</x>
<y>17</y>
<width>1</width>
<height>1</height>
</rect>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>238</green>
<blue>238</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>246</green>
<blue>246</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>119</red>
<green>119</green>
<blue>119</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>159</green>
<blue>159</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>238</green>
<blue>238</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>246</green>
<blue>246</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>238</green>
<blue>238</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>246</green>
<blue>246</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>119</red>
<green>119</green>
<blue>119</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>159</green>
<blue>159</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>238</green>
<blue>238</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>246</green>
<blue>246</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>119</red>
<green>119</green>
<blue>119</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>238</green>
<blue>238</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>246</green>
<blue>246</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>119</red>
<green>119</green>
<blue>119</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>159</green>
<blue>159</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>119</red>
<green>119</green>
<blue>119</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>119</red>
<green>119</green>
<blue>119</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>238</green>
<blue>238</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>238</green>
<blue>238</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>238</green>
<blue>238</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="toggleDarksend">
<property name="geometry">
<rect>
<x>10</x>
<y>220</y>
<width>291</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Start/Stop Mixing</string>
</property>
</widget>
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>10</x>
<y>210</y>
<width>291</width>
<height>16</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="darksendStatus">
<property name="geometry">
<rect>
<x>10</x>
<y>170</y>
<width>288</width>
<height>43</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>288</width>
<height>43</height>
</size>
</property>
<property name="text">
<string>(Last Message)</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -8,15 +8,19 @@
#include "bitcoinunits.h"
#include "clientmodel.h"
#include "darksend.h"
#include "darksendconfig.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "transactionfilterproxy.h"
#include "transactiontablemodel.h"
#include "walletmodel.h"
#include "init.h"
#include <QAbstractItemDelegate>
#include <QPainter>
#include <QTimer>
#define DECORATION_SIZE 64
#define NUM_ITEMS 3
@ -117,10 +121,26 @@ OverviewPage::OverviewPage(QWidget *parent) :
connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex)));
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(darkSendStatus()));
timer->start(333);
// init "out of sync" warning labels
ui->labelWalletStatus->setText("(" + tr("out of sync") + ")");
ui->labelTransactionsStatus->setText("(" + tr("out of sync") + ")");
showingDarkSendMessage = 0;
darksendActionCheck = 0;
if(fMasterNode){
ui->toggleDarksend->setText("(Disabled)");
ui->toggleDarksend->setEnabled(false);
}else if(!fEnableDarksend){
ui->toggleDarksend->setText("Start Darksend Mixing");
} else {
ui->toggleDarksend->setText("Stop Darksend Mixing");
}
// start with displaying the "out of sync" warnings
showOutOfSyncWarning(true);
}
@ -136,15 +156,17 @@ OverviewPage::~OverviewPage()
delete ui;
}
void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance)
{
int unit = walletModel->getOptionsModel()->getDisplayUnit();
currentBalance = balance;
currentUnconfirmedBalance = unconfirmedBalance;
currentImmatureBalance = immatureBalance;
currentAnonymizedBalance = anonymizedBalance;
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance));
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, unconfirmedBalance));
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, immatureBalance));
ui->labelAnonymized->setText(BitcoinUnits::formatWithUnit(unit, anonymizedBalance));
ui->labelTotal->setText(BitcoinUnits::formatWithUnit(unit, balance + unconfirmedBalance + immatureBalance));
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
@ -183,10 +205,13 @@ void OverviewPage::setWalletModel(WalletModel *model)
ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress);
// Keep up to date with wallet
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance());
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64)));
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance());
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
connect(ui->runAutoDenom, SIGNAL(clicked()), this, SLOT(runDoAutomaticDenomination()));
connect(ui->toggleDarksend, SIGNAL(clicked()), this, SLOT(toggleDarksend()));
}
// update the display unit, to not use the default ("DRK")
@ -198,7 +223,7 @@ void OverviewPage::updateDisplayUnit()
if(walletModel && walletModel->getOptionsModel())
{
if(currentBalance != -1)
setBalance(currentBalance, currentUnconfirmedBalance, currentImmatureBalance);
setBalance(currentBalance, currentUnconfirmedBalance, currentImmatureBalance, currentAnonymizedBalance);
// Update txdelegate->unit with the current unit
txdelegate->unit = walletModel->getOptionsModel()->getDisplayUnit();
@ -218,3 +243,189 @@ void OverviewPage::showOutOfSyncWarning(bool fShow)
ui->labelWalletStatus->setVisible(fShow);
ui->labelTransactionsStatus->setVisible(fShow);
}
void OverviewPage::updateDarksendProgress(){
int64_t balance = pwalletMain->GetBalance();
if(balance == 0){
ui->darksendProgress->setValue(0);
QString s("No inputs detected");
ui->darksendProgress->setToolTip(s);
return;
}
std::ostringstream convert;
//Get average rounds of inputs
double a = ((double)pwalletMain->GetAverageAnonymizedRounds() / (double)nDarksendRounds)*100;
//Get the anon threshold
double max = nAnonymizeDarkcoinAmount;
//If it's more than the wallet amount, limit to that.
if(max > (double)(pwalletMain->GetBalance()/COIN)-1) max = (double)(pwalletMain->GetBalance()/COIN)-1;
//denominated balance / anon threshold -- the percentage that we've completed
double b = ((double)(pwalletMain->GetDenominatedBalance()/COIN) / max);
double val = a*b;
if(val < 0) val = 0;
if(val > 100) val = 100;
ui->darksendProgress->setValue(val);//rounds avg * denom progress
convert << "Inputs have an average of " << pwalletMain->GetAverageAnonymizedRounds() << " of " << nDarksendRounds << " rounds (" << a << "/" << b << ")";
QString s(convert.str().c_str());
ui->darksendProgress->setToolTip(s);
}
void OverviewPage::darkSendStatus()
{
int nBestHeight = chainActive.Tip()->nHeight;
if(nBestHeight != darkSendPool.cachedNumBlocks)
{
updateDarksendProgress();
std::ostringstream convert2;
convert2 << nAnonymizeDarkcoinAmount << " DRK / " << nDarksendRounds << " Rounds";
QString s2(convert2.str().c_str());
ui->labelAmountRounds->setText(s2);
}
if(!fEnableDarksend) {
if(nBestHeight != darkSendPool.cachedNumBlocks)
{
darkSendPool.cachedNumBlocks = nBestHeight;
ui->darksendEnabled->setText("Disabled");
ui->darksendStatus->setText("");
ui->toggleDarksend->setText("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;
if (pwalletMain->GetBalance() - pwalletMain->GetAnonymizedBalance() > 2*COIN){
if (walletModel->getEncryptionStatus() != WalletModel::Unencrypted){
if((nAnonymizeDarkcoinAmount*COIN)-pwalletMain->GetAnonymizedBalance() > 1.1*COIN &&
walletModel->getEncryptionStatus() == WalletModel::Locked){
WalletModel::UnlockContext ctx(walletModel->requestUnlock(false));
if(!ctx.isValid()){
//unlock was cancelled
fEnableDarksend = false;
darkSendPool.cachedNumBlocks = 0;
LogPrintf("Wallet is locked and user declined to unlock. Disabling Darksend.\n");
}
}
if((nAnonymizeDarkcoinAmount*COIN)-pwalletMain->GetAnonymizedBalance() <= 1.1*COIN &&
walletModel->getEncryptionStatus() == WalletModel::Unlocked &&
darkSendPool.GetMyTransactionCount() == 0){
LogPrintf("Darksend is complete, locking wallet.\n");
walletModel->setWalletLocked(true);
}
}
}
/* *******************************************************/
ui->darksendEnabled->setText("Enabled");
}
int state = darkSendPool.GetState();
int entries = darkSendPool.GetEntriesCount();
int accepted = darkSendPool.GetLastEntryAccepted();
std::ostringstream convert;
if(state == POOL_STATUS_ACCEPTING_ENTRIES) {
if(entries == 0) {
convert << "Darksend is idle";
showingDarkSendMessage = 0;
} else if (accepted == 1) {
convert << "Darksend request complete: Your transaction was accepted into the pool!";
if(showingDarkSendMessage % 10 > 8) {
darkSendPool.lastEntryAccepted = 0;
showingDarkSendMessage = 0;
}
} else {
if(showingDarkSendMessage % 70 <= 40) convert << "Submitted to masternode, entries " << entries << "/" << darkSendPool.GetMaxPoolTransactions();
else if(showingDarkSendMessage % 70 <= 50) convert << "Submitted to masternode, Waiting for more entries (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) .";
else if(showingDarkSendMessage % 70 <= 60) convert << "Submitted to masternode, Waiting for more entries (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) ..";
else if(showingDarkSendMessage % 70 <= 70) convert << "Submitted to masternode, Waiting for more entries (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) ...";
}
} else if(state == POOL_STATUS_SIGNING) {
if(showingDarkSendMessage % 70 <= 10) convert << "Found enough users, signing";
else if(showingDarkSendMessage % 70 <= 20) convert << "Found enough users, signing ( waiting. )";
else if(showingDarkSendMessage % 70 <= 30) convert << "Found enough users, signing ( waiting.. )";
else if(showingDarkSendMessage % 70 <= 40) convert << "Found enough users, signing ( waiting... )";
} else if(state == POOL_STATUS_TRANSMISSION) {
convert << "Transmitting final transaction";
} else if (state == POOL_STATUS_IDLE) {
convert << "Darksend is idle";
} else if (state == POOL_STATUS_FINALIZE_TRANSACTION) {
convert << "Finalizing transaction";
} else if(state == POOL_STATUS_ERROR) {
convert << "Darksend request incomplete: " << darkSendPool.lastMessage << ". Will retry...";
} else if(state == POOL_STATUS_SUCCESS) {
convert << "Darksend request complete: " << darkSendPool.lastMessage;
} else if(state == POOL_STATUS_QUEUE) {
if(showingDarkSendMessage % 70 <= 50) convert << "Submitted to masternode, waiting in queue .";
else if(showingDarkSendMessage % 70 <= 60) convert << "Submitted to masternode, waiting in queue ..";
else if(showingDarkSendMessage % 70 <= 70) convert << "Submitted to masternode, waiting in queue ...";
} else {
convert << "unknown state : id=" << state;
}
if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) darkSendPool.Check();
QString s(convert.str().c_str());
if(s != ui->darksendStatus->text())
LogPrintf("%s\n", convert.str().c_str());
ui->darksendStatus->setText(s);
showingDarkSendMessage++;
darksendActionCheck++;
// Get DarkSend Denomination Status
}
void OverviewPage::runDoAutomaticDenomination(){
darkSendPool.DoAutomaticDenominating();
}
void OverviewPage::toggleDarksend(){
int64_t balance = pwalletMain->GetBalance();
if(balance < 2.5*COIN){
QMessageBox::warning(this, tr("Darksend"),
tr("Darksend requires at least 2.5 DRK to use."),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
darkSendPool.cachedNumBlocks = 0;
fEnableDarksend = !fEnableDarksend;
if(!fEnableDarksend){
ui->toggleDarksend->setText("Start Darksend Mixing");
} else {
ui->toggleDarksend->setText("Stop Darksend Mixing");
/* show darksend configuration if client has defaults set */
if(nAnonymizeDarkcoinAmount == 0){
DarksendConfig dlg(this);
dlg.setModel(walletModel);
dlg.exec();
}
darkSendPool.DoAutomaticDenominating();
}
}

View File

@ -32,25 +32,35 @@ public:
void setClientModel(ClientModel *clientModel);
void setWalletModel(WalletModel *walletModel);
void showOutOfSyncWarning(bool fShow);
void updateDarksendProgress();
public slots:
void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance);
void darkSendStatus();
void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance);
signals:
void transactionClicked(const QModelIndex &index);
private:
QTimer *timer;
Ui::OverviewPage *ui;
ClientModel *clientModel;
WalletModel *walletModel;
qint64 currentBalance;
qint64 currentUnconfirmedBalance;
qint64 currentImmatureBalance;
qint64 currentAnonymizedBalance;
int showingDarkSendMessage;
int darksendActionCheck;
int cachedNumBlocks;
TxViewDelegate *txdelegate;
TransactionFilterProxy *filter;
private slots:
void runDoAutomaticDenomination();
void toggleDarksend();
void updateDisplayUnit();
void handleTransactionClicked(const QModelIndex &index);
void updateAlerts(const QString &warnings);