mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge pull request #134 from UdjinM6/fix_creating_denominated
fixing pre-mix process of creation denominated amounts
This commit is contained in:
commit
1598d8e7a6
125
src/darksend.cpp
125
src/darksend.cpp
@ -1394,7 +1394,6 @@ void CDarkSendPool::CompletedTransaction(bool error, std::string lastMessageNew)
|
|||||||
|
|
||||||
// To avoid race conditions, we'll only let DS run once per block
|
// To avoid race conditions, we'll only let DS run once per block
|
||||||
cachedLastSuccess = chainActive.Tip()->nHeight;
|
cachedLastSuccess = chainActive.Tip()->nHeight;
|
||||||
splitUpInARow = 0;
|
|
||||||
}
|
}
|
||||||
lastMessage = lastMessageNew;
|
lastMessage = lastMessageNew;
|
||||||
|
|
||||||
@ -1420,9 +1419,9 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
|
|||||||
if(fMasterNode) return false;
|
if(fMasterNode) return false;
|
||||||
if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false;
|
if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false;
|
||||||
|
|
||||||
if(chainActive.Tip()->nHeight-cachedLastSuccess < minBlockSpacing) {
|
if(chainActive.Tip()->nHeight - cachedLastSuccess < minBlockSpacing) {
|
||||||
LogPrintf("CDarkSendPool::DoAutomaticDenominating - Last successful darksend was too recent\n");
|
LogPrintf("CDarkSendPool::DoAutomaticDenominating - Last successful darksend action was too recent\n");
|
||||||
strAutoDenomResult = "Last successful darksend was too recent";
|
strAutoDenomResult = "Last successful darksend action was too recent";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!fEnableDarksend) {
|
if(!fEnableDarksend) {
|
||||||
@ -1451,14 +1450,14 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
|
|||||||
// ** find the coins we'll use
|
// ** find the coins we'll use
|
||||||
std::vector<CTxIn> vCoins;
|
std::vector<CTxIn> vCoins;
|
||||||
std::vector<COutput> vCoins2;
|
std::vector<COutput> vCoins2;
|
||||||
int64_t nValueMin = 0.01*COIN;
|
int64_t nValueMin = CENT;
|
||||||
int64_t nValueIn = 0;
|
int64_t nValueIn = 0;
|
||||||
|
|
||||||
// should not be less than fees in DARKSEND_FEE + few (lets say 5) smallest denoms
|
// should not be less than fees in DARKSEND_FEE + few (lets say 5) smallest denoms
|
||||||
int64_t nLowestDenom = DARKSEND_FEE + darkSendDenominations[darkSendDenominations.size() - 1]*5;
|
int64_t nLowestDenom = DARKSEND_FEE + darkSendDenominations[darkSendDenominations.size() - 1]*5;
|
||||||
|
|
||||||
// if there is no DS fee yet
|
// if there are no DS collateral inputs yet
|
||||||
if(!pwalletMain->HasDarksendFeeInputs())
|
if(!pwalletMain->HasCollateralInputs())
|
||||||
// should have some additional amount for them
|
// should have some additional amount for them
|
||||||
nLowestDenom += (DARKSEND_COLLATERAL*4)+DARKSEND_FEE*2;
|
nLowestDenom += (DARKSEND_COLLATERAL*4)+DARKSEND_FEE*2;
|
||||||
|
|
||||||
@ -1467,22 +1466,24 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
|
|||||||
// if balanceNeedsAnonymized is more than pool max, take the pool max
|
// if balanceNeedsAnonymized is more than pool max, take the pool max
|
||||||
if(nBalanceNeedsAnonymized > DARKSEND_POOL_MAX) nBalanceNeedsAnonymized = DARKSEND_POOL_MAX;
|
if(nBalanceNeedsAnonymized > DARKSEND_POOL_MAX) nBalanceNeedsAnonymized = DARKSEND_POOL_MAX;
|
||||||
|
|
||||||
// if balanceNeedsAnonymized is more than (non-anonymized - COIN), take (non-anonymized - COIN)
|
// if balanceNeedsAnonymized is more than non-anonymized, take non-anonymized
|
||||||
int64_t nBalanceNotYetAnonymized = pwalletMain->GetBalance() - pwalletMain->GetAnonymizedBalance() - COIN;
|
int64_t nBalanceNotYetAnonymized = pwalletMain->GetBalance() - pwalletMain->GetAnonymizedBalance();
|
||||||
if(nBalanceNeedsAnonymized > nBalanceNotYetAnonymized) nBalanceNeedsAnonymized = nBalanceNotYetAnonymized;
|
if(nBalanceNeedsAnonymized > nBalanceNotYetAnonymized) nBalanceNeedsAnonymized = nBalanceNotYetAnonymized;
|
||||||
|
|
||||||
if(nBalanceNeedsAnonymized < nLowestDenom)
|
if(nBalanceNeedsAnonymized < nLowestDenom)
|
||||||
{
|
{
|
||||||
if(nBalanceNeedsAnonymized > 0)
|
// if(nBalanceNeedsAnonymized > nValueMin)
|
||||||
nBalanceNeedsAnonymized = nLowestDenom;
|
// nBalanceNeedsAnonymized = nLowestDenom;
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
LogPrintf("DoAutomaticDenominating : No funds detected in need of denominating \n");
|
LogPrintf("DoAutomaticDenominating : No funds detected in need of denominating \n");
|
||||||
strAutoDenomResult = "No funds detected in need of denominating";
|
strAutoDenomResult = "No funds detected in need of denominating";
|
||||||
return false;
|
return false;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fDebug) LogPrintf("DoAutomaticDenominating : nLowestDenom=%d, nBalanceNeedsAnonymized=%d\n", nLowestDenom, nBalanceNeedsAnonymized);
|
||||||
|
|
||||||
// select coins that should be given to the pool
|
// select coins that should be given to the pool
|
||||||
if (!pwalletMain->SelectCoinsDark(nValueMin, nBalanceNeedsAnonymized, vCoins, nValueIn, 0, nDarksendRounds))
|
if (!pwalletMain->SelectCoinsDark(nValueMin, nBalanceNeedsAnonymized, vCoins, nValueIn, 0, nDarksendRounds))
|
||||||
{
|
{
|
||||||
@ -1494,16 +1495,16 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
|
|||||||
if(!fDryRun) return CreateDenominated(nBalanceNeedsAnonymized);
|
if(!fDryRun) return CreateDenominated(nBalanceNeedsAnonymized);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("DoAutomaticDenominating : No funds detected in need of denominating (2)\n");
|
LogPrintf("DoAutomaticDenominating : Can't denominate - no compatible inputs left\n");
|
||||||
strAutoDenomResult = "No funds detected in need of denominating (2)";
|
strAutoDenomResult = "Can't denominate - no compatible inputs left";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//check to see if we have the fee sized inputs, it requires these
|
//check to see if we have the collateral sized inputs, it requires these
|
||||||
if(!pwalletMain->HasDarksendFeeInputs()){
|
if(!pwalletMain->HasCollateralInputs()){
|
||||||
if(!fDryRun) SplitUpMoney(true);
|
if(!fDryRun) MakeCollateralAmounts();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1717,31 +1718,15 @@ bool CDarkSendPool::SendRandomPaymentToSelf()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Split up large inputs or create fee sized inputs
|
// Split up large inputs or create fee sized inputs
|
||||||
bool CDarkSendPool::SplitUpMoney(bool justCollateral)
|
bool CDarkSendPool::MakeCollateralAmounts()
|
||||||
{
|
{
|
||||||
if((chainActive.Tip()->nHeight - lastSplitUpBlock) < 10){
|
|
||||||
LogPrintf("SplitUpMoney - Too soon to split up again\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(splitUpInARow >= 2){
|
|
||||||
LogPrintf("Error: Darksend SplitUpMoney was called multiple times in a row. This should not happen. Please submit a detailed explanation of the steps it took to create this error and submit to evan@darkcoin.io. \n");
|
|
||||||
fEnableDarksend = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// should split up to remaining amount only...
|
// should split up to remaining amount only...
|
||||||
int64_t nTotalBalance = pwalletMain->GetDenominatedBalance(false);
|
int64_t nTotalBalance = pwalletMain->GetBalance();
|
||||||
int64_t nSplitBalance = nAnonymizeDarkcoinAmount*COIN - pwalletMain->GetDenominatedBalance();
|
int64_t nSplitBalance = nAnonymizeDarkcoinAmount*COIN - pwalletMain->GetDenominatedBalance();
|
||||||
if(nSplitBalance > nTotalBalance) nSplitBalance = nTotalBalance;
|
if(nSplitBalance > nTotalBalance) nSplitBalance = nTotalBalance;
|
||||||
// ...or up to 1 DRK if it's just collateral
|
|
||||||
if(justCollateral && nSplitBalance > 1*COIN) nSplitBalance = 1*COIN;
|
|
||||||
int64_t nTotalOut = 0;
|
int64_t nTotalOut = 0;
|
||||||
lastSplitUpBlock = chainActive.Tip()->nHeight;
|
|
||||||
|
|
||||||
LogPrintf("DoAutomaticDenominating: Split up large input (justCollateral %d):\n", justCollateral);
|
LogPrintf("DoAutomaticDenominating: MakeCollateralAmounts: nSplitBalance %d nTotalBalance %d\n", nSplitBalance, pwalletMain->GetDenominatedBalance(false));
|
||||||
LogPrintf(" -- nSplitBalance %d\n", nSplitBalance);
|
|
||||||
LogPrintf(" -- denom %d \n", pwalletMain->GetDenominatedBalance(false));
|
|
||||||
|
|
||||||
// make our change address
|
// make our change address
|
||||||
CReserveKey reservekey(pwalletMain);
|
CReserveKey reservekey(pwalletMain);
|
||||||
@ -1756,54 +1741,37 @@ bool CDarkSendPool::SplitUpMoney(bool justCollateral)
|
|||||||
std::string strFail = "";
|
std::string strFail = "";
|
||||||
vector< pair<CScript, int64_t> > vecSend;
|
vector< pair<CScript, int64_t> > vecSend;
|
||||||
|
|
||||||
int64_t a = 1*COIN;
|
|
||||||
|
|
||||||
// ****** Add fees ************ /
|
|
||||||
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
||||||
nTotalOut += (DARKSEND_COLLATERAL*2)+DARKSEND_FEE;
|
nTotalOut += (DARKSEND_COLLATERAL*2)+DARKSEND_FEE;
|
||||||
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
||||||
nTotalOut += (DARKSEND_COLLATERAL*2)+DARKSEND_FEE;
|
nTotalOut += (DARKSEND_COLLATERAL*2)+DARKSEND_FEE;
|
||||||
|
|
||||||
// ****** Add outputs in bases of two from 1 darkcoin *** /
|
if(nTotalOut > nSplitBalance) {
|
||||||
if(!justCollateral){
|
LogPrintf("MakeCollateralAmounts: Not enough balance to split\n");
|
||||||
bool continuing = true;
|
|
||||||
|
|
||||||
while(continuing){
|
|
||||||
if(nTotalOut + a < nSplitBalance){
|
|
||||||
//LogPrintf(" nTotalOut %d, added %d\n", nTotalOut, a);
|
|
||||||
|
|
||||||
vecSend.push_back(make_pair(scriptChange, a));
|
|
||||||
nTotalOut += a;
|
|
||||||
} else {
|
|
||||||
continuing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
a = a * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if((justCollateral && nTotalOut <= 0.1*COIN) || vecSend.size() < 1) {
|
|
||||||
LogPrintf("SplitUpMoney: Not enough outputs to make a transaction\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if((!justCollateral && nTotalOut <= 1*COIN) || vecSend.size() < 1){
|
|
||||||
LogPrintf("SplitUpMoney: Not enough outputs to make a transaction\n");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCoinControl *coinControl=NULL;
|
CCoinControl *coinControl=NULL;
|
||||||
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey,
|
// try to use non-denominated and not mn-like funds
|
||||||
nFeeRet, strFail, coinControl, justCollateral ? ALL_COINS : ONLY_NONDENOMINATED);
|
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey,
|
||||||
|
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN);
|
||||||
if(!success){
|
if(!success){
|
||||||
LogPrintf("SplitUpMoney: Error - %s\n", strFail.c_str());
|
// if we failed (most likeky not enough funds), try to use denominated instead -
|
||||||
return false;
|
// MN-like funds should not be touched in any case and we can't mix denominated without collaterals anyway
|
||||||
|
success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey,
|
||||||
|
nFeeRet, strFail, coinControl, ONLY_DENOMINATED);
|
||||||
|
if(!success){
|
||||||
|
LogPrintf("MakeCollateralAmounts: Error - %s\n", strFail.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pwalletMain->CommitTransaction(wtx, reservekey);
|
// use the same cachedLastSuccess as for DS mixinx to prevent race
|
||||||
|
if(pwalletMain->CommitTransaction(wtx, reservekey))
|
||||||
|
cachedLastSuccess = chainActive.Tip()->nHeight;
|
||||||
|
|
||||||
LogPrintf("SplitUpMoney Success: tx %s\n", wtx.GetHash().GetHex().c_str());
|
LogPrintf("MakeCollateralAmounts Success: tx %s\n", wtx.GetHash().GetHex().c_str());
|
||||||
|
|
||||||
splitUpInARow++;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1824,8 +1792,8 @@ bool CDarkSendPool::CreateDenominated(int64_t nTotalValue)
|
|||||||
vector< pair<CScript, int64_t> > vecSend;
|
vector< pair<CScript, int64_t> > vecSend;
|
||||||
int64_t nValueLeft = nTotalValue;
|
int64_t nValueLeft = nTotalValue;
|
||||||
|
|
||||||
// ****** Add fees ************ /
|
// ****** Add collateral outputs ************ /
|
||||||
if(!pwalletMain->HasDarksendFeeInputs()) {
|
if(!pwalletMain->HasCollateralInputs()) {
|
||||||
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
||||||
nValueLeft -= (DARKSEND_COLLATERAL*2)+DARKSEND_FEE;
|
nValueLeft -= (DARKSEND_COLLATERAL*2)+DARKSEND_FEE;
|
||||||
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
||||||
@ -1861,13 +1829,15 @@ bool CDarkSendPool::CreateDenominated(int64_t nTotalValue)
|
|||||||
|
|
||||||
CCoinControl *coinControl=NULL;
|
CCoinControl *coinControl=NULL;
|
||||||
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey,
|
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey,
|
||||||
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED);
|
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN);
|
||||||
if(!success){
|
if(!success){
|
||||||
LogPrintf("CreateDenominated: Error - %s\n", strFail.c_str());
|
LogPrintf("CreateDenominated: Error - %s\n", strFail.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pwalletMain->CommitTransaction(wtx, reservekey);
|
// use the same cachedLastSuccess as for DS mixinx to prevent race
|
||||||
|
if(pwalletMain->CommitTransaction(wtx, reservekey))
|
||||||
|
cachedLastSuccess = chainActive.Tip()->nHeight;
|
||||||
|
|
||||||
LogPrintf("CreateDenominated Success: tx %s\n", wtx.GetHash().GetHex().c_str());
|
LogPrintf("CreateDenominated Success: tx %s\n", wtx.GetHash().GetHex().c_str());
|
||||||
|
|
||||||
@ -2129,6 +2099,9 @@ bool CDarkSendSigner::VerifyMessage(CPubKey pubkey, vector<unsigned char>& vchSi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fDebug && pubkey2.GetID() != pubkey.GetID())
|
||||||
|
LogPrintf("CDarkSendSigner::VerifyMessage -- keys don't match: %s %s", pubkey2.GetID().ToString(), pubkey.GetID().ToString());
|
||||||
|
|
||||||
return (pubkey2.GetID() == pubkey.GetID());
|
return (pubkey2.GetID() == pubkey.GetID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,8 +259,6 @@ public:
|
|||||||
int64_t sessionTotalValue; //used for autoDenom
|
int64_t sessionTotalValue; //used for autoDenom
|
||||||
std::vector<CTransaction> vecSessionCollateral;
|
std::vector<CTransaction> vecSessionCollateral;
|
||||||
|
|
||||||
int lastSplitUpBlock;
|
|
||||||
int splitUpInARow; // how many splits we've done since a success?
|
|
||||||
int cachedLastSuccess;
|
int cachedLastSuccess;
|
||||||
int cachedNumBlocks; //used for the overview screen
|
int cachedNumBlocks; //used for the overview screen
|
||||||
int minBlockSpacing; //required blocks between mixes
|
int minBlockSpacing; //required blocks between mixes
|
||||||
@ -279,11 +277,9 @@ public:
|
|||||||
/* DarkSend uses collateral addresses to trust parties entering the pool
|
/* DarkSend uses collateral addresses to trust parties entering the pool
|
||||||
to behave themselves. If they don't it takes their money. */
|
to behave themselves. If they don't it takes their money. */
|
||||||
|
|
||||||
lastSplitUpBlock = 0;
|
|
||||||
cachedLastSuccess = 0;
|
cachedLastSuccess = 0;
|
||||||
cachedNumBlocks = 0;
|
cachedNumBlocks = 0;
|
||||||
unitTest = false;
|
unitTest = false;
|
||||||
splitUpInARow = 0;
|
|
||||||
txCollateral = CTransaction();
|
txCollateral = CTransaction();
|
||||||
minBlockSpacing = 1;
|
minBlockSpacing = 1;
|
||||||
nDsqCount = 0;
|
nDsqCount = 0;
|
||||||
@ -423,7 +419,7 @@ public:
|
|||||||
// used for liquidity providers
|
// used for liquidity providers
|
||||||
bool SendRandomPaymentToSelf();
|
bool SendRandomPaymentToSelf();
|
||||||
// split up large inputs or make fee sized inputs
|
// split up large inputs or make fee sized inputs
|
||||||
bool SplitUpMoney(bool justCollateral=false);
|
bool MakeCollateralAmounts();
|
||||||
bool CreateDenominated(int64_t nTotalValue);
|
bool CreateDenominated(int64_t nTotalValue);
|
||||||
// get the denominations for a list of outputs (returns a bitshifted integer)
|
// get the denominations for a list of outputs (returns a bitshifted integer)
|
||||||
int GetDenominations(const std::vector<CTxOut>& vout);
|
int GetDenominations(const std::vector<CTxOut>& vout);
|
||||||
|
@ -1237,12 +1237,13 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
|
|||||||
CTxIn vin = CTxIn(out.tx->GetHash(), out.i);
|
CTxIn vin = CTxIn(out.tx->GetHash(), out.i);
|
||||||
int rounds = GetInputDarksendRounds(vin);
|
int rounds = GetInputDarksendRounds(vin);
|
||||||
if(rounds >= 0) found = true;
|
if(rounds >= 0) found = true;
|
||||||
} else if(coin_type == ONLY_NONDENOMINATED) {
|
} else if(coin_type == ONLY_NONDENOMINATED || coin_type == ONLY_NONDENOMINATED_NOTMN) {
|
||||||
found = true;
|
found = true;
|
||||||
|
if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts
|
||||||
BOOST_FOREACH(int64_t d, darkSendDenominations)
|
BOOST_FOREACH(int64_t d, darkSendDenominations)
|
||||||
if(pcoin->vout[i].nValue == d)
|
if(pcoin->vout[i].nValue == d)
|
||||||
found = false;
|
found = false;
|
||||||
|
if(found && coin_type == ONLY_NONDENOMINATED_NOTMN) found = (pcoin->vout[i].nValue != 1000*COIN); // do not use MN funds
|
||||||
} else {
|
} else {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
@ -1459,9 +1460,6 @@ bool CWallet::SelectCoins(int64_t nTargetValue, set<pair<const CWalletTx*,unsign
|
|||||||
|
|
||||||
//if we're doing only denominated, we need to round up to the nearest .1DRK
|
//if we're doing only denominated, we need to round up to the nearest .1DRK
|
||||||
if(coin_type == ONLY_DENOMINATED){
|
if(coin_type == ONLY_DENOMINATED){
|
||||||
// denominate our funds
|
|
||||||
std::vector<CTxOut> vOut;
|
|
||||||
|
|
||||||
// Make outputs by looping through denominations, from large to small
|
// Make outputs by looping through denominations, from large to small
|
||||||
BOOST_FOREACH(int64_t v, darkSendDenominations)
|
BOOST_FOREACH(int64_t v, darkSendDenominations)
|
||||||
{
|
{
|
||||||
@ -1593,7 +1591,7 @@ bool CWallet::SelectCoinsDark(int64_t nValueMin, int64_t nValueMax, std::vector<
|
|||||||
nValueRet = 0;
|
nValueRet = 0;
|
||||||
|
|
||||||
vector<COutput> vCoins;
|
vector<COutput> vCoins;
|
||||||
AvailableCoins(vCoins, false, coinControl, nDarksendRoundsMin < 0 ? ONLY_NONDENOMINATED : ONLY_DENOMINATED);
|
AvailableCoins(vCoins, false, coinControl, nDarksendRoundsMin < 0 ? ONLY_NONDENOMINATED_NOTMN : ONLY_DENOMINATED);
|
||||||
|
|
||||||
set<pair<const CWalletTx*,unsigned int> > setCoinsRet2;
|
set<pair<const CWalletTx*,unsigned int> > setCoinsRet2;
|
||||||
|
|
||||||
@ -1643,13 +1641,8 @@ bool CWallet::SelectCoinsCollateral(std::vector<CTxIn>& setCoinsRet, int64_t& nV
|
|||||||
BOOST_FOREACH(const COutput& out, vCoins)
|
BOOST_FOREACH(const COutput& out, vCoins)
|
||||||
{
|
{
|
||||||
// collateral inputs will always be a multiple of DARSEND_COLLATERAL, up to five
|
// collateral inputs will always be a multiple of DARSEND_COLLATERAL, up to five
|
||||||
if(
|
if(IsCollateralAmount(out.tx->vout[out.i].nValue))
|
||||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 5)+DARKSEND_FEE ||
|
{
|
||||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 4)+DARKSEND_FEE ||
|
|
||||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 3)+DARKSEND_FEE ||
|
|
||||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 2)+DARKSEND_FEE ||
|
|
||||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 1)+DARKSEND_FEE
|
|
||||||
){
|
|
||||||
CTxIn vin = CTxIn(out.tx->GetHash(),out.i);
|
CTxIn vin = CTxIn(out.tx->GetHash(),out.i);
|
||||||
|
|
||||||
vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey
|
vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey
|
||||||
@ -1692,27 +1685,27 @@ int CWallet::CountInputsWithAmount(int64_t nInputAmount)
|
|||||||
return nTotal;
|
return nTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::HasDarksendFeeInputs() const
|
bool CWallet::HasCollateralInputs() const
|
||||||
{
|
{
|
||||||
CCoinControl *coinControl=NULL;
|
CCoinControl *coinControl=NULL;
|
||||||
|
|
||||||
vector<COutput> vCoins;
|
vector<COutput> vCoins;
|
||||||
AvailableCoins(vCoins, false, coinControl, ALL_COINS);
|
AvailableCoins(vCoins, false, coinControl, ALL_COINS);
|
||||||
|
|
||||||
bool found_collateral = false;
|
int nFound = 0;
|
||||||
BOOST_FOREACH(const COutput& out, vCoins)
|
BOOST_FOREACH(const COutput& out, vCoins)
|
||||||
{
|
if(IsCollateralAmount(out.tx->vout[out.i].nValue)) nFound++;
|
||||||
if(
|
|
||||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 5)+DARKSEND_FEE ||
|
|
||||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 4)+DARKSEND_FEE ||
|
|
||||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 3)+DARKSEND_FEE ||
|
|
||||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 2)+DARKSEND_FEE ||
|
|
||||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 1)+DARKSEND_FEE
|
|
||||||
) found_collateral = true;
|
|
||||||
|
|
||||||
}
|
return nFound > 1; // should have more than one just in case
|
||||||
|
}
|
||||||
|
|
||||||
return found_collateral;
|
bool CWallet::IsCollateralAmount(int64_t nInputAmount) const
|
||||||
|
{
|
||||||
|
return nInputAmount == (DARKSEND_COLLATERAL * 5)+DARKSEND_FEE ||
|
||||||
|
nInputAmount == (DARKSEND_COLLATERAL * 4)+DARKSEND_FEE ||
|
||||||
|
nInputAmount == (DARKSEND_COLLATERAL * 3)+DARKSEND_FEE ||
|
||||||
|
nInputAmount == (DARKSEND_COLLATERAL * 2)+DARKSEND_FEE ||
|
||||||
|
nInputAmount == (DARKSEND_COLLATERAL * 1)+DARKSEND_FEE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::SelectCoinsWithoutDenomination(int64_t nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
|
bool CWallet::SelectCoinsWithoutDenomination(int64_t nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
|
||||||
@ -1852,6 +1845,8 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
|
|||||||
strFailReason = _("Insufficient funds");
|
strFailReason = _("Insufficient funds");
|
||||||
else if (coin_type == ONLY_NONDENOMINATED)
|
else if (coin_type == ONLY_NONDENOMINATED)
|
||||||
strFailReason = _("Unable to locate enough Darksend non-denominated funds for this transaction");
|
strFailReason = _("Unable to locate enough Darksend non-denominated funds for this transaction");
|
||||||
|
else if (coin_type == ONLY_NONDENOMINATED_NOTMN)
|
||||||
|
strFailReason = _("Unable to locate enough Darksend non-denominated funds for this transaction that are not equal 1000 DRK");
|
||||||
else
|
else
|
||||||
strFailReason = _("Unable to locate enough Darksend denominated funds for this transaction");
|
strFailReason = _("Unable to locate enough Darksend denominated funds for this transaction");
|
||||||
|
|
||||||
@ -2023,7 +2018,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, std:
|
|||||||
if (!wtxNew.AcceptToMemoryPool(false))
|
if (!wtxNew.AcceptToMemoryPool(false))
|
||||||
{
|
{
|
||||||
// This must not fail. The transaction has already been signed and recorded.
|
// This must not fail. The transaction has already been signed and recorded.
|
||||||
LogPrintf("CommitTransaction() : Error: Transaction not valid");
|
LogPrintf("CommitTransaction() : Error: Transaction not valid\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
wtxNew.RelayWalletTransaction(strCommand);
|
wtxNew.RelayWalletTransaction(strCommand);
|
||||||
|
@ -55,7 +55,8 @@ enum AvailableCoinsType
|
|||||||
{
|
{
|
||||||
ALL_COINS = 1,
|
ALL_COINS = 1,
|
||||||
ONLY_DENOMINATED = 2,
|
ONLY_DENOMINATED = 2,
|
||||||
ONLY_NONDENOMINATED = 3
|
ONLY_NONDENOMINATED = 3,
|
||||||
|
ONLY_NONDENOMINATED_NOTMN = 4 // ONLY_NONDENOMINATED and not 1000 DRK at the same time
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -136,7 +137,8 @@ public:
|
|||||||
bool SelectCoinsByDenominations(int nDenom, int64_t nValueMin, int64_t nValueMax, std::vector<CTxIn>& setCoinsRet, vector<COutput>& vCoins, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax);
|
bool SelectCoinsByDenominations(int nDenom, int64_t nValueMin, int64_t nValueMax, std::vector<CTxIn>& setCoinsRet, vector<COutput>& vCoins, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax);
|
||||||
bool SelectCoinsDarkDenominated(int64_t nTargetValue, std::vector<CTxIn>& setCoinsRet, int64_t& nValueRet) const;
|
bool SelectCoinsDarkDenominated(int64_t nTargetValue, std::vector<CTxIn>& setCoinsRet, int64_t& nValueRet) const;
|
||||||
bool SelectCoinsMasternode(CTxIn& vin, int64_t& nValueRet, CScript& pubScript) const;
|
bool SelectCoinsMasternode(CTxIn& vin, int64_t& nValueRet, CScript& pubScript) const;
|
||||||
bool HasDarksendFeeInputs() const;
|
bool HasCollateralInputs() const;
|
||||||
|
bool IsCollateralAmount(int64_t nInputAmount) const;
|
||||||
int CountInputsWithAmount(int64_t nInputAmount);
|
int CountInputsWithAmount(int64_t nInputAmount);
|
||||||
|
|
||||||
bool SelectCoinsCollateral(std::vector<CTxIn>& setCoinsRet, int64_t& nValueRet) const ;
|
bool SelectCoinsCollateral(std::vector<CTxIn>& setCoinsRet, int64_t& nValueRet) const ;
|
||||||
|
Loading…
Reference in New Issue
Block a user