if (fHelp || params.size() != 0)
throw runtime_error(
"getdifficulty\n"
- "Returns the proof-of-work difficulty as a multiple of the minimum difficulty.");
+ "Returns difficulty as a multiple of the minimum difficulty.");
- return GetDifficulty();
+ Object obj;
+ obj.push_back(Pair("proof-of-work", GetDifficulty()));
+ obj.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true))));
+ return obj;
}
result.push_back(Pair("synccheckpoint", Checkpoints::hashSyncCheckpoint.ToString().c_str()));
pindexCheckpoint = mapBlockIndex[Checkpoints::hashSyncCheckpoint];
result.push_back(Pair("height", pindexCheckpoint->nHeight));
- result.push_back(Pair("timestamp", DateTimeStrFormat("%x %H:%M:%S", pindexCheckpoint->GetBlockTime()).c_str()));
-
+ result.push_back(Pair("timestamp", DateTimeStrFormat(pindexCheckpoint->GetBlockTime()).c_str()));
+ if (mapArgs.count("-checkpointkey"))
+ result.push_back(Pair("checkpointmaster", true));
+
return result;
}
nAmount = (nAmount / CENT) * CENT; // round to cent
if (nAmount < 0)
throw runtime_error("amount cannot be negative.\n");
- // TODO: handle persistence of nBalanceReserve
- // settings removed since bitcoin 0.6
- // WriteSetting("nBalanceReserve", nBalanceReserve = nAmount);
- nBalanceReserve = nAmount;
+ mapArgs["-reservebalance"] = FormatMoney(nAmount).c_str();
}
else
{
if (params.size() > 1)
throw runtime_error("cannot specify amount to turn off reserve.\n");
- // TODO: handle persistence of nBalanceReserve
- // settings removed since bitcoin 0.6
- // WriteSetting("nBalanceReserve", nBalanceReserve = 0);
- nBalanceReserve = 0;
+ mapArgs["-reservebalance"] = "0";
}
}
Object result;
- result.push_back(Pair("reserve", (nBalanceReserve > 0)));
- result.push_back(Pair("amount", ValueFromAmount(nBalanceReserve)));
+ int64 nReserveBalance = 0;
+ if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
+ throw runtime_error("invalid reserve balance amount\n");
+ result.push_back(Pair("reserve", (nReserveBalance > 0)));
+ result.push_back(Pair("amount", ValueFromAmount(nReserveBalance)));
return result;
}
// ThreadRPCServer: holds cs_main and acquiring cs_vSend in alert.RelayTo()/PushMessage()/BeginMessage()
Value sendalert(const Array& params, bool fHelp)
{
- if (fHelp || params.size() < 5)
+ if (fHelp || params.size() < 6)
throw runtime_error(
- "sendalert <message> <privatekey> <minver> <maxver> <id> [cancelupto]\n"
+ "sendalert <message> <privatekey> <minver> <maxver> <priority> <id> [cancelupto]\n"
"<message> is the alert text message\n"
"<privatekey> is hex string of alert master private key\n"
- "<minver> is the minimum applicable client version\n"
- "<maxver> is the maximum applicable client version\n"
+ "<minver> is the minimum applicable internal client version\n"
+ "<maxver> is the maximum applicable internal client version\n"
+ "<priority> is integer priority number\n"
"<id> is the alert id\n"
"[cancelupto] cancels all alert id's up to this number\n"
- "Returns true or false.");
+ "Returns true or false.");
CAlert alert;
CKey key;
alert.strStatusBar = params[0].get_str();
alert.nMinVer = params[2].get_int();
alert.nMaxVer = params[3].get_int();
- alert.nID = params[4].get_int();
- if (params.size() > 5)
- alert.nCancel = params[5].get_int();
+ alert.nPriority = params[4].get_int();
+ alert.nID = params[5].get_int();
+ if (params.size() > 6)
+ alert.nCancel = params[6].get_int();
alert.nVersion = PROTOCOL_VERSION;
alert.nRelayUntil = GetAdjustedTime() + 365*24*60*60;
alert.nExpiration = GetAdjustedTime() + 365*24*60*60;
- alert.nPriority = 1;
CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
sMsg << (CUnsignedAlert)alert;
result.push_back(Pair("nVersion", alert.nVersion));
result.push_back(Pair("nMinVer", alert.nMinVer));
result.push_back(Pair("nMaxVer", alert.nMaxVer));
+ result.push_back(Pair("nPriority", alert.nPriority));
result.push_back(Pair("nID", alert.nID));
if (alert.nCancel > 0)
result.push_back(Pair("nCancel", alert.nCancel));
return result;
}
-// ppcoin: send checkpoint
-Value sendcheckpoint(const Array& params, bool fHelp)
-{
- if (fHelp || params.size() > 2 || params.size() < 1 )
- throw runtime_error(
- "sendcheckpoint <privatekey> [checkpointhash]\n"
- "<privatekey> is hex string of checkpoint master private key\n"
- "<checkpointhash> is the hash of checkpoint block\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");
- }
-
- 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());
- 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);
- }
-
- 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;
-}
//
{ "repairwallet", &repairwallet, false},
{ "makekeypair", &makekeypair, false},
{ "sendalert", &sendalert, false},
- { "sendcheckpoint", &sendcheckpoint, false},
};
CRPCTable::CRPCTable()
if (strMethod == "sendalert" && n > 3) ConvertTo<boost::int64_t>(params[3]);
if (strMethod == "sendalert" && n > 4) ConvertTo<boost::int64_t>(params[4]);
if (strMethod == "sendalert" && n > 5) ConvertTo<boost::int64_t>(params[5]);
+ if (strMethod == "sendalert" && n > 6) ConvertTo<boost::int64_t>(params[6]);
if (strMethod == "sendmany" && n > 1)
{
string s = params[1].get_str();