X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fbitcoinrpc.cpp;h=c0c9d2d7e95e95652d89611988552ff86ffd64d6;hp=6c7f4253b34369282d4468042e52567128755389;hb=44f601723c3a1c68de6e613a897e9f8418eb874a;hpb=6a467ea5724ee2bd7a6f53af3abcc5a57effafbb diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 6c7f425..c0c9d2d 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -2211,59 +2211,30 @@ Value sendalert(const Array& params, bool fHelp) return result; } -// ppcoin: send checkpoint -Value sendcheckpoint(const Array& params, bool fHelp) +// ppcoin: set checkpoint key +Value setcheckpointkey(const Array& params, bool fHelp) { - if (fHelp || params.size() > 2 || params.size() < 1 ) + if (fHelp || params.size() != 1) throw runtime_error( - "sendcheckpoint [checkpointhash]\n" - " is hex string of checkpoint master private key\n" - " is the hash of checkpoint block\n"); + "setcheckpointkey \n" + " is hex string of checkpoint master private key\n"); CSyncCheckpoint checkpoint; - CKey key; - - // TODO: omit checkpointhash parameter - if (params.size() > 1) - { - checkpoint.hashCheckpoint = uint256(params[1].get_str()); - if (!mapBlockIndex.count(checkpoint.hashCheckpoint)) - throw runtime_error( - "Provided checkpoint block is not on main chain\n"); - } - else - { - checkpoint.hashCheckpoint = Checkpoints::AutoSelectSyncCheckpoint(); - if (checkpoint.hashCheckpoint == Checkpoints::hashSyncCheckpoint) - throw runtime_error( - "Unable to select a more recent sync-checkpoint"); - } - + checkpoint.hashCheckpoint = hashGenesisBlock; CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION); sMsg << (CUnsignedSyncCheckpoint)checkpoint; checkpoint.vchMsg = vector(sMsg.begin(), sMsg.end()); vector 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"); - if(!checkpoint.ProcessSyncCheckpoint(NULL)) - throw runtime_error( - "Failed to process checkpoint.\n"); - // Relay checkpoint - { - LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) - checkpoint.RelayTo(pnode); - } + CSyncCheckpoint::strMasterPrivKey = params[0].get_str(); - Object result; - result.push_back(Pair("checkpoint", Checkpoints::hashSyncCheckpoint.ToString().c_str())); - result.push_back(Pair("height", mapBlockIndex[Checkpoints::hashSyncCheckpoint]->nHeight)); - result.push_back(Pair("timestamp", DateTimeStrFormat("%x %H:%M:%S", mapBlockIndex[Checkpoints::hashSyncCheckpoint]->GetBlockTime()).c_str())); - return result; + return "checkpoint master key has been set."; } @@ -2327,7 +2298,7 @@ static const CRPCCommand vRPCCommands[] = { "repairwallet", &repairwallet, false}, { "makekeypair", &makekeypair, false}, { "sendalert", &sendalert, false}, - { "sendcheckpoint", &sendcheckpoint, false}, + { "setcheckpointkey", &setcheckpointkey, false}, }; CRPCTable::CRPCTable()