pindexCheckpoint = mapBlockIndex[Checkpoints::hashSyncCheckpoint];
result.push_back(Pair("height", pindexCheckpoint->nHeight));
result.push_back(Pair("timestamp", DateTimeStrFormat(pindexCheckpoint->GetBlockTime()).c_str()));
-
+ if (mapArgs.count("-checkpointkey"))
+ result.push_back(Pair("checkpointmaster", true));
+
return result;
}
return result;
}
-// ppcoin: set checkpoint key
-Value setcheckpointkey(const Array& params, bool fHelp)
-{
- if (fHelp || params.size() != 1)
- throw runtime_error(
- "setcheckpointkey <privatekey>\n"
- "<privatekey> is hex string of checkpoint master private key\n");
-
- CSyncCheckpoint checkpoint;
- checkpoint.hashCheckpoint = hashGenesisBlock;
- CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
- sMsg << (CUnsignedSyncCheckpoint)checkpoint;
- checkpoint.vchMsg = vector<unsigned char>(sMsg.begin(), sMsg.end());
-
- vector<unsigned char> vchPrivKey = ParseHex(params[0].get_str());
- CKey key;
- key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end())); // if key is not correct openssl may crash
- if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig))
- throw runtime_error(
- "Unable to sign checkpoint, check private key?\n");
-
- CSyncCheckpoint::strMasterPrivKey = params[0].get_str();
-
- return "checkpoint master key has been set.";
-}
//
{ "repairwallet", &repairwallet, false},
{ "makekeypair", &makekeypair, false},
{ "sendalert", &sendalert, false},
- { "setcheckpointkey", &setcheckpointkey, false},
};
CRPCTable::CRPCTable()
pfrom->AskFor(CInv(MSG_BLOCK, hashPendingCheckpoint));
}
+ bool SetCheckpointPrivKey(std::string strPrivKey)
+ {
+ // Test signing a sync-checkpoint with genesis block
+ CSyncCheckpoint checkpoint;
+ checkpoint.hashCheckpoint = hashGenesisBlock;
+ CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
+ sMsg << (CUnsignedSyncCheckpoint)checkpoint;
+ checkpoint.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());
+
+ std::vector<unsigned char> vchPrivKey = ParseHex(strPrivKey);
+ CKey key;
+ key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end())); // if key is not correct openssl may crash
+ if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig))
+ return false;
+
+ // Test signing successful, proceed
+ CSyncCheckpoint::strMasterPrivKey = strPrivKey;
+ return true;
+ }
+
bool SendSyncCheckpoint(uint256 hashCheckpoint)
{
CSyncCheckpoint checkpoint;
#include "init.h"
#include "util.h"
#include "ui_interface.h"
+#include "checkpoints.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/convenience.hpp>
}
}
+ if (mapArgs.count("-checkpointkey")) // ppcoin: checkpoint master priv key
+ {
+ if (!Checkpoints::SetCheckpointPrivKey(GetArg("-checkpointkey", "")))
+ ThreadSafeMessageBox(_("Unable to sign checkpoint, wrong checkpointkey?\n"), _("PPCoin"), wxOK | wxMODAL);
+ }
+
//
// Start the node
//