new version

This commit is contained in:
Evan Duffield 2014-08-06 10:58:24 -07:00
parent 8d7b8d167e
commit 0f7f3bd17a
9 changed files with 114 additions and 117 deletions

View File

@ -9,7 +9,7 @@
#define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 10 #define CLIENT_VERSION_MINOR 10
#define CLIENT_VERSION_REVISION 12 #define CLIENT_VERSION_REVISION 12
#define CLIENT_VERSION_BUILD 14 #define CLIENT_VERSION_BUILD 15
// Set to true for release, false for prerelease or test build // Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true #define CLIENT_VERSION_IS_RELEASE true

View File

@ -3941,13 +3941,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if(!darkSendPool.IsCompatibleWithSession(nAmount)) if(!darkSendPool.IsCompatibleWithSession(nAmount))
{ {
printf("dsi -- not compatible with existing transactions! \n"); printf("dsa -- not compatible with existing transactions! \n");
accepted = 0; accepted = 0;
error = "not compatible with existing transactions"; error = "not compatible with existing transactions";
pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error);
return true; return true;
} else { } else {
printf("dsi -- is compatible, please submit! \n"); printf("dsa -- is compatible, please submit! \n");
accepted = 1; accepted = 1;
pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error);
return true; return true;
@ -3967,7 +3967,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
int accepted = 0; int accepted = 0;
std::string error = ""; std::string error = "";
if(darkSendPool.IsCompatibleWithEntries(out)) if(!darkSendPool.IsCompatibleWithEntries(out))
{ {
printf("dsi -- not compatible with existing transactions! \n"); printf("dsi -- not compatible with existing transactions! \n");
accepted = 0; accepted = 0;
@ -4093,14 +4093,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
std::string error; std::string error;
vRecv >> sessionID >> state >> entriesCount >> accepted >> error; vRecv >> sessionID >> state >> entriesCount >> accepted >> error;
if(accepted != 1 && darkSendPool.sessionID != sessionID){ if((accepted != 1 && accepted != 0) && darkSendPool.sessionID != sessionID){
printf("dssu - message doesn't match current darksend session\n"); printf("dssu - message doesn't match current darksend session\n");
return false; return false;
} }
darkSendPool.StatusUpdate(state, entriesCount, accepted, error, sessionID); darkSendPool.StatusUpdate(state, entriesCount, accepted, error, sessionID);
printf("DarkSendStatusUpdate - state: %i entriesCount: %i accepted: %i error: %s \n", state, entriesCount, accepted, error.c_str());
} }
else if (strCommand == "dss") { //DarkSend Sign Final Tx else if (strCommand == "dss") { //DarkSend Sign Final Tx
@ -6018,13 +6017,15 @@ void CDarkSendPool::SetNull(bool clearEverything){
lastEntryAccepted = 0; lastEntryAccepted = 0;
countEntriesAccepted = 0; countEntriesAccepted = 0;
sessionUsers = 0;
sessionAmount = 0;
if(clearEverything){ if(clearEverything){
myEntries.clear(); myEntries.clear();
sessionID = 1 + (rand() % 999999); sessionID = 1 + (rand() % 999999);
sessionUsers = 0;
sessionAmount = 0;
sessionFoundMasternode = false;
sessionTries = 0;
} }
} }
@ -6149,10 +6150,12 @@ void CDarkSendPool::Check()
} }
if((state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) && GetTimeMillis()-lastTimeChanged >= 10000) { if((state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) && GetTimeMillis()-lastTimeChanged >= 10000) {
//bool runAgain = state == POOL_STATUS_SUCCESS;
printf("CDarkSendPool::Check() -- RESETTING MESSAGE \n"); printf("CDarkSendPool::Check() -- RESETTING MESSAGE \n");
SetNull(true); SetNull(true);
if(fMasterNode) RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), -1); if(fMasterNode) RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), -1);
UnlockCoins(); UnlockCoins();
//if(runAgain) DoAutomaticDenominating();
} }
} }
@ -6387,7 +6390,7 @@ bool CDarkSendPool::SignaturesComplete(){
return true; return true;
} }
void CDarkSendPool::SendMoney(const CTransaction& collateral, std::vector<CTxIn>& vin, std::vector<CTxOut>& vout, int64& fee, int64 amount, std::vector<int64> reservedKeysIn){ void CDarkSendPool::SendMoney(const CTransaction& collateral, std::vector<CTxIn>& vin, std::vector<CTxOut>& vout, int64& fee, int64 amount){
BOOST_FOREACH(CTxIn in, collateral.vin) BOOST_FOREACH(CTxIn in, collateral.vin)
lockedCoins.push_back(in); lockedCoins.push_back(in);
@ -6395,11 +6398,6 @@ void CDarkSendPool::SendMoney(const CTransaction& collateral, std::vector<CTxIn>
BOOST_FOREACH(CTxIn in, vin) BOOST_FOREACH(CTxIn in, vin)
lockedCoins.push_back(in); lockedCoins.push_back(in);
BOOST_FOREACH(int64 index, reservedKeysIn){
printf(" reserved key -- %"PRI64d"\n", index);
keypoolIndexes.push_back(index);
}
int i = darkSendPool.GetCurrentMasterNode(1); int i = darkSendPool.GetCurrentMasterNode(1);
if(i < 0) return; if(i < 0) return;
@ -6414,31 +6412,20 @@ void CDarkSendPool::SendMoney(const CTransaction& collateral, std::vector<CTxIn>
} }
printf("CDarkSendPool::SendMoney() - Added transaction to pool.\n"); printf("CDarkSendPool::SendMoney() - Added transaction to pool.\n");
if(fDebug){
printf("CDarkSendPool::SendMoney() -- NEW INPUT -- adding %s\n", vin[0].ToString().c_str());
}
ClearLastMessage(); ClearLastMessage();
printf("CDarkSendPool::SendMoney() - Is connected to masternode?.\n");
if(!IsConnectedToMasterNode()){ if(!IsConnectedToMasterNode()){
if(!ConnectToBestMasterNode()){ if(!ConnectToBestMasterNode()){
printf("CDarkSendPool::SendMoney() - Couldn't connect to masternode.\n");
return; return;
} }
} }
printf("CDarkSendPool::SendMoney() - connected to masternode.\n");
// store our entry for later use // store our entry for later use
CDarkSendEntry e; CDarkSendEntry e;
e.Add(vin, amount, collateral, vout); e.Add(vin, amount, collateral, vout);
myEntries.push_back(e); myEntries.push_back(e);
BOOST_FOREACH(const CTxIn& i, vin)
printf(" -- new input %s\n", i.ToString().c_str());
// relay our entry to the master node // relay our entry to the master node
RelayDarkSendIn(vin, amount, collateral, vout); RelayDarkSendIn(vin, amount, collateral, vout);
Check(); Check();
@ -6451,16 +6438,18 @@ bool CDarkSendPool::StatusUpdate(int newState, int newEntriesCount, int newAccep
UpdateState(newState); UpdateState(newState);
entriesCount = newEntriesCount; entriesCount = newEntriesCount;
printf("DarkSendStatusUpdate - state: %i entriesCount: %i accepted: %i error: %s \n", newState, newEntriesCount, newAccepted, error.c_str());
if(newState == POOL_STATUS_ACCEPTING_ENTRIES){ if(newState == POOL_STATUS_ACCEPTING_ENTRIES){
if(newAccepted == 1){ if(newAccepted == 1){
sessionID = newSessionID;
printf("CDarkSendPool::StatusUpdate - set sessionID to %d\n", sessionID);
printf("CDarkSendPool::StatusUpdate - entry accepted! \n"); printf("CDarkSendPool::StatusUpdate - entry accepted! \n");
sessionFoundMasternode = true; sessionFoundMasternode = true;
} else { DoAutomaticDenominating();
} else if (newAccepted == 0 && sessionID == 0 && !sessionFoundMasternode) {
printf("CDarkSendPool::StatusUpdate - entry not accepted by masternode \n"); printf("CDarkSendPool::StatusUpdate - entry not accepted by masternode \n");
DoAutomaticDenominating();
} }
DoAutomaticDenominating(); if(sessionFoundMasternode) return true;
} }
if(newAccepted != -1) { if(newAccepted != -1) {
@ -6470,6 +6459,12 @@ bool CDarkSendPool::StatusUpdate(int newState, int newEntriesCount, int newAccep
UpdateState(POOL_STATUS_ERROR); UpdateState(POOL_STATUS_ERROR);
lastMessage = error; lastMessage = error;
} }
if(newAccepted == 1) {
sessionID = newSessionID;
printf("CDarkSendPool::StatusUpdate - set sessionID to %d\n", sessionID);
sessionFoundMasternode = true;
}
} }
return true; return true;
@ -6951,14 +6946,7 @@ void CDarkSendPool::CompletedTransaction(bool error, std::string lastMessageNew)
if(fDebug) printf("CompletedTransaction -- success \n"); if(fDebug) printf("CompletedTransaction -- success \n");
UpdateState(POOL_STATUS_SUCCESS); UpdateState(POOL_STATUS_SUCCESS);
BOOST_FOREACH(const int64 index, keypoolIndexes) {
CReserveKey reservekey(pwalletMain);
reservekey.SetIndex(index);
reservekey.KeepKey();
}
myEntries.clear(); myEntries.clear();
DoAutomaticDenominating();
} }
lastMessage = lastMessageNew; lastMessage = lastMessageNew;
@ -7061,18 +7049,21 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun)
return false; return false;
} }
int64 balanceNeedsAnonymized = pwalletMain->GetBalance() - pwalletMain->GetAnonymizedBalance();
if(balanceNeedsAnonymized < COIN*1.1){
printf("DoAutomaticDenominating : No funds detected in need of denominating \n");
return false;
}
// ** find the coins we'll use // ** find the coins we'll use
std::vector<CTxIn> vCoins; std::vector<CTxIn> vCoins;
int64 nValueMin = 0.01*COIN; int64 nValueMin = 0.01*COIN;
int64 nValueMax = 999*COIN; int64 nValueMax = 999*COIN;
int64 nValueIn = 0; int64 nValueIn = 0;
int64 balanceNeedsAnonymized = pwalletMain->GetBalance() - pwalletMain->GetAnonymizedBalance();
if(balanceNeedsAnonymized < COIN*1.1){
printf("DoAutomaticDenominating : No funds detected in need of denominating \n");
return false;
}
if(balanceNeedsAnonymized > nValueMax){
balanceNeedsAnonymized = nValueMax;
}
if (!pwalletMain->SelectCoinsDark(nValueMin, nValueMax, vCoins, nValueIn, -2, nDarksendRounds)) if (!pwalletMain->SelectCoinsDark(nValueMin, nValueMax, vCoins, nValueIn, -2, nDarksendRounds))
{ {
nValueIn = 0; nValueIn = 0;
@ -7107,20 +7098,26 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun)
// initial phase, find a masternode // initial phase, find a masternode
if(!sessionFoundMasternode){ if(!sessionFoundMasternode){
if(sessionTries++ < 10){ if(sessionTries++ < 10){
int i = GetMasternodeByRank(rand() % 20); int i = GetMasternodeByRank(rand() % 1+(std::min(20, (int)darkSendMasterNodes.size())));
if(i != -1) { if(i == -1) {
if(ConnectNode((CAddress)darkSendMasterNodes[i].addr, NULL, true)){ printf("DoAutomaticDenominating : Error finding a masternode\n");
submittedToMasternode = darkSendMasterNodes[i].addr; return false;
LOCK(cs_vNodes); }
BOOST_FOREACH(CNode* pnode, vNodes)
{ lastTimeChanged = GetTimeMillis();
if(darkSendMasterNodes[i].addr != pnode->addr) continue; printf("DoAutomaticDenominating -- attempt connection to masternode %s\n", darkSendMasterNodes[i].addr.ToString().c_str());
pnode->PushMessage("dsa", balanceNeedsAnonymized); if(ConnectNode((CAddress)darkSendMasterNodes[i].addr, NULL, true)){
return true; submittedToMasternode = darkSendMasterNodes[i].addr;
} LOCK(cs_vNodes);
} else { BOOST_FOREACH(CNode* pnode, vNodes)
return DoAutomaticDenominating(); {
if(darkSendMasterNodes[i].addr != pnode->addr) continue;
pnode->PushMessage("dsa", balanceNeedsAnonymized);
printf(" --- connected, sending dsa for %"PRI64d"\n", balanceNeedsAnonymized);
return true;
} }
} else {
return DoAutomaticDenominating();
} }
} }
} }
@ -7228,6 +7225,7 @@ int CDarkSendPool::GetMasternodeByRank(int findRank)
memcpy(&n2, &n, sizeof(n2)); memcpy(&n2, &n, sizeof(n2));
vecMasternodeScores.push_back(make_pair(n2, i)); vecMasternodeScores.push_back(make_pair(n2, i));
i++;
} }
sort(vecMasternodeScores.rbegin(), vecMasternodeScores.rend(), CompareValueOnly2()); sort(vecMasternodeScores.rbegin(), vecMasternodeScores.rend(), CompareValueOnly2());

View File

@ -2583,7 +2583,7 @@ static const int64 DARKSEND_FEE = 0.001*COIN;
class CDarkSendPool class CDarkSendPool
{ {
public: public:
static const int MIN_PEER_PROTO_VERSION = 70026; static const int MIN_PEER_PROTO_VERSION = 70027;
std::vector<CDarkSendEntry> myEntries; std::vector<CDarkSendEntry> myEntries;
std::vector<CDarkSendEntry> entries; std::vector<CDarkSendEntry> entries;
@ -2599,7 +2599,6 @@ public:
CScript collateralPubKey; CScript collateralPubKey;
std::vector<CTxIn> lockedCoins; std::vector<CTxIn> lockedCoins;
std::vector<int64> keypoolIndexes;
CTxIn vinMasterNode; CTxIn vinMasterNode;
CPubKey pubkeyMasterNode; CPubKey pubkeyMasterNode;
@ -2729,7 +2728,7 @@ public:
bool AddEntry(const std::vector<CTxIn>& newInput, const int64& nAmount, const CTransaction& txCollateral, const std::vector<CTxOut>& newOutput, std::string& error); bool AddEntry(const std::vector<CTxIn>& newInput, const int64& nAmount, const CTransaction& txCollateral, const std::vector<CTxOut>& newOutput, std::string& error);
bool AddScriptSig(const CTxIn& newVin); bool AddScriptSig(const CTxIn& newVin);
bool SignaturesComplete(); bool SignaturesComplete();
void SendMoney(const CTransaction& collateral, std::vector<CTxIn>& vin, std::vector<CTxOut>& vout, int64& fee, int64 amount, std::vector<int64> reservedKeysIn); void SendMoney(const CTransaction& collateral, std::vector<CTxIn>& vin, std::vector<CTxOut>& vout, int64& fee, int64 amount);
bool StatusUpdate(int newState, int newEntriesCount, int newAccepted, std::string& error, int newSessionID=0); bool StatusUpdate(int newState, int newEntriesCount, int newAccepted, std::string& error, int newSessionID=0);
bool SignFinalTransaction(CTransaction& finalTransactionNew, CNode* node); bool SignFinalTransaction(CTransaction& finalTransactionNew, CNode* node);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>920</width> <width>1024</width>
<height>410</height> <height>457</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -625,8 +625,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>900</width> <width>1004</width>
<height>162</height> <height>209</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -702,32 +702,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="darkSendStatusButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Create inputs compatible with DarkSend</string>
</property>
<property name="text">
<string>DarkSendStatus</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/denominate</normaloff>:/icons/denominate</iconset>
</property>
<property name="autoRepeatDelay">
<number>300</number>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QComboBox" name="inputType"> <widget class="QComboBox" name="inputType">
<property name="minimumSize"> <property name="minimumSize">
@ -758,6 +732,38 @@
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
</property> </property>
<item>
<widget class="QLabel" name="darkSendStatus">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Darksend Status</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">

View File

@ -29,7 +29,7 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
ui->addButton->setIcon(QIcon()); ui->addButton->setIcon(QIcon());
ui->clearButton->setIcon(QIcon()); ui->clearButton->setIcon(QIcon());
ui->darkSendStatusButton->setIcon(QIcon()); ui->darkSendStatus->setIcon(QIcon());
ui->sendButton->setIcon(QIcon()); ui->sendButton->setIcon(QIcon());
#endif #endif
#if QT_VERSION >= 0x040700 #if QT_VERSION >= 0x040700
@ -41,7 +41,6 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry()));
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
connect(ui->darkSendStatusButton, SIGNAL(clicked()), this, SLOT(darkSendStatusButton()));
// Coin Control // Coin Control
ui->lineEditCoinControlChange->setFont(GUIUtil::bitcoinAddressFont()); ui->lineEditCoinControlChange->setFont(GUIUtil::bitcoinAddressFont());
@ -50,7 +49,7 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &))); connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &)));
timer = new QTimer(this); timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(darkSendStatusButton())); connect(timer, SIGNAL(timeout()), this, SLOT(darkSendStatus()));
timer->start(333); timer->start(333);
// Coin Control: clipboard actions // Coin Control: clipboard actions
@ -260,7 +259,7 @@ void SendCoinsDialog::clear()
ui->sendButton->setDefault(true); ui->sendButton->setDefault(true);
} }
void SendCoinsDialog::darkSendStatusButton() void SendCoinsDialog::darkSendStatus()
{ {
// check darksend status and unlock if needed // check darksend status and unlock if needed
if(darksendActionCheck % 30 == 0){ if(darksendActionCheck % 30 == 0){
@ -325,10 +324,13 @@ void SendCoinsDialog::darkSendStatusButton()
if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) darkSendPool.Check(); if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) darkSendPool.Check();
printf("%s\n", convert.str().c_str());
QString s(convert.str().c_str()); QString s(convert.str().c_str());
ui->darkSendStatusButton->setText(s);
if(s != ui->darkSendStatus->text())
printf("%s\n", convert.str().c_str());
ui->darkSendStatus->setText(s);
showingDarkSendMessage++; showingDarkSendMessage++;
darksendActionCheck++; darksendActionCheck++;
@ -481,7 +483,7 @@ void SendCoinsDialog::setState(int state, int entries, int accepted)
if(!model || !model->getOptionsModel()) if(!model || !model->getOptionsModel())
return; return;
ui->darkSendStatusButton->setText("Status Updated"); ui->darkSendStatus->setText("Status Updated");
} }
void SendCoinsDialog::updateDisplayUnit() void SendCoinsDialog::updateDisplayUnit()

View File

@ -37,7 +37,7 @@ public:
public slots: public slots:
void clear(); void clear();
void darkSendStatusButton(); void darkSendStatus();
void reject(); void reject();
void accept(); void accept();
SendCoinsEntry *addEntry(); SendCoinsEntry *addEntry();

View File

@ -237,7 +237,7 @@ bool IsCanonicalPubKey(const valtype &vchPubKey) {
if (vchPubKey.size() != 33) if (vchPubKey.size() != 33)
return error("Non-canonical public key: invalid length for compressed key"); return error("Non-canonical public key: invalid length for compressed key");
} else { } else {
return error("Non-canonical public key: compressed nor uncompressed : size %d", vchPubKey.size()); return error("Non-canonical public key: compressed nor uncompressed : size %d", (int)vchPubKey.size());
} }
return true; return true;
} }

View File

@ -25,7 +25,7 @@ extern const std::string CLIENT_DATE;
// network protocol versioning // network protocol versioning
// //
static const int PROTOCOL_VERSION = 70026; static const int PROTOCOL_VERSION = 70027;
// intial proto version, to be increased after version/verack negotiation // intial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209; static const int INIT_PROTO_VERSION = 209;

View File

@ -1321,13 +1321,13 @@ bool CWallet::SelectCoinsDark(int64 nValueMin, int64 nValueMax, std::vector<CTxI
vector<COutput> vCoins; vector<COutput> vCoins;
AvailableCoins(vCoins, false, coinControl, ALL_COINS); AvailableCoins(vCoins, false, coinControl, ALL_COINS);
printf("found coins %d\n", (int)vCoins.size()); //printf("found coins %d\n", (int)vCoins.size());
set<pair<const CWalletTx*,unsigned int> > setCoinsRet2; set<pair<const CWalletTx*,unsigned int> > setCoinsRet2;
BOOST_FOREACH(const COutput& out, vCoins) BOOST_FOREACH(const COutput& out, vCoins)
{ {
printf(" vin nValue %"PRI64d" \n", out.tx->vout[out.i].nValue); //printf(" vin nValue %"PRI64d" \n", out.tx->vout[out.i].nValue);
if(out.tx->vout[out.i].nValue <= DARKSEND_COLLATERAL*5) continue; //these are made for collateral/fees/etc if(out.tx->vout[out.i].nValue <= DARKSEND_COLLATERAL*5) continue; //these are made for collateral/fees/etc
if(fMasterNode && out.tx->vout[out.i].nValue == 1000*COIN) continue; //masternode input if(fMasterNode && out.tx->vout[out.i].nValue == 1000*COIN) continue; //masternode input
@ -1335,17 +1335,17 @@ bool CWallet::SelectCoinsDark(int64 nValueMin, int64 nValueMax, std::vector<CTxI
CTxIn vin = CTxIn(out.tx->GetHash(),out.i); CTxIn vin = CTxIn(out.tx->GetHash(),out.i);
int rounds = darkSendPool.GetInputDarksendRounds(vin); int rounds = darkSendPool.GetInputDarksendRounds(vin);
printf(" -- rounds %d\n", rounds); //printf(" -- rounds %d\n", rounds);
if(rounds >= nDarksendRoundsMax) continue; if(rounds >= nDarksendRoundsMax) continue;
printf(" -- rounds less than max\n"); //printf(" -- rounds less than max\n");
if(rounds < nDarksendRoundsMin) continue; if(rounds < nDarksendRoundsMin) continue;
vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey
nValueRet += out.tx->vout[out.i].nValue; nValueRet += out.tx->vout[out.i].nValue;
setCoinsRet.push_back(vin); setCoinsRet.push_back(vin);
setCoinsRet2.insert(make_pair(out.tx, out.i)); setCoinsRet2.insert(make_pair(out.tx, out.i));
printf(" -- nValueRet %"PRI64d"\n", nValueRet/COIN); //printf(" -- nValueRet %"PRI64d"\n", nValueRet/COIN);
if(nValueRet >= nValueMax) return true; if(nValueRet >= nValueMax) return true;
} }
} }
@ -1743,7 +1743,6 @@ string CWallet::DarkSendDenominate()
// calculate total value out // calculate total value out
int64 nTotalValue = 0; int64 nTotalValue = 0;
std::vector<int64> reservedKeys;
CWalletTx wtx; CWalletTx wtx;
BOOST_FOREACH(CTxIn i, vCoins){ BOOST_FOREACH(CTxIn i, vCoins){
if (mapWallet.count(i.prevout.hash)) if (mapWallet.count(i.prevout.hash))
@ -1779,9 +1778,7 @@ string CWallet::DarkSendDenominate()
CPubKey vchPubKey; CPubKey vchPubKey;
assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked
scriptChange.SetDestination(vchPubKey.GetID()); scriptChange.SetDestination(vchPubKey.GetID());
reservekey.ReserveKey(); reservekey.KeepKey();
reservedKeys.push_back(reservekey.GetIndex());
reservekey.Reset();
CTxOut vout2 = CTxOut(DARKSEND_COLLATERAL, darkSendPool.collateralPubKey); CTxOut vout2 = CTxOut(DARKSEND_COLLATERAL, darkSendPool.collateralPubKey);
@ -1824,9 +1821,7 @@ string CWallet::DarkSendDenominate()
CPubKey vchPubKey; CPubKey vchPubKey;
assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked
scriptChange.SetDestination(vchPubKey.GetID()); scriptChange.SetDestination(vchPubKey.GetID());
reservekey.ReserveKey(); reservekey.KeepKey();
reservedKeys.push_back(reservekey.GetIndex());
reservekey.Reset();
CTxOut o(v, scriptChange); CTxOut o(v, scriptChange);
vOut.push_back(o); vOut.push_back(o);
@ -1846,10 +1841,7 @@ string CWallet::DarkSendDenominate()
CPubKey vchPubKey; CPubKey vchPubKey;
assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked
scriptChange.SetDestination(vchPubKey.GetID()); scriptChange.SetDestination(vchPubKey.GetID());
reservekey.ReserveKey(); reservekey.KeepKey();
reservedKeys.push_back(reservekey.GetIndex());
reservekey.Reset();
CTxOut o(nValueLeft, scriptChange); CTxOut o(nValueLeft, scriptChange);
vOut.push_back(o); vOut.push_back(o);
@ -1857,7 +1849,7 @@ string CWallet::DarkSendDenominate()
nOutputs++; nOutputs++;
} }
darkSendPool.SendMoney(txCollateral, vCoins, vOut, nFeeRet, nValueIn, reservedKeys); darkSendPool.SendMoney(txCollateral, vCoins, vOut, nFeeRet, nValueIn);
return ""; return "";
} }