X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fbitcoinrpc.cpp;h=b2ff091ddf7a633094d0c0e6930727f5c84c2a58;hb=3a59ce084de0266c56df1e9ffb2fcd38e0ca4ccd;hp=08a1dacf9e0a0a4d6fa4f0194598f1389c2cbefc;hpb=0561bbd1c69263dceb24ffacf850788e6e961a13;p=novacoin.git diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 08a1dac..b2ff091 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -271,9 +271,12 @@ Value getdifficulty(const Array& params, bool fHelp) 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; } @@ -2023,8 +2026,10 @@ Value getcheckpoint(const Array& params, bool fHelp) 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; } @@ -2051,25 +2056,22 @@ Value reservebalance(const Array& params, bool fHelp) 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; } @@ -2159,16 +2161,17 @@ extern map mapAlerts; // 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 [cancelupto]\n" + "sendalert [cancelupto]\n" " is the alert text message\n" " is hex string of alert master private key\n" - " is the minimum applicable client version\n" - " is the maximum applicable client version\n" + " is the minimum applicable internal client version\n" + " is the maximum applicable internal client version\n" + " is integer priority number\n" " 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; @@ -2176,13 +2179,13 @@ Value sendalert(const Array& params, bool fHelp) 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; @@ -2208,66 +2211,13 @@ Value sendalert(const Array& params, bool fHelp) 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 [checkpointhash]\n" - " is hex string of checkpoint master private key\n" - " 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(sMsg.begin(), sMsg.end()); - - vector 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; -} // @@ -2330,7 +2280,6 @@ static const CRPCCommand vRPCCommands[] = { "repairwallet", &repairwallet, false}, { "makekeypair", &makekeypair, false}, { "sendalert", &sendalert, false}, - { "sendcheckpoint", &sendcheckpoint, false}, }; CRPCTable::CRPCTable() @@ -2948,6 +2897,7 @@ int CommandLineRPC(int argc, char *argv[]) if (strMethod == "sendalert" && n > 3) ConvertTo(params[3]); if (strMethod == "sendalert" && n > 4) ConvertTo(params[4]); if (strMethod == "sendalert" && n > 5) ConvertTo(params[5]); + if (strMethod == "sendalert" && n > 6) ConvertTo(params[6]); if (strMethod == "sendmany" && n > 1) { string s = params[1].get_str();