mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Add maximum out value for IX via spork
This commit is contained in:
parent
707db8427c
commit
23ea75f737
@ -3,7 +3,7 @@ AC_PREREQ([2.60])
|
||||
define(_CLIENT_VERSION_MAJOR, 0)
|
||||
define(_CLIENT_VERSION_MINOR, 11)
|
||||
define(_CLIENT_VERSION_REVISION, 1)
|
||||
define(_CLIENT_VERSION_BUILD, 19)
|
||||
define(_CLIENT_VERSION_BUILD, 20)
|
||||
define(_CLIENT_VERSION_IS_RELEASE, true)
|
||||
define(_COPYRIGHT_YEAR, 2015)
|
||||
AC_INIT([Darkcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@darkcoin.io],[darkcoin])
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define CLIENT_VERSION_MAJOR 0
|
||||
#define CLIENT_VERSION_MINOR 11
|
||||
#define CLIENT_VERSION_REVISION 1
|
||||
#define CLIENT_VERSION_BUILD 19
|
||||
#define CLIENT_VERSION_BUILD 20
|
||||
|
||||
|
||||
|
||||
|
@ -194,6 +194,11 @@ bool IsIXTXValid(const CTransaction& txCollateral){
|
||||
}
|
||||
}
|
||||
|
||||
if(nValueOut > GetSporkValue(SPORK_5_MAX_VALUE)*COIN){
|
||||
if(fDebug) LogPrintf ("IsIXTXValid - Transaction value too high - %s\n", txCollateral.ToString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if(missingTx){
|
||||
if(fDebug) LogPrintf ("IsIXTXValid - Unknown inputs in IX transaction - %s\n", txCollateral.ToString().c_str());
|
||||
/*
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "ui_interface.h"
|
||||
#include "wallet.h"
|
||||
#include "walletdb.h" // for BackupWallet
|
||||
#include "spork.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -266,6 +267,13 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
|
||||
CWalletTx *newTx = transaction.getTransaction();
|
||||
CReserveKey *keyChange = transaction.getPossibleKeyChange();
|
||||
|
||||
|
||||
if(recipients[0].useInstantX && total > GetSporkValue(SPORK_5_MAX_VALUE)*COIN){
|
||||
emit message(tr("Send Coins"), tr("InstantX doesn't support sending values that high yet. Transactions are currently limited to %n DRK.", "", GetSporkValue(SPORK_5_MAX_VALUE)),
|
||||
CClientUIInterface::MSG_ERROR);
|
||||
return TransactionCreationFailed;
|
||||
}
|
||||
|
||||
bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason, coinControl, recipients[0].inputType, recipients[0].useInstantX);
|
||||
transaction.setTransactionFee(nFeeRequired);
|
||||
|
||||
@ -318,6 +326,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CReserveKey *keyChange = transaction.getPossibleKeyChange();
|
||||
|
||||
transaction.getRecipients();
|
||||
|
@ -140,7 +140,7 @@ Value spork(const Array& params, bool fHelp)
|
||||
|
||||
Object ret;
|
||||
while(it != mapSporksActive.end()) {
|
||||
ret.push_back(Pair(sporkManager.GetSporkNameByID(it->second.nSporkID), it->second.nTimeStart));
|
||||
ret.push_back(Pair(sporkManager.GetSporkNameByID(it->second.nSporkID), it->second.nValue));
|
||||
it++;
|
||||
}
|
||||
return ret;
|
||||
@ -150,11 +150,11 @@ Value spork(const Array& params, bool fHelp)
|
||||
return "Invalid spork name";
|
||||
}
|
||||
|
||||
// EPOCH VALUE
|
||||
int64_t nEpochStart = params[1].get_int();
|
||||
// SPORK VALUE
|
||||
int64_t nValue = params[1].get_int();
|
||||
|
||||
//broadcast new spork
|
||||
if(sporkManager.UpdateSpork(nSporkID, nEpochStart)){
|
||||
if(sporkManager.UpdateSpork(nSporkID, nValue)){
|
||||
return "success";
|
||||
} else {
|
||||
return "failure";
|
||||
|
@ -45,7 +45,7 @@ void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
|
||||
}
|
||||
}
|
||||
|
||||
LogPrintf("spork - new %s ID %d Time %d bestHeight %d\n", hash.ToString().c_str(), spork.nSporkID, spork.nTimeStart, chainActive.Tip()->nHeight);
|
||||
LogPrintf("spork - new %s ID %d Time %d bestHeight %d\n", hash.ToString().c_str(), spork.nSporkID, spork.nValue, chainActive.Tip()->nHeight);
|
||||
|
||||
if(!sporkManager.CheckSignature(spork)){
|
||||
LogPrintf("spork - invalid signature\n");
|
||||
@ -75,12 +75,13 @@ bool IsSporkActive(int nSporkID)
|
||||
int64_t r = 0;
|
||||
|
||||
if(mapSporksActive.count(nSporkID)){
|
||||
r = mapSporksActive[nSporkID].nTimeStart;
|
||||
r = mapSporksActive[nSporkID].nValue;
|
||||
} else {
|
||||
if(nSporkID == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) r = SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT;
|
||||
if(nSporkID == SPORK_2_INSTANTX) r = SPORK_2_INSTANTX_DEFAULT;
|
||||
if(nSporkID == SPORK_3_INSTANTX_BLOCK_FILTERING) r = SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT;
|
||||
if(nSporkID == SPORK_4_RECONVERGE) r = SPORK_4_RECONVERGE_DEFAULT;
|
||||
if(nSporkID == SPORK_5_MAX_VALUE) r = SPORK_5_MAX_VALUE_DEFAULT;
|
||||
|
||||
if(r == 0) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID);
|
||||
}
|
||||
@ -89,11 +90,31 @@ bool IsSporkActive(int nSporkID)
|
||||
return r < GetTime();
|
||||
}
|
||||
|
||||
// grab the value of the spork on the network, or the default
|
||||
int GetSporkValue(int nSporkID)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
if(mapSporksActive.count(nSporkID)){
|
||||
r = mapSporksActive[nSporkID].nValue;
|
||||
} else {
|
||||
if(nSporkID == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) r = SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT;
|
||||
if(nSporkID == SPORK_2_INSTANTX) r = SPORK_2_INSTANTX_DEFAULT;
|
||||
if(nSporkID == SPORK_3_INSTANTX_BLOCK_FILTERING) r = SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT;
|
||||
if(nSporkID == SPORK_4_RECONVERGE) r = SPORK_4_RECONVERGE_DEFAULT;
|
||||
if(nSporkID == SPORK_5_MAX_VALUE) r = SPORK_5_MAX_VALUE_DEFAULT;
|
||||
|
||||
if(r == 0) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
bool CSporkManager::CheckSignature(CSporkMessage& spork)
|
||||
{
|
||||
//note: need to investigate why this is failing
|
||||
std::string strMessage = boost::lexical_cast<std::string>(spork.nSporkID) + boost::lexical_cast<std::string>(spork.nTimeStart) + boost::lexical_cast<std::string>(spork.nTimeSigned);
|
||||
std::string strMessage = boost::lexical_cast<std::string>(spork.nSporkID) + boost::lexical_cast<std::string>(spork.nValue) + boost::lexical_cast<std::string>(spork.nTimeSigned);
|
||||
std::string strPubKey = (Params().NetworkID() == CChainParams::MAIN) ? strMainPubKey : strTestPubKey;
|
||||
CPubKey pubkey(ParseHex(strPubKey));
|
||||
|
||||
@ -107,7 +128,7 @@ bool CSporkManager::CheckSignature(CSporkMessage& spork)
|
||||
|
||||
bool CSporkManager::Sign(CSporkMessage& spork)
|
||||
{
|
||||
std::string strMessage = boost::lexical_cast<std::string>(spork.nSporkID) + boost::lexical_cast<std::string>(spork.nTimeStart) + boost::lexical_cast<std::string>(spork.nTimeSigned);
|
||||
std::string strMessage = boost::lexical_cast<std::string>(spork.nSporkID) + boost::lexical_cast<std::string>(spork.nValue) + boost::lexical_cast<std::string>(spork.nTimeSigned);
|
||||
|
||||
CKey key2;
|
||||
CPubKey pubkey2;
|
||||
@ -132,17 +153,18 @@ bool CSporkManager::Sign(CSporkMessage& spork)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSporkManager::UpdateSpork(int nSporkID, int64_t nTimeStart)
|
||||
bool CSporkManager::UpdateSpork(int nSporkID, int64_t nValue)
|
||||
{
|
||||
|
||||
CSporkMessage msg;
|
||||
msg.nSporkID = nSporkID;
|
||||
msg.nTimeStart = nTimeStart;
|
||||
msg.nValue = nValue;
|
||||
msg.nTimeSigned = GetTime();
|
||||
|
||||
if(Sign(msg)){
|
||||
Relay(msg);
|
||||
mapSporks[msg.GetHash()] = msg;
|
||||
mapSporksActive[nSporkID] = msg;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -180,11 +202,11 @@ bool CSporkManager::SetPrivKey(std::string strPrivKey)
|
||||
|
||||
int CSporkManager::GetSporkIDByName(std::string strName)
|
||||
{
|
||||
printf("%s\n", strName.c_str());
|
||||
if(strName == "SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT") return SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT;
|
||||
if(strName == "SPORK_2_INSTANTX") return SPORK_2_INSTANTX;
|
||||
if(strName == "SPORK_3_INSTANTX_BLOCK_FILTERING") return SPORK_3_INSTANTX_BLOCK_FILTERING;
|
||||
if(strName == "SPORK_4_RECONVERGE") return SPORK_4_RECONVERGE;
|
||||
if(strName == "SPORK_5_MAX_VALUE") return SPORK_5_MAX_VALUE;
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -195,6 +217,7 @@ std::string CSporkManager::GetSporkNameByID(int id)
|
||||
if(id == SPORK_2_INSTANTX) return "SPORK_2_INSTANTX";
|
||||
if(id == SPORK_3_INSTANTX_BLOCK_FILTERING) return "SPORK_3_INSTANTX_BLOCK_FILTERING";
|
||||
if(id == SPORK_4_RECONVERGE) return "SPORK_4_RECONVERGE";
|
||||
if(id == SPORK_5_MAX_VALUE) return "SPORK_5_MAX_VALUE";
|
||||
|
||||
return "Unknown";
|
||||
}
|
@ -23,11 +23,13 @@ using namespace boost;
|
||||
#define SPORK_2_INSTANTX 10001
|
||||
#define SPORK_3_INSTANTX_BLOCK_FILTERING 10002
|
||||
#define SPORK_4_RECONVERGE 10003
|
||||
#define SPORK_5_MAX_VALUE 10004
|
||||
|
||||
#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT 1424217600 //2015-2-18
|
||||
#define SPORK_2_INSTANTX_DEFAULT 978307200 //2001-1-1
|
||||
#define SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT 1424217600 //2015-2-18
|
||||
#define SPORK_4_RECONVERGE_DEFAULT 4070908800 //2099-1-1
|
||||
#define SPORK_5_MAX_VALUE_DEFAULT 1000 //1000 DRK
|
||||
|
||||
class CSporkMessage;
|
||||
class CSporkManager;
|
||||
@ -48,6 +50,7 @@ extern std::map<int, CSporkMessage> mapSporksActive;
|
||||
extern CSporkManager sporkManager;
|
||||
|
||||
void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
||||
int GetSporkValue(int nSporkID);
|
||||
bool IsSporkActive(int nSporkID);
|
||||
|
||||
//
|
||||
@ -60,7 +63,7 @@ class CSporkMessage
|
||||
public:
|
||||
std::vector<unsigned char> vchSig;
|
||||
int nSporkID;
|
||||
int64_t nTimeStart;
|
||||
int64_t nValue;
|
||||
int64_t nTimeSigned;
|
||||
|
||||
uint256 GetHash(){
|
||||
@ -70,7 +73,7 @@ public:
|
||||
|
||||
IMPLEMENT_SERIALIZE(
|
||||
READWRITE(nSporkID);
|
||||
READWRITE(nTimeStart);
|
||||
READWRITE(nValue);
|
||||
READWRITE(nTimeSigned);
|
||||
READWRITE(vchSig);
|
||||
)
|
||||
@ -95,7 +98,7 @@ public:
|
||||
|
||||
std::string GetSporkNameByID(int id);
|
||||
int GetSporkIDByName(std::string strName);
|
||||
bool UpdateSpork(int nSporkID, int64_t nTimeStart);
|
||||
bool UpdateSpork(int nSporkID, int64_t nValue);
|
||||
bool SetPrivKey(std::string strPrivKey);
|
||||
bool CheckSignature(CSporkMessage& spork);
|
||||
bool Sign(CSporkMessage& spork);
|
||||
|
@ -1841,6 +1841,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
wtxNew.BindWallet(this);
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user