Merge #908: Remove global strMasterNodePrivKey
00743b8 Remove global strMasterNodePrivKey - no need to extract keys all the time, store them in CActiveMasternode and reuse when needed
This commit is contained in:
parent
8cdf85323b
commit
175508d6b7
@ -106,16 +106,6 @@ void CActiveMasternode::ManageStatus()
|
||||
pwalletMain->LockCoin(vin.prevout);
|
||||
|
||||
// send to all nodes
|
||||
CPubKey pubKeyMasternode;
|
||||
CKey keyMasternode;
|
||||
|
||||
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode))
|
||||
{
|
||||
notCapableReason = "Error upon calling SetKey: " + errorMessage;
|
||||
LogPrintf("CActiveMasternode::ManageStatus() - %s\n", notCapableReason);
|
||||
return;
|
||||
}
|
||||
|
||||
CMasternodeBroadcast mnb;
|
||||
if(!CreateBroadcast(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage, mnb)) {
|
||||
notCapableReason = "Error on CreateBroadcast: " + errorMessage;
|
||||
@ -165,15 +155,6 @@ bool CActiveMasternode::SendMasternodePing(std::string& errorMessage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CPubKey pubKeyMasternode;
|
||||
CKey keyMasternode;
|
||||
|
||||
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode))
|
||||
{
|
||||
errorMessage = strprintf("Error upon calling SetKey: %s\n", errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
LogPrintf("CActiveMasternode::SendMasternodePing() - Relay Masternode Ping vin = %s\n", vin.ToString());
|
||||
|
||||
CMasternodePing mnp(vin);
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
// Initialized by init.cpp
|
||||
// Keys for the main Masternode
|
||||
CPubKey pubKeyMasternode;
|
||||
CKey keyMasternode;
|
||||
|
||||
// Initialized while registering Masternode
|
||||
CTxIn vin;
|
||||
|
@ -590,21 +590,13 @@ void CDarksendPool::CheckFinalTransaction()
|
||||
std::string strMessage = finalTransaction.GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);
|
||||
std::string strError = "";
|
||||
std::vector<unsigned char> vchSig;
|
||||
CKey key2;
|
||||
CPubKey pubkey2;
|
||||
|
||||
if(!darkSendSigner.SetKey(strMasterNodePrivKey, strError, key2, pubkey2))
|
||||
{
|
||||
LogPrintf("CDarksendPool::Check() - ERROR: Invalid Masternodeprivkey: '%s'\n", strError);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!darkSendSigner.SignMessage(strMessage, strError, vchSig, key2)) {
|
||||
if(!darkSendSigner.SignMessage(strMessage, strError, vchSig, activeMasternode.keyMasternode)) {
|
||||
LogPrintf("CDarksendPool::Check() - Sign message failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!darkSendSigner.VerifyMessage(pubkey2, vchSig, strMessage, strError)) {
|
||||
if(!darkSendSigner.VerifyMessage(activeMasternode.pubKeyMasternode, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CDarksendPool::Check() - Verify message failed\n");
|
||||
return;
|
||||
}
|
||||
@ -2186,24 +2178,15 @@ bool CDarksendQueue::Sign()
|
||||
if(!fMasterNode) return false;
|
||||
|
||||
std::string strMessage = vin.ToString() + boost::lexical_cast<std::string>(nDenom) + boost::lexical_cast<std::string>(time) + boost::lexical_cast<std::string>(ready);
|
||||
|
||||
CKey key2;
|
||||
CPubKey pubkey2;
|
||||
std::string errorMessage = "";
|
||||
|
||||
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, key2, pubkey2))
|
||||
{
|
||||
LogPrintf("CDarksendQueue():Relay - ERROR: Invalid Masternodeprivkey: '%s'\n", errorMessage);
|
||||
if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, activeMasternode.keyMasternode)) {
|
||||
LogPrintf("CDarksendQueue():Sign - Sign message failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, key2)) {
|
||||
LogPrintf("CDarksendQueue():Relay - Sign message failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!darkSendSigner.VerifyMessage(pubkey2, vchSig, strMessage, errorMessage)) {
|
||||
LogPrintf("CDarksendQueue():Relay - Verify message failed");
|
||||
if(!darkSendSigner.VerifyMessage(activeMasternode.pubKeyMasternode, vchSig, strMessage, errorMessage)) {
|
||||
LogPrintf("CDarksendQueue():Sign - Verify message failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,6 @@ static const int PS_KEYS_THRESHOLD_STOP = 50;
|
||||
extern CDarksendPool darkSendPool;
|
||||
extern CDarkSendSigner darkSendSigner;
|
||||
extern std::vector<CDarksendQueue> vecDarksendQueue;
|
||||
extern std::string strMasterNodePrivKey;
|
||||
extern map<uint256, CDarksendBroadcastTx> mapDarksendBroadcastTxes;
|
||||
extern CActiveMasternode activeMasternode;
|
||||
|
||||
|
12
src/init.cpp
12
src/init.cpp
@ -1784,20 +1784,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
}
|
||||
|
||||
strMasterNodePrivKey = GetArg("-masternodeprivkey", "");
|
||||
std::string strMasterNodePrivKey = GetArg("-masternodeprivkey", "");
|
||||
if(!strMasterNodePrivKey.empty()){
|
||||
std::string errorMessage;
|
||||
|
||||
CKey key;
|
||||
CPubKey pubkey;
|
||||
|
||||
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, key, pubkey))
|
||||
{
|
||||
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode))
|
||||
return InitError(_("Invalid masternodeprivkey. Please see documenation."));
|
||||
}
|
||||
|
||||
activeMasternode.pubKeyMasternode = pubkey;
|
||||
|
||||
LogPrintf(" pubKeyMasternode: %s\n", CBitcoinAddress(activeMasternode.pubKeyMasternode.GetID()).ToString());
|
||||
} else {
|
||||
return InitError(_("You must specify a masternodeprivkey in the configuration. Please see documentation for help."));
|
||||
}
|
||||
|
@ -558,24 +558,15 @@ bool CConsensusVote::Sign()
|
||||
{
|
||||
std::string errorMessage;
|
||||
|
||||
CKey key2;
|
||||
CPubKey pubkey2;
|
||||
std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(nBlockHeight);
|
||||
//LogPrintf("signing strMessage %s \n", strMessage);
|
||||
//LogPrintf("signing privkey %s \n", strMasterNodePrivKey);
|
||||
|
||||
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, key2, pubkey2))
|
||||
{
|
||||
LogPrintf("CConsensusVote::Sign() - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchMasterNodeSignature, key2)) {
|
||||
if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchMasterNodeSignature, activeMasternode.keyMasternode)) {
|
||||
LogPrintf("CConsensusVote::Sign() - Sign message failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!darkSendSigner.VerifyMessage(pubkey2, vchMasterNodeSignature, strMessage, errorMessage)) {
|
||||
if(!darkSendSigner.VerifyMessage(activeMasternode.pubKeyMasternode, vchMasterNodeSignature, strMessage, errorMessage)) {
|
||||
LogPrintf("CConsensusVote::Sign() - Verify message failed");
|
||||
return false;
|
||||
}
|
||||
|
@ -554,17 +554,9 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
|
||||
// SIGN MESSAGE TO NETWORK WITH OUR MASTERNODE KEYS
|
||||
|
||||
std::string errorMessage;
|
||||
CPubKey pubKeyMasternode;
|
||||
CKey keyMasternode;
|
||||
|
||||
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode))
|
||||
{
|
||||
LogPrintf("CMasternodePayments::ProcessBlock() - Error upon calling SetKey: %s\n", errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
LogPrintf("CMasternodePayments::ProcessBlock() - Signing Winner\n");
|
||||
if(newWinner.Sign(keyMasternode, pubKeyMasternode))
|
||||
if(newWinner.Sign(activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode))
|
||||
{
|
||||
LogPrintf("CMasternodePayments::ProcessBlock() - AddWinningMasternode\n");
|
||||
|
||||
|
@ -104,7 +104,6 @@ using namespace std;
|
||||
|
||||
//Dash only features
|
||||
bool fMasterNode = false;
|
||||
string strMasterNodePrivKey = "";
|
||||
string strMasterNodeAddr = "";
|
||||
bool fLiteMode = false;
|
||||
bool fEnableInstantSend = true;
|
||||
|
Loading…
Reference in New Issue
Block a user