diff --git a/src/main.cpp b/src/main.cpp index 058db4467b..ec7bcda6d4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2829,11 +2829,13 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl mapOrphanBlocksByPrev.erase(hashPrev); } - //might need to reset pool + printf("ProcessBlock: ACCEPTED\n"); + darkSendPool.CheckTimeout(); + + printf("Darksend NewBlock\n"); darkSendPool.NewBlock(); - printf("ProcessBlock: ACCEPTED\n"); if (pfrom && !CSyncCheckpoint::strMasterPrivKey.empty() && (int)GetArg("-checkpointdepth", -1) >= 0) @@ -5289,10 +5291,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) printf("%d\n", scriptPubKeyIn[0]); - // start masternode payments - bool bMasterNodePayment = false; // fees to foundation @@ -6808,10 +6808,11 @@ bool CDarkSendPool::DoConcessusVote(int64 nBlockHeight) void CDarkSendPool::NewBlock() { - if(fDisableDarksend) return; + if(fDebug) printf("CDarkSendPool::NewBlock \n"); + if(IsInitialBlockDownload()) return; - if(fDebug) printf("CDarkSendPool::NewBlock \n"); + printf("CDarkSendPool::NewBlock - 2\n"); { LOCK2(cs_main, mempool.cs); @@ -6828,10 +6829,14 @@ void CDarkSendPool::NewBlock() } } + printf("CDarkSendPool::NewBlock - 3\n"); + //send votes for next block and one after that DoConcessusVote(pindexBest->nHeight + 2); DoConcessusVote(pindexBest->nHeight + 3); } + + if(fDisableDarksend) return; if(!fMasterNode){ //denominate all non-denominated inputs every 25 minutes. @@ -7065,7 +7070,6 @@ bool CDarkSendPool::SplitUpMoney(bool justCollateral) nTotalOut += (a) + (a/5); } vecSend.push_back(make_pair(scriptChange, DARKSEND_COLLATERAL*5)); - vecSend.push_back(make_pair(scriptChange, DARKSEND_FEE*5)); nTotalOut += (DARKSEND_COLLATERAL*5)+(DARKSEND_FEE*5); } @@ -7073,10 +7077,10 @@ bool CDarkSendPool::SplitUpMoney(bool justCollateral) printf(" auto2-- nTotalOut %"PRI64d"\n", nTotalOut); if(!justCollateral){ - if(nTotalOut <= 1.1*COIN || vecSend.size() < 4) + if(nTotalOut <= 1.1*COIN || vecSend.size() < 3) return false; } else { - if(nTotalOut <= 0.1*COIN || vecSend.size() < 2) + if(nTotalOut <= 0.1*COIN || vecSend.size() < 1) return false; } diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index f10d56d4b0..0e291702f3 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -103,7 +103,7 @@ - Balance: + Total Balance: @@ -129,14 +129,14 @@ - + Unconfirmed: - + @@ -158,14 +158,27 @@ - - + + - Immature: + Anonymized - + + + + + 75 + true + + + + 0 DRK + + + + @@ -184,6 +197,13 @@ + + + + Immature: + + + diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index 537828f215..95cef08d79 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 883 - 401 + 920 + 410 @@ -625,8 +625,8 @@ 0 0 - 863 - 153 + 900 + 162 @@ -732,23 +732,23 @@ - 155 + 175 0 - Only DS+ Inputs + Use Anonymous Funds - Only Non DS+ Inputs + Use Non-Anonymous Funds - All Inputs + No Preference diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index ad2d682b7b..113bd19a02 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -131,15 +131,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)); // only show immature (newly mined) balance if it's non-zero, so as not to complicate things // for the non-mining users @@ -176,8 +178,8 @@ 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())); } @@ -191,7 +193,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(); diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 59ba3c66bb..93c2fd3491 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -29,7 +29,7 @@ public: void showOutOfSyncWarning(bool fShow); public slots: - void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance); + void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance); signals: void transactionClicked(const QModelIndex &index); @@ -41,6 +41,7 @@ private: qint64 currentBalance; qint64 currentUnconfirmedBalance; qint64 currentImmatureBalance; + qint64 currentAnonymizedBalance; TxViewDelegate *txdelegate; TransactionFilterProxy *filter; diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 6be678d59b..6ca6ae3ee0 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -98,8 +98,8 @@ void SendCoinsDialog::setModel(WalletModel *model) } if(model && model->getOptionsModel()) { - 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())); // Coin Control @@ -145,26 +145,31 @@ void SendCoinsDialog::on_sendButton_clicked() return; } + QString funds = "Using Anonymous Funds"; + recipients[0].inputType = "ONLY_DENOMINATED"; + + if(ui->inputType->currentText() == "Use Anonymous Funds"){ + recipients[0].inputType = "ONLY_NONDENOMINATED"; + funds = "Using Anonymous Funds"; + } else if(ui->inputType->currentText() == "Use Non-Anonymous Funds"){ + recipients[0].inputType = "ONLY_DENOMINATED"; + funds = "Using NON-ANONYMOUS Funds"; + } else { + recipients[0].inputType = "ALL_COINS"; + funds = "Using ANY AVAILABLE Funds"; + } + // Format confirmation message QStringList formatted; foreach(const SendCoinsRecipient &rcp, recipients) { #if QT_VERSION < 0x050000 - formatted.append(tr("%1 to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address)); + formatted.append(tr("%1 to %2 (%3) using %4").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address, funds)); #else - formatted.append(tr("%1 to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), rcp.label.toHtmlEscaped(), rcp.address)); + formatted.append(tr("%1 to %2 (%3) using %4").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), rcp.label.toHtmlEscaped(), rcp.address, funds)); #endif } - recipients[0].inputType = "ONLY_DENOMINATED"; - - if(ui->inputType->currentText() == "Only Non DS+ Inputs"){ - recipients[0].inputType = "ONLY_NONDENOMINATED"; - } else if(ui->inputType->currentText() == "Only DS+ Inputs"){ - recipients[0].inputType = "ONLY_DENOMINATED"; - } else { - recipients[0].inputType = "ALL_COINS"; - } fNewRecipientAllowed = false; @@ -457,10 +462,11 @@ bool SendCoinsDialog::handleURI(const QString &uri) return false; } -void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance) +void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance) { Q_UNUSED(unconfirmedBalance); Q_UNUSED(immatureBalance); + Q_UNUSED(anonymizedBalance); if(!model || !model->getOptionsModel()) return; diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 8f2165dbd5..30d79dc27d 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -42,7 +42,7 @@ public slots: void accept(); SendCoinsEntry *addEntry(); void updateRemoveEnabled(); - void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance); + void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance); void setState(int state, int entries, int accepted); private: diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index c15dfc0f4b..72c040f538 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -52,6 +52,12 @@ qint64 WalletModel::getBalance(const CCoinControl *coinControl) const return wallet->GetBalance(); } + +qint64 WalletModel::getAnonymizedBalance() const +{ + return wallet->GetAnonymizedBalance(); +} + qint64 WalletModel::getUnconfirmedBalance() const { return wallet->GetUnconfirmedBalance(); @@ -97,13 +103,15 @@ void WalletModel::checkBalanceChanged() qint64 newBalance = getBalance(); qint64 newUnconfirmedBalance = getUnconfirmedBalance(); qint64 newImmatureBalance = getImmatureBalance(); + qint64 newAnonymizedBalance = getAnonymizedBalance(); if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance) { cachedBalance = newBalance; cachedUnconfirmedBalance = newUnconfirmedBalance; cachedImmatureBalance = newImmatureBalance; - emit balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance); + cachedAnonymizedBalance = newAnonymizedBalance; + emit balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance, newAnonymizedBalance); } } diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index ec7f66b0a0..a2d5647f58 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -65,6 +65,7 @@ public: TransactionTableModel *getTransactionTableModel(); qint64 getBalance(const CCoinControl *coinControl=NULL) const; + qint64 getAnonymizedBalance() const; qint64 getUnconfirmedBalance() const; qint64 getImmatureBalance() const; int getNumTransactions() const; @@ -142,6 +143,7 @@ private: qint64 cachedBalance; qint64 cachedUnconfirmedBalance; qint64 cachedImmatureBalance; + qint64 cachedAnonymizedBalance; qint64 cachedNumTransactions; EncryptionStatus cachedEncryptionStatus; int cachedNumBlocks; @@ -154,7 +156,7 @@ private: signals: // Signal that balance in wallet changed - void balanceChanged(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance); + void balanceChanged(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance); // Number of transactions in wallet changed void numTransactionsChanged(int count); diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 82b0347d33..a66d9de696 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -75,6 +75,7 @@ Value getinfo(const Array& params, bool fHelp) if (pwalletMain) { obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); + obj.push_back(Pair("anonymized_balance", ValueFromAmount(pwalletMain->GetAnonymizedBalance()))); } obj.push_back(Pair("blocks", (int)nBestHeight)); obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset())); diff --git a/src/wallet.cpp b/src/wallet.cpp index 1947f2fc72..25ba0cab30 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -957,6 +957,32 @@ int64 CWallet::GetBalance() const return nTotal; } +int64 CWallet::GetAnonymizedBalance() const +{ + int64 nTotal = 0; + { + LOCK(cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (pcoin->IsConfirmed()){ + bool found = false; + for (unsigned int i = 0; i < pcoin->vout.size(); i++) { + + COutput out = COutput(pcoin, i, pcoin->GetDepthInMainChain()); + CTxIn vin = CTxIn(out.tx->GetHash(), out.i); + int rounds = darkSendPool.GetInputDarksendRounds(vin); + if(rounds >= nDarksendRounds) found = true; + } + + if(found) nTotal += pcoin->GetAvailableCredit(); + } + } + } + + return nTotal; +} + int64 CWallet::GetNonDenominatedBalance() const { int64 nTotal = 0; diff --git a/src/wallet.h b/src/wallet.h index ee8f3396eb..0acc6561ad 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -193,6 +193,7 @@ public: void ReacceptWalletTransactions(); void ResendWalletTransactions(); int64 GetBalance() const; + int64 GetAnonymizedBalance() const; int64 GetNonDenominatedBalance() const; int64 GetUnconfirmedBalance() const; int64 GetImmatureBalance() const;