Fix governance hash (#1208)
* Add vinMasternode to governance object hash and bump protocols * Add collateral hash to governance object hash * Added signature to object hash * Revert "Add collateral hash to governance object hash" This reverts commit 2f60c280f3ce1e26cb4ab12f8287424b200aab83.
This commit is contained in:
parent
fa301ecb49
commit
8c16880b15
@ -19,7 +19,7 @@ static const int PRIVATESEND_QUEUE_TIMEOUT = 30;
|
|||||||
static const int PRIVATESEND_SIGNING_TIMEOUT = 15;
|
static const int PRIVATESEND_SIGNING_TIMEOUT = 15;
|
||||||
|
|
||||||
//! minimum peer version accepted by mixing pool
|
//! minimum peer version accepted by mixing pool
|
||||||
static const int MIN_PRIVATESEND_PEER_PROTO_VERSION = 70203;
|
static const int MIN_PRIVATESEND_PEER_PROTO_VERSION = 70204;
|
||||||
|
|
||||||
static const CAmount PRIVATESEND_COLLATERAL = 0.001 * COIN;
|
static const CAmount PRIVATESEND_COLLATERAL = 0.001 * COIN;
|
||||||
static const CAmount PRIVATESEND_POOL_MAX = 999.999 * COIN;
|
static const CAmount PRIVATESEND_POOL_MAX = 999.999 * COIN;
|
||||||
|
@ -223,6 +223,19 @@ void CGovernanceObject::ClearMasternodeVotes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CGovernanceObject::GetSignatureMessage() const
|
||||||
|
{
|
||||||
|
LOCK(cs);
|
||||||
|
std::string strMessage = nHashParent.ToString() + "|" +
|
||||||
|
boost::lexical_cast<std::string>(nRevision) + "|" +
|
||||||
|
boost::lexical_cast<std::string>(nTime) + "|" +
|
||||||
|
strData + "|" +
|
||||||
|
vinMasternode.prevout.ToStringShort() + "|" +
|
||||||
|
nCollateralHash.ToString();
|
||||||
|
|
||||||
|
return strMessage;
|
||||||
|
}
|
||||||
|
|
||||||
void CGovernanceObject::SetMasternodeInfo(const CTxIn& vin)
|
void CGovernanceObject::SetMasternodeInfo(const CTxIn& vin)
|
||||||
{
|
{
|
||||||
vinMasternode = vin;
|
vinMasternode = vin;
|
||||||
@ -230,11 +243,10 @@ void CGovernanceObject::SetMasternodeInfo(const CTxIn& vin)
|
|||||||
|
|
||||||
bool CGovernanceObject::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode)
|
bool CGovernanceObject::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
|
||||||
|
|
||||||
std::string strError;
|
std::string strError;
|
||||||
uint256 nHash = GetHash();
|
std::string strMessage = GetSignatureMessage();
|
||||||
std::string strMessage = nHash.ToString();
|
|
||||||
|
LOCK(cs);
|
||||||
|
|
||||||
if(!darkSendSigner.SignMessage(strMessage, vchSig, keyMasternode)) {
|
if(!darkSendSigner.SignMessage(strMessage, vchSig, keyMasternode)) {
|
||||||
LogPrintf("CGovernanceObject::Sign -- SignMessage() failed\n");
|
LogPrintf("CGovernanceObject::Sign -- SignMessage() failed\n");
|
||||||
@ -255,11 +267,11 @@ bool CGovernanceObject::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode)
|
|||||||
|
|
||||||
bool CGovernanceObject::CheckSignature(CPubKey& pubKeyMasternode)
|
bool CGovernanceObject::CheckSignature(CPubKey& pubKeyMasternode)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
|
||||||
std::string strError;
|
std::string strError;
|
||||||
uint256 nHash = GetHash();
|
|
||||||
std::string strMessage = nHash.ToString();
|
|
||||||
|
|
||||||
|
std::string strMessage = GetSignatureMessage();
|
||||||
|
|
||||||
|
LOCK(cs);
|
||||||
if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
|
if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
|
||||||
LogPrintf("CGovernance::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
|
LogPrintf("CGovernance::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
|
||||||
return false;
|
return false;
|
||||||
@ -286,6 +298,8 @@ uint256 CGovernanceObject::GetHash() const
|
|||||||
ss << nRevision;
|
ss << nRevision;
|
||||||
ss << nTime;
|
ss << nTime;
|
||||||
ss << strData;
|
ss << strData;
|
||||||
|
ss << vinMasternode;
|
||||||
|
ss << vchSig;
|
||||||
// fee_tx is left out on purpose
|
// fee_tx is left out on purpose
|
||||||
uint256 h1 = ss.GetHash();
|
uint256 h1 = ss.GetHash();
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class CGovernanceObject;
|
|||||||
class CGovernanceVote;
|
class CGovernanceVote;
|
||||||
|
|
||||||
static const int MAX_GOVERNANCE_OBJECT_DATA_SIZE = 16 * 1024;
|
static const int MAX_GOVERNANCE_OBJECT_DATA_SIZE = 16 * 1024;
|
||||||
static const int MIN_GOVERNANCE_PEER_PROTO_VERSION = 70203;
|
static const int MIN_GOVERNANCE_PEER_PROTO_VERSION = 70204;
|
||||||
|
|
||||||
static const int GOVERNANCE_OBJECT_UNKNOWN = 0;
|
static const int GOVERNANCE_OBJECT_UNKNOWN = 0;
|
||||||
static const int GOVERNANCE_OBJECT_PROPOSAL = 1;
|
static const int GOVERNANCE_OBJECT_PROPOSAL = 1;
|
||||||
@ -262,6 +262,8 @@ public:
|
|||||||
bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode);
|
bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode);
|
||||||
bool CheckSignature(CPubKey& pubKeyMasternode);
|
bool CheckSignature(CPubKey& pubKeyMasternode);
|
||||||
|
|
||||||
|
std::string GetSignatureMessage() const;
|
||||||
|
|
||||||
// CORE OBJECT FUNCTIONS
|
// CORE OBJECT FUNCTIONS
|
||||||
|
|
||||||
bool IsValidLocally(const CBlockIndex* pindex, std::string& strError, bool fCheckCollateral);
|
bool IsValidLocally(const CBlockIndex* pindex, std::string& strError, bool fCheckCollateral);
|
||||||
|
@ -28,7 +28,7 @@ std::map<uint256, int64_t> mapAskedForGovernanceObject;
|
|||||||
|
|
||||||
int nSubmittedFinalBudget;
|
int nSubmittedFinalBudget;
|
||||||
|
|
||||||
const std::string CGovernanceManager::SERIALIZATION_VERSION_STRING = "CGovernanceManager-Version-5";
|
const std::string CGovernanceManager::SERIALIZATION_VERSION_STRING = "CGovernanceManager-Version-6";
|
||||||
|
|
||||||
CGovernanceManager::CGovernanceManager()
|
CGovernanceManager::CGovernanceManager()
|
||||||
: pCurrentBlockIndex(NULL),
|
: pCurrentBlockIndex(NULL),
|
||||||
|
@ -28,7 +28,7 @@ static const int INSTANTSEND_SIGNATURES_REQUIRED = 6;
|
|||||||
static const int INSTANTSEND_SIGNATURES_TOTAL = 10;
|
static const int INSTANTSEND_SIGNATURES_TOTAL = 10;
|
||||||
static const int DEFAULT_INSTANTSEND_DEPTH = 5;
|
static const int DEFAULT_INSTANTSEND_DEPTH = 5;
|
||||||
|
|
||||||
static const int MIN_INSTANTSEND_PROTO_VERSION = 70203;
|
static const int MIN_INSTANTSEND_PROTO_VERSION = 70204;
|
||||||
static const CAmount INSTANTSEND_MIN_FEE = 0.001 * COIN;
|
static const CAmount INSTANTSEND_MIN_FEE = 0.001 * COIN;
|
||||||
|
|
||||||
extern bool fEnableInstantSend;
|
extern bool fEnableInstantSend;
|
||||||
|
@ -24,7 +24,7 @@ static const int MNPAYMENTS_SIGNATURES_TOTAL = 10;
|
|||||||
// V1 - Last protocol version before update
|
// V1 - Last protocol version before update
|
||||||
// V2 - Newest protocol version
|
// V2 - Newest protocol version
|
||||||
static const int MIN_MASTERNODE_PAYMENT_PROTO_VERSION_1 = 70103;
|
static const int MIN_MASTERNODE_PAYMENT_PROTO_VERSION_1 = 70103;
|
||||||
static const int MIN_MASTERNODE_PAYMENT_PROTO_VERSION_2 = 70203;
|
static const int MIN_MASTERNODE_PAYMENT_PROTO_VERSION_2 = 70204;
|
||||||
|
|
||||||
extern CCriticalSection cs_vecPayees;
|
extern CCriticalSection cs_vecPayees;
|
||||||
extern CCriticalSection cs_mapMasternodeBlocks;
|
extern CCriticalSection cs_mapMasternodeBlocks;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* network protocol versioning
|
* network protocol versioning
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const int PROTOCOL_VERSION = 70203;
|
static const int PROTOCOL_VERSION = 70204;
|
||||||
|
|
||||||
//! initial proto version, to be increased after version/verack negotiation
|
//! initial proto version, to be increased after version/verack negotiation
|
||||||
static const int INIT_PROTO_VERSION = 209;
|
static const int INIT_PROTO_VERSION = 209;
|
||||||
|
Loading…
Reference in New Issue
Block a user