mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 21:42:47 +01:00
fixes for denominations
This commit is contained in:
parent
f66b6645a0
commit
a5ec3b2801
84
src/main.cpp
84
src/main.cpp
@ -896,7 +896,7 @@ bool CTxMemPool::acceptableInputs(CValidationState &state, CTransaction &tx, boo
|
||||
|
||||
|
||||
bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fCheckInputs, bool fLimitFree,
|
||||
bool* pfMissingInputs)
|
||||
bool* pfMissingInputs, bool fScriptChecks)
|
||||
{
|
||||
if (pfMissingInputs)
|
||||
*pfMissingInputs = false;
|
||||
@ -997,7 +997,7 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe
|
||||
|
||||
// Check against previous transactions
|
||||
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
|
||||
if (!tx.CheckInputs(state, view, true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC))
|
||||
if (!tx.CheckInputs(state, view, fScriptChecks, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC))
|
||||
{
|
||||
return error("CTxMemPool::acceptable() : ConnectInputs failed %s", hash.ToString().c_str());
|
||||
}
|
||||
@ -1016,10 +1016,10 @@ bool CTransaction::AcceptToMemoryPool(CValidationState &state, bool fCheckInputs
|
||||
}
|
||||
}
|
||||
|
||||
bool CTransaction::IsAcceptable(CValidationState &state, bool fCheckInputs, bool fLimitFree, bool* pfMissingInputs)
|
||||
bool CTransaction::IsAcceptable(CValidationState &state, bool fCheckInputs, bool fLimitFree, bool* pfMissingInputs, bool fScriptChecks)
|
||||
{
|
||||
try {
|
||||
return mempool.acceptable(state, *this, fCheckInputs, fLimitFree, pfMissingInputs);
|
||||
return mempool.acceptable(state, *this, fCheckInputs, fLimitFree, pfMissingInputs, fScriptChecks);
|
||||
} catch(std::runtime_error &e) {
|
||||
return state.Abort(_("System error: ") + e.what());
|
||||
}
|
||||
@ -3910,25 +3910,71 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
int accepted = 0;
|
||||
std::string error = "";
|
||||
|
||||
/*//check it like a transaction
|
||||
//check it like a transaction
|
||||
{
|
||||
int64 nValueIn = 0;
|
||||
int64 nValueOut = 0;
|
||||
bool missingTx = false;
|
||||
|
||||
CValidationState state;
|
||||
CTransaction txNew;
|
||||
CTransaction tx;
|
||||
|
||||
BOOST_FOREACH(const CTxOut o, out)
|
||||
txNew.vout.push_back(o);
|
||||
BOOST_FOREACH(const CTxOut o, out){
|
||||
nValueOut += o.nValue;
|
||||
tx.vout.push_back(o);
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const CTxIn i, in)
|
||||
txNew.vin.push_back(i);
|
||||
BOOST_FOREACH(const CTxIn i, in){
|
||||
tx.vin.push_back(i);
|
||||
|
||||
if (!txNew.AcceptToMemoryPool(state, true, false)){ //AcceptableInputs(state, true)){
|
||||
printf("dsi -- transactione not valid! %s\n", txNew.ToString().c_str());
|
||||
printf("dsi -- tx in %s\n", i.ToString().c_str());
|
||||
|
||||
CTransaction tx2;
|
||||
uint256 hash;
|
||||
if(GetTransaction(i.prevout.hash, tx2, hash, true))
|
||||
nValueIn += tx2.vout[i.prevout.n].nValue;
|
||||
else
|
||||
missingTx = true;
|
||||
}
|
||||
|
||||
|
||||
if(!missingTx){
|
||||
int64 nFees = nValueIn-nValueOut;
|
||||
int64 txMinFee = tx.GetMinFee(1000, true, GMF_RELAY);
|
||||
printf("dsi -- min fee %"PRI64d"\n", txMinFee);
|
||||
printf("dsi -- fees %"PRI64d"-%"PRI64d"=%"PRI64d" \ntx:%s\n", nValueIn, nValueOut, nFees, tx.ToString().c_str());
|
||||
if (nFees < txMinFee) {
|
||||
printf("dsi -- fees are too low! %"PRI64d"-%"PRI64d"=%"PRI64d" \ntx:%s\n", nValueIn, nValueOut, nFees, tx.ToString().c_str());
|
||||
accepted = 0;
|
||||
error = "transaction fees are too low";
|
||||
pfrom->PushMessage("dssu", darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nValueIn-nValueOut > nValueIn*.01) {
|
||||
printf("dsi -- fees are too high! %s\n", tx.ToString().c_str());
|
||||
accepted = 0;
|
||||
error = "transaction fees are too high";
|
||||
pfrom->PushMessage("dssu", darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
printf("dsi -- missing input tx! %s\n", tx.ToString().c_str());
|
||||
accepted = 0;
|
||||
error = "missing input tx information";
|
||||
pfrom->PushMessage("dssu", darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool missing = false;
|
||||
if (!tx.IsAcceptable(state, true, false, &missing, false)){ //AcceptableInputs(state, true)){
|
||||
printf("dsi -- transactione not valid! %s\n", tx.ToString().c_str());
|
||||
accepted = 0;
|
||||
error = "transaction not valid";
|
||||
pfrom->PushMessage("dssu", darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error);
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if(darkSendPool.AddEntry(in, nAmount, txCollateral, out, error)){
|
||||
accepted = 1;
|
||||
@ -6867,13 +6913,19 @@ void CDarkSendPool::DoAutomaticDenominating()
|
||||
// ** find the coins we'll use
|
||||
std::vector<CTxIn> vCoins;
|
||||
int64 nValueMin = 0.01*COIN;
|
||||
int64 nValueMax = 100*COIN;
|
||||
int64 nValueMax = 501*COIN;
|
||||
int64 nValueIn = 0;
|
||||
|
||||
//simply look for non-denominated coins
|
||||
nValueIn = 0;
|
||||
if (!pwalletMain->SelectCoinsDark(nValueMin, nValueMax, vCoins, nValueIn, nDarksendRounds))
|
||||
{
|
||||
if (pwalletMain->SelectCoinsDark(nValueMax+1, 9999999*COIN, vCoins, nValueIn, nDarksendRounds))
|
||||
{
|
||||
printf("DoAutomaticDenominating Error: Found inputs too large to denominate. These must be broken up manually to use DarkSend.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("DoAutomaticDenominating : No funds detected in need of denominating\n");
|
||||
return;
|
||||
}
|
||||
@ -6951,11 +7003,9 @@ bool CDarkSendPool::GetCurrentMasterNodeConsessus(int64 blockHeight, CScript& pa
|
||||
if(out.nValue == 1000*COIN){
|
||||
payee = out.scriptPubKey;
|
||||
printf("MasternodeConsessus - Masternode payment to %s\n", payee.ToString().c_str());
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
printf("MasternodeConsessus - couldn't locate pubkey??? \n");
|
||||
|
@ -39,7 +39,7 @@ class CBitcoinAddress;
|
||||
#define START_MASTERNODE_PAYMENTS_TESTNET 1403568776 //Tue, 24 Jun 2014 00:12:56 GMT
|
||||
#define START_MASTERNODE_PAYMENTS 1403728576 //Wed, 25 Jun 2014 20:36:16 GMT
|
||||
|
||||
#define POOL_MAX_TRANSACTIONS 3 // wait for X transactions to merge and publish
|
||||
#define POOL_MAX_TRANSACTIONS 1 // wait for X transactions to merge and publish
|
||||
#define POOL_STATUS_UNKNOWN 0 // waiting for update
|
||||
#define POOL_STATUS_IDLE 1 // waiting for update
|
||||
#define POOL_STATUS_ACCEPTING_ENTRIES 2 // accepting entries
|
||||
@ -740,7 +740,7 @@ public:
|
||||
bool AcceptToMemoryPool(CValidationState &state, bool fCheckInputs=true, bool fLimitFree = true, bool* pfMissingInputs=NULL);
|
||||
|
||||
// Check everything without accepting into the pool
|
||||
bool IsAcceptable(CValidationState &state, bool fCheckInputs=true, bool fLimitFree = true, bool* pfMissingInputs=NULL);
|
||||
bool IsAcceptable(CValidationState &state, bool fCheckInputs=true, bool fLimitFree = true, bool* pfMissingInputs=NULL, bool fScriptChecks=true);
|
||||
|
||||
// Check only the inputs in a transaction
|
||||
bool AcceptableInputs(CValidationState &state, bool fLimitFree);
|
||||
@ -2255,7 +2255,7 @@ public:
|
||||
std::map<COutPoint, CInPoint> mapNextTx;
|
||||
|
||||
bool accept(CValidationState &state, CTransaction &tx, bool fCheckInputs, bool fLimitFree, bool* pfMissingInputs);
|
||||
bool acceptable(CValidationState &state, CTransaction &tx, bool fCheckInputs, bool fLimitFree, bool* pfMissingInputs);
|
||||
bool acceptable(CValidationState &state, CTransaction &tx, bool fCheckInputs, bool fLimitFree, bool* pfMissingInputs, bool fScriptChecks=true);
|
||||
bool acceptableInputs(CValidationState &state, CTransaction &tx, bool fLimitFree);
|
||||
bool addUnchecked(const uint256& hash, const CTransaction &tx);
|
||||
bool remove(const CTransaction &tx, bool fRecursive = false);
|
||||
|
@ -1646,6 +1646,25 @@ string CWallet::DarkSendDenominate(int64 nValue)
|
||||
|
||||
printf(" --- nValueIn %"PRI64d" nTotalValue %"PRI64d"\n", nValueIn, nTotalValue);
|
||||
|
||||
// calculate total value out --------
|
||||
|
||||
nTotalValue = 0;
|
||||
CWalletTx wtx;
|
||||
BOOST_FOREACH(CTxIn i, vCoins){
|
||||
if (mapWallet.count(i.prevout.hash))
|
||||
{
|
||||
CWalletTx& wtx = mapWallet[i.prevout.hash];
|
||||
nTotalValue += wtx.vout[i.prevout.n].nValue;
|
||||
} else {
|
||||
printf("SelectCoinsDarkDenominated -- Couldn't find transaction\n");
|
||||
}
|
||||
}
|
||||
nTotalValue -= nFeeRet; //minus fees
|
||||
|
||||
//--------------
|
||||
|
||||
|
||||
|
||||
BOOST_FOREACH(CTxIn v, vCoins)
|
||||
LockCoin(v.prevout);
|
||||
|
||||
@ -1700,6 +1719,7 @@ string CWallet::DarkSendDenominate(int64 nValue)
|
||||
int64 nValueLeft = nTotalValue;
|
||||
std::vector<CTxOut> vOut;
|
||||
int nOutputs = 0;
|
||||
printf("nValueLeft %"PRI64d"\n", nValueLeft/COIN);
|
||||
BOOST_FOREACH(int64 v, darkSendDenominations){
|
||||
nOutputs = 0;
|
||||
while(nValueLeft - v >= 0 && nOutputs <= 10) {
|
||||
@ -1713,6 +1733,9 @@ string CWallet::DarkSendDenominate(int64 nValue)
|
||||
|
||||
nOutputs++;
|
||||
nValueLeft -= v;
|
||||
|
||||
printf(" -- denom %"PRI64d"\n", v/COIN);
|
||||
printf("nValueLeft %"PRI64d"\n", nValueLeft/COIN);
|
||||
}
|
||||
|
||||
if(nValueLeft == 0) break;
|
||||
|
Loading…
Reference in New Issue
Block a user