added denomination information to overview, reset/try again buttons

This commit is contained in:
Evan Duffield 2014-12-27 16:45:07 -07:00
parent ff8285060d
commit 3acb5c6388
5 changed files with 121 additions and 17 deletions

View File

@ -1144,6 +1144,8 @@ void CDarkSendPool::SendDarksendDenominate(std::vector<CTxIn>& vin, std::vector<
e.Add(vin, amount, txCollateral, vout);
myEntries.push_back(e);
GetDenominationsToString(GetDenominations(vout), SubmittedDenom);
// relay our entry to the master node
RelayDarkSendIn(vin, amount, txCollateral, vout);
Check();
@ -1883,6 +1885,45 @@ bool CDarkSendPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txColla
return true;
}
//create a nice string to show the denominations
void CDarkSendPool::GetDenominationsToString(int nDenom, std::string& strDenom){
// Function returns as follows:
//
// bit 0 - 100DRK+1 ( bit on if present )
// bit 1 - 10DRK+1
// bit 2 - 1DRK+1
// bit 2 - .1DRK+1
// bit 3 - non-denom
strDenom = "";
if(nDenom & (1 << 0)) {
if(strDenom.size() > 0) strDenom += "+";
strDenom += "100";
}
if(nDenom & (1 << 1)) {
if(strDenom.size() > 0) strDenom += "+";
strDenom += "10";
}
if(nDenom & (1 << 2)) {
if(strDenom.size() > 0) strDenom += "+";
strDenom += "1";
}
if(nDenom & (1 << 3)) {
if(strDenom.size() > 0) strDenom += "+";
strDenom += "0.1";
}
if(nDenom & (1 << 4)) {
if(strDenom.size() > 0) strDenom += "+";
strDenom += "ND";
}
}
// return a bitshifted integer representing the denominations in this list
int CDarkSendPool::GetDenominations(const std::vector<CTxOut>& vout){
std::vector<pair<int64_t, int> > denomUsed;
@ -1918,12 +1959,11 @@ int CDarkSendPool::GetDenominations(const std::vector<CTxOut>& vout){
// Function returns as follows:
//
// bit 0 - 500DRK+1 ( bit on if present )
// bit 1 - 100DRK+1
// bit 2 - 10DRK+1
// bit 3 - 1DRK+1
// bit 4 - fee
// bit 5 - other sizes
// bit 0 - 100DRK+1 ( bit on if present )
// bit 1 - 10DRK+1
// bit 2 - 1DRK+1
// bit 3 - .1DRK+1
// bit 4 - non-denom
return denom;
}

View File

@ -267,6 +267,9 @@ public:
int minBlockSpacing; //required blocks between mixes
CTransaction txCollateral;
//debugging data
std::string SubmittedDenom;
std::vector<int64_t> vecDisabledDenominations;
//incremented whenever a DSQ comes through
@ -293,6 +296,7 @@ public:
minBlockSpacing = 1;
nDsqCount = 0;
vecDisabledDenominations.clear();
SubmittedDenom = "";
SetCollateralAddress(strAddress);
SetNull();
@ -420,6 +424,7 @@ public:
bool SplitUpMoney(bool justCollateral=false);
// get the denominations for a list of outputs (returns a bitshifted integer)
int GetDenominations(const std::vector<CTxOut>& vout);
void GetDenominationsToString(int nDenom, std::string& strDenom);
// get the denominations for a specific amount of darkcoin.
int GetDenominationsByAmount(int64_t nAmount);
int GetDenominationsByAmounts(std::vector<int64_t>& vecAmount);

View File

@ -259,7 +259,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>275</height>
<height>350</height>
</size>
</property>
<property name="layoutDirection">
@ -277,7 +277,7 @@
<x>10</x>
<y>40</y>
<width>293</width>
<height>121</height>
<height>161</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
@ -358,6 +358,20 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Submitted Denom</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_10">
<property name="text">
<string></string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label_2">
@ -820,8 +834,8 @@
<property name="geometry">
<rect>
<x>10</x>
<y>220</y>
<width>291</width>
<y>296</y>
<width>191</width>
<height>51</height>
</rect>
</property>
@ -833,7 +847,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>210</y>
<y>200</y>
<width>291</width>
<height>16</height>
</rect>
@ -846,9 +860,9 @@
<property name="geometry">
<rect>
<x>10</x>
<y>170</y>
<y>220</y>
<width>288</width>
<height>43</height>
<height>61</height>
</rect>
</property>
<property name="minimumSize">
@ -867,6 +881,35 @@
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="darksendAuto">
<property name="geometry">
<rect>
<x>200</x>
<y>296</y>
<width>96</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Try Mix</string>
</property>
</widget>
<widget class="QPushButton" name="darksendReset">
<property name="geometry">
<rect>
<x>200</x>
<y>320</y>
<width>96</width>
<height>27</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</widget>
</item>
<item>

View File

@ -210,7 +210,8 @@ void OverviewPage::setWalletModel(WalletModel *model)
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
connect(ui->runAutoDenom, SIGNAL(clicked()), this, SLOT(runDoAutomaticDenomination()));
connect(ui->darksendAuto, SIGNAL(clicked()), this, SLOT(darksendAuto()));
connect(ui->darksendReset, SIGNAL(clicked()), this, SLOT(darksendReset()));
connect(ui->toggleDarksend, SIGNAL(clicked()), this, SLOT(toggleDarksend()));
}
@ -407,16 +408,30 @@ void OverviewPage::darkSendStatus()
ui->darksendStatus->setText(s);
std::string out;
darkSendPool.GetDenominationsToString(darkSendPool.sessionDenom, out);
QString s2(out.c_str());
ui->label_10->setText(s2);
showingDarkSendMessage++;
darksendActionCheck++;
// Get DarkSend Denomination Status
}
void OverviewPage::runDoAutomaticDenomination(){
void OverviewPage::darksendAuto(){
darkSendPool.DoAutomaticDenominating();
}
void OverviewPage::darksendReset(){
darkSendPool.SetNull(true);
QMessageBox::warning(this, tr("Darksend"),
tr("Darksend was successfully reset."),
QMessageBox::Ok, QMessageBox::Ok);
}
void OverviewPage::toggleDarksend(){
if(!fEnableDarksend){
int64_t balance = pwalletMain->GetBalance();

View File

@ -54,13 +54,14 @@ private:
int showingDarkSendMessage;
int darksendActionCheck;
int cachedNumBlocks;
TxViewDelegate *txdelegate;
TransactionFilterProxy *filter;
private slots:
void runDoAutomaticDenomination();
void toggleDarksend();
void darksendAuto();
void darksendReset();
void updateDisplayUnit();
void handleTransactionClicked(const QModelIndex &index);
void updateAlerts(const QString &warnings);