Merge #9476: [refactor] Remove using namespace <xxx> from rpc/ & script/ sources
8cbfc4e Refactor: Remove using namespace <xxx> from script/ (Karl-Johan Alm) f3c264e Refactor: Remove using namespace <xxx> from rpc/ (Karl-Johan Alm) Tree-SHA512: 407e80eeda0b8e1df22c5fcba33572e117542fde83c67357f6c2d98fa60bcc7b21bb88ad9a1ee59062fbec17fadaa4836b69e8e6d18188b4027b794357634467
This commit is contained in:
parent
e71cb3861d
commit
ccca7af09e
@ -30,7 +30,6 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
using namespace std;
|
||||
|
||||
struct CUpdatedBlock
|
||||
{
|
||||
@ -149,7 +148,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
|
||||
UniValue getblockcount(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getblockcount\n"
|
||||
"\nReturns the number of blocks in the longest blockchain.\n"
|
||||
"\nResult:\n"
|
||||
@ -166,7 +165,7 @@ UniValue getblockcount(const JSONRPCRequest& request)
|
||||
UniValue getbestblockhash(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getbestblockhash\n"
|
||||
"\nReturns the hash of the best (tip) block in the longest blockchain.\n"
|
||||
"\nResult:\n"
|
||||
@ -193,7 +192,7 @@ void RPCNotifyBlockChange(bool ibd, const CBlockIndex * pindex)
|
||||
UniValue waitfornewblock(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() > 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"waitfornewblock (timeout)\n"
|
||||
"\nWaits for a specific new block and returns useful info about it.\n"
|
||||
"\nReturns the current block on timeout or exit.\n"
|
||||
@ -231,7 +230,7 @@ UniValue waitfornewblock(const JSONRPCRequest& request)
|
||||
UniValue waitforblock(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"waitforblock <blockhash> (timeout)\n"
|
||||
"\nWaits for a specific new block and returns useful info about it.\n"
|
||||
"\nReturns the current block on timeout or exit.\n"
|
||||
@ -273,7 +272,7 @@ UniValue waitforblock(const JSONRPCRequest& request)
|
||||
UniValue waitforblockheight(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"waitforblockheight <height> (timeout)\n"
|
||||
"\nWaits for (at least) block height and returns the height and hash\n"
|
||||
"of the current tip.\n"
|
||||
@ -315,7 +314,7 @@ UniValue waitforblockheight(const JSONRPCRequest& request)
|
||||
UniValue getdifficulty(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getdifficulty\n"
|
||||
"\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n"
|
||||
"\nResult:\n"
|
||||
@ -367,7 +366,7 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
|
||||
info.push_back(Pair("ancestorsize", e.GetSizeWithAncestors()));
|
||||
info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors()));
|
||||
const CTransaction& tx = e.GetTx();
|
||||
set<string> setDepends;
|
||||
std::set<std::string> setDepends;
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
{
|
||||
if (mempool.exists(txin.prevout.hash))
|
||||
@ -375,7 +374,7 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
|
||||
}
|
||||
|
||||
UniValue depends(UniValue::VARR);
|
||||
BOOST_FOREACH(const string& dep, setDepends)
|
||||
BOOST_FOREACH(const std::string& dep, setDepends)
|
||||
{
|
||||
depends.push_back(dep);
|
||||
}
|
||||
@ -400,7 +399,7 @@ UniValue mempoolToJSON(bool fVerbose = false)
|
||||
}
|
||||
else
|
||||
{
|
||||
vector<uint256> vtxid;
|
||||
std::vector<uint256> vtxid;
|
||||
mempool.queryHashes(vtxid);
|
||||
|
||||
UniValue a(UniValue::VARR);
|
||||
@ -414,7 +413,7 @@ UniValue mempoolToJSON(bool fVerbose = false)
|
||||
UniValue getrawmempool(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() > 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getrawmempool ( verbose )\n"
|
||||
"\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
|
||||
"\nHint: use getmempoolentry to fetch a specific transaction from the mempool.\n"
|
||||
@ -446,7 +445,7 @@ UniValue getrawmempool(const JSONRPCRequest& request)
|
||||
UniValue getmempoolancestors(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) {
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getmempoolancestors txid (verbose)\n"
|
||||
"\nIf txid is in the mempool, returns all in-mempool ancestors.\n"
|
||||
"\nArguments:\n"
|
||||
@ -510,7 +509,7 @@ UniValue getmempoolancestors(const JSONRPCRequest& request)
|
||||
UniValue getmempooldescendants(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) {
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getmempooldescendants txid (verbose)\n"
|
||||
"\nIf txid is in the mempool, returns all in-mempool descendants.\n"
|
||||
"\nArguments:\n"
|
||||
@ -574,7 +573,7 @@ UniValue getmempooldescendants(const JSONRPCRequest& request)
|
||||
UniValue getmempoolentry(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1) {
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getmempoolentry txid\n"
|
||||
"\nReturns mempool data for given transaction\n"
|
||||
"\nArguments:\n"
|
||||
@ -641,7 +640,7 @@ UniValue getblockhashes(const JSONRPCRequest& request)
|
||||
UniValue getblockhash(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getblockhash height\n"
|
||||
"\nReturns hash of block in best-block-chain at height provided.\n"
|
||||
"\nArguments:\n"
|
||||
@ -666,7 +665,7 @@ UniValue getblockhash(const JSONRPCRequest& request)
|
||||
UniValue getblockheader(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getblockheader \"hash\" ( verbose )\n"
|
||||
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.\n"
|
||||
"If verbose is true, returns an Object with information about blockheader <hash>.\n"
|
||||
@ -814,7 +813,7 @@ UniValue getblockheaders(const JSONRPCRequest& request)
|
||||
UniValue getblock(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getblock \"blockhash\" ( verbose )\n"
|
||||
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
|
||||
"If verbose is true, returns an Object with information about block <hash>.\n"
|
||||
@ -952,7 +951,7 @@ static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
|
||||
UniValue pruneblockchain(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"pruneblockchain\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"height\" (numeric, required) The block height to prune up to. May be set to a discrete height, or a unix timestamp\n"
|
||||
@ -1001,7 +1000,7 @@ UniValue pruneblockchain(const JSONRPCRequest& request)
|
||||
UniValue gettxoutsetinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"gettxoutsetinfo\n"
|
||||
"\nReturns statistics about the unspent transaction output set.\n"
|
||||
"Note this call may take some time.\n"
|
||||
@ -1041,7 +1040,7 @@ UniValue gettxoutsetinfo(const JSONRPCRequest& request)
|
||||
UniValue gettxout(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"gettxout \"txid\" n ( include_mempool )\n"
|
||||
"\nReturns details about an unspent transaction output.\n"
|
||||
"\nArguments:\n"
|
||||
@ -1123,7 +1122,7 @@ UniValue verifychain(const JSONRPCRequest& request)
|
||||
int nCheckLevel = GetArg("-checklevel", DEFAULT_CHECKLEVEL);
|
||||
int nCheckDepth = GetArg("-checkblocks", DEFAULT_CHECKBLOCKS);
|
||||
if (request.fHelp || request.params.size() > 2)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"verifychain ( checklevel nblocks )\n"
|
||||
"\nVerifies blockchain database.\n"
|
||||
"\nArguments:\n"
|
||||
@ -1209,7 +1208,7 @@ void BIP9SoftForkDescPushBack(UniValue& bip9_softforks, const std::string &name,
|
||||
UniValue getblockchaininfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getblockchaininfo\n"
|
||||
"Returns an object containing various state info regarding blockchain processing.\n"
|
||||
"\nResult:\n"
|
||||
@ -1303,7 +1302,7 @@ struct CompareBlocksByHeight
|
||||
UniValue getchaintips(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() > 2)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getchaintips ( count branchlen )\n"
|
||||
"Return information about all known tips in the block tree,"
|
||||
" including the main chain as well as orphaned branches.\n"
|
||||
@ -1343,7 +1342,7 @@ UniValue getchaintips(const JSONRPCRequest& request)
|
||||
LOCK(cs_main);
|
||||
|
||||
/*
|
||||
* Idea: the set of chain tips is chainActive.tip, plus orphan blocks which do not have another orphan building off of them.
|
||||
* Idea: the set of chain tips is chainActive.tip, plus orphan blocks which do not have another orphan building off of them.
|
||||
* Algorithm:
|
||||
* - Make one pass through mapBlockIndex, picking out the orphan blocks, and also storing a set of the orphan block's pprev pointers.
|
||||
* - Iterate through the orphan blocks. If the block isn't pointed to by another orphan, it is a chain tip.
|
||||
@ -1396,7 +1395,7 @@ UniValue getchaintips(const JSONRPCRequest& request)
|
||||
obj.push_back(Pair("chainwork", block->nChainWork.GetHex()));
|
||||
obj.push_back(Pair("branchlen", branchLen));
|
||||
|
||||
string status;
|
||||
std::string status;
|
||||
if (chainActive.Contains(block)) {
|
||||
// This block is part of the currently active chain.
|
||||
status = "active";
|
||||
@ -1440,7 +1439,7 @@ UniValue mempoolInfoToJSON()
|
||||
UniValue getmempoolinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getmempoolinfo\n"
|
||||
"\nReturns details on the active state of the TX memory pool.\n"
|
||||
"\nResult:\n"
|
||||
@ -1462,7 +1461,7 @@ UniValue getmempoolinfo(const JSONRPCRequest& request)
|
||||
UniValue preciousblock(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"preciousblock \"blockhash\"\n"
|
||||
"\nTreats a block as if it were received before others with the same work.\n"
|
||||
"\nA later preciousblock call can override the effect of an earlier one.\n"
|
||||
@ -1500,7 +1499,7 @@ UniValue preciousblock(const JSONRPCRequest& request)
|
||||
UniValue invalidateblock(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"invalidateblock \"blockhash\"\n"
|
||||
"\nPermanently marks a block as invalid, as if it violated a consensus rule.\n"
|
||||
"\nArguments:\n"
|
||||
@ -1538,7 +1537,7 @@ UniValue invalidateblock(const JSONRPCRequest& request)
|
||||
UniValue reconsiderblock(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"reconsiderblock \"blockhash\"\n"
|
||||
"\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n"
|
||||
"This can be used to undo the effects of invalidateblock.\n"
|
||||
|
@ -14,8 +14,6 @@
|
||||
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
|
||||
#include <univalue.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class CRPCConvertParam
|
||||
{
|
||||
public:
|
||||
@ -204,7 +202,7 @@ UniValue ParseNonRFCJSONValue(const std::string& strVal)
|
||||
UniValue jVal;
|
||||
if (!jVal.read(std::string("[")+strVal+std::string("]")) ||
|
||||
!jVal.isArray() || jVal.size()!=1)
|
||||
throw runtime_error(string("Error parsing JSON:")+strVal);
|
||||
throw std::runtime_error(std::string("Error parsing JSON:")+strVal);
|
||||
return jVal[0];
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,6 @@
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Return average network hashes per second based on the last 'lookup' blocks,
|
||||
* or from the last difficulty change if 'lookup' is nonpositive.
|
||||
@ -83,7 +81,7 @@ UniValue GetNetworkHashPS(int lookup, int height) {
|
||||
UniValue getnetworkhashps(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() > 2)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getnetworkhashps ( nblocks height )\n"
|
||||
"\nReturns the estimated network hashes per second based on the last n blocks.\n"
|
||||
"Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n"
|
||||
@ -155,7 +153,7 @@ UniValue generateBlocks(boost::shared_ptr<CReserveScript> coinbaseScript, int nG
|
||||
UniValue generate(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"generate nblocks ( maxtries )\n"
|
||||
"\nMine up to nblocks blocks immediately (before the RPC call returns)\n"
|
||||
"\nArguments:\n"
|
||||
@ -191,7 +189,7 @@ UniValue generate(const JSONRPCRequest& request)
|
||||
UniValue generatetoaddress(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"generatetoaddress nblocks address (maxtries)\n"
|
||||
"\nMine blocks immediately to a specified address (before the RPC call returns)\n"
|
||||
"\nArguments:\n"
|
||||
@ -214,7 +212,7 @@ UniValue generatetoaddress(const JSONRPCRequest& request)
|
||||
CBitcoinAddress address(request.params[1].get_str());
|
||||
if (!address.IsValid())
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
|
||||
|
||||
|
||||
boost::shared_ptr<CReserveScript> coinbaseScript(new CReserveScript());
|
||||
coinbaseScript->reserveScript = GetScriptForDestination(address.Get());
|
||||
|
||||
@ -224,7 +222,7 @@ UniValue generatetoaddress(const JSONRPCRequest& request)
|
||||
UniValue getmininginfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getmininginfo\n"
|
||||
"\nReturns a json object containing mining-related information."
|
||||
"\nResult:\n"
|
||||
@ -263,7 +261,7 @@ UniValue getmininginfo(const JSONRPCRequest& request)
|
||||
UniValue prioritisetransaction(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 3)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"prioritisetransaction <txid> <priority delta> <fee delta>\n"
|
||||
"Accepts the transaction into mined blocks at a higher (or lower) priority\n"
|
||||
"\nArguments:\n"
|
||||
@ -322,7 +320,7 @@ std::string gbt_vb_name(const Consensus::DeploymentPos pos) {
|
||||
UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() > 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getblocktemplate ( TemplateRequest )\n"
|
||||
"\nIf the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n"
|
||||
"It returns data needed to construct a block to work on.\n"
|
||||
@ -586,7 +584,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
UniValue aCaps(UniValue::VARR); aCaps.push_back("proposal");
|
||||
|
||||
UniValue transactions(UniValue::VARR);
|
||||
map<uint256, int64_t> setTxIndex;
|
||||
std::map<uint256, int64_t> setTxIndex;
|
||||
int i = 0;
|
||||
for (const auto& it : pblock->vtx) {
|
||||
const CTransaction& tx = *it;
|
||||
@ -754,7 +752,7 @@ protected:
|
||||
UniValue submitblock(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) {
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"submitblock \"hexdata\" ( \"jsonparametersobject\" )\n"
|
||||
"\nAttempts to submit new block to network.\n"
|
||||
"The 'jsonparametersobject' parameter is currently ignored.\n"
|
||||
@ -820,7 +818,7 @@ UniValue submitblock(const JSONRPCRequest& request)
|
||||
UniValue estimatefee(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"estimatefee nblocks\n"
|
||||
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
|
||||
"confirmation within nblocks blocks.\n"
|
||||
@ -880,7 +878,7 @@ UniValue estimatepriority(const JSONRPCRequest& request)
|
||||
UniValue estimatesmartfee(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"estimatesmartfee nblocks\n"
|
||||
"\nWARNING: This interface is unstable and may disappear or change!\n"
|
||||
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
|
||||
|
@ -30,8 +30,6 @@
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* @note Do not add or change anything in the information returned by this
|
||||
* method. `getinfo` exists for backwards-compatibility only. It combines
|
||||
@ -48,7 +46,7 @@ using namespace std;
|
||||
UniValue getinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getinfo\n"
|
||||
"\nDEPRECATED. Returns an object containing various state info.\n"
|
||||
"\nResult:\n"
|
||||
@ -100,7 +98,7 @@ UniValue getinfo(const JSONRPCRequest& request)
|
||||
obj.push_back(Pair("timeoffset", GetTimeOffset()));
|
||||
if(g_connman)
|
||||
obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL)));
|
||||
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string())));
|
||||
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string())));
|
||||
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
|
||||
obj.push_back(Pair("testnet", Params().NetworkIDString() == CBaseChainParams::TESTNET));
|
||||
#ifdef ENABLE_WALLET
|
||||
@ -280,7 +278,7 @@ UniValue spork(const JSONRPCRequest& request)
|
||||
UniValue validateaddress(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"validateaddress \"address\"\n"
|
||||
"\nReturn information about the given dash address.\n"
|
||||
"\nArguments:\n"
|
||||
@ -319,7 +317,7 @@ UniValue validateaddress(const JSONRPCRequest& request)
|
||||
if (isValid)
|
||||
{
|
||||
CTxDestination dest = address.Get();
|
||||
string currentAddress = address.ToString();
|
||||
std::string currentAddress = address.ToString();
|
||||
ret.push_back(Pair("address", currentAddress));
|
||||
|
||||
CScript scriptPubKey = GetScriptForDestination(dest);
|
||||
@ -365,13 +363,13 @@ CScript _createmultisig_redeemScript(const UniValue& params)
|
||||
|
||||
// Gather public keys
|
||||
if (nRequired < 1)
|
||||
throw runtime_error("a multisignature address must require at least one key to redeem");
|
||||
throw std::runtime_error("a multisignature address must require at least one key to redeem");
|
||||
if ((int)keys.size() < nRequired)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
strprintf("not enough keys supplied "
|
||||
"(got %u keys, but need at least %d to redeem)", keys.size(), nRequired));
|
||||
if (keys.size() > 16)
|
||||
throw runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number");
|
||||
throw std::runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number");
|
||||
std::vector<CPubKey> pubkeys;
|
||||
pubkeys.resize(keys.size());
|
||||
for (unsigned int i = 0; i < keys.size(); i++)
|
||||
@ -384,14 +382,14 @@ CScript _createmultisig_redeemScript(const UniValue& params)
|
||||
{
|
||||
CKeyID keyID;
|
||||
if (!address.GetKeyID(keyID))
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
strprintf("%s does not refer to a key",ks));
|
||||
CPubKey vchPubKey;
|
||||
if (!pwalletMain->GetPubKey(keyID, vchPubKey))
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
strprintf("no full public key for address %s",ks));
|
||||
if (!vchPubKey.IsFullyValid())
|
||||
throw runtime_error(" Invalid public key: "+ks);
|
||||
throw std::runtime_error(" Invalid public key: "+ks);
|
||||
pubkeys[i] = vchPubKey;
|
||||
}
|
||||
|
||||
@ -402,18 +400,18 @@ CScript _createmultisig_redeemScript(const UniValue& params)
|
||||
{
|
||||
CPubKey vchPubKey(ParseHex(ks));
|
||||
if (!vchPubKey.IsFullyValid())
|
||||
throw runtime_error(" Invalid public key: "+ks);
|
||||
throw std::runtime_error(" Invalid public key: "+ks);
|
||||
pubkeys[i] = vchPubKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw runtime_error(" Invalid public key: "+ks);
|
||||
throw std::runtime_error(" Invalid public key: "+ks);
|
||||
}
|
||||
}
|
||||
CScript result = GetScriptForMultisig(nRequired, pubkeys);
|
||||
|
||||
if (result.size() > MAX_SCRIPT_ELEMENT_SIZE)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE));
|
||||
|
||||
return result;
|
||||
@ -423,7 +421,7 @@ UniValue createmultisig(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 2 || request.params.size() > 2)
|
||||
{
|
||||
string msg = "createmultisig nrequired [\"key\",...]\n"
|
||||
std::string msg = "createmultisig nrequired [\"key\",...]\n"
|
||||
"\nCreates a multi-signature address with n signature of m keys required.\n"
|
||||
"It returns a json object with the address and redeemScript.\n"
|
||||
|
||||
@ -447,7 +445,7 @@ UniValue createmultisig(const JSONRPCRequest& request)
|
||||
"\nAs a json rpc call\n"
|
||||
+ HelpExampleRpc("createmultisig", "2, \"[\\\"Xt4qk9uKvQYAonVGSZNXqxeDmtjaEWgfrs\\\",\\\"XoSoWQkpgLpppPoyyzbUFh1fq2RBvW6UK1\\\"]\"")
|
||||
;
|
||||
throw runtime_error(msg);
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
|
||||
// Construct using pay-to-script-hash:
|
||||
@ -465,7 +463,7 @@ UniValue createmultisig(const JSONRPCRequest& request)
|
||||
UniValue verifymessage(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 3)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"verifymessage \"address\" \"signature\" \"message\"\n"
|
||||
"\nVerify a signed message\n"
|
||||
"\nArguments:\n"
|
||||
@ -487,9 +485,9 @@ UniValue verifymessage(const JSONRPCRequest& request)
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
string strAddress = request.params[0].get_str();
|
||||
string strSign = request.params[1].get_str();
|
||||
string strMessage = request.params[2].get_str();
|
||||
std::string strAddress = request.params[0].get_str();
|
||||
std::string strSign = request.params[1].get_str();
|
||||
std::string strMessage = request.params[2].get_str();
|
||||
|
||||
CBitcoinAddress addr(strAddress);
|
||||
if (!addr.IsValid())
|
||||
@ -500,7 +498,7 @@ UniValue verifymessage(const JSONRPCRequest& request)
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
|
||||
|
||||
bool fInvalid = false;
|
||||
vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid);
|
||||
std::vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid);
|
||||
|
||||
if (fInvalid)
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
|
||||
@ -519,7 +517,7 @@ UniValue verifymessage(const JSONRPCRequest& request)
|
||||
UniValue signmessagewithprivkey(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 2)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"signmessagewithprivkey \"privkey\" \"message\"\n"
|
||||
"\nSign a message with the private key of an address\n"
|
||||
"\nArguments:\n"
|
||||
@ -536,8 +534,8 @@ UniValue signmessagewithprivkey(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"")
|
||||
);
|
||||
|
||||
string strPrivkey = request.params[0].get_str();
|
||||
string strMessage = request.params[1].get_str();
|
||||
std::string strPrivkey = request.params[0].get_str();
|
||||
std::string strMessage = request.params[1].get_str();
|
||||
|
||||
CBitcoinSecret vchSecret;
|
||||
bool fGood = vchSecret.SetString(strPrivkey);
|
||||
@ -551,7 +549,7 @@ UniValue signmessagewithprivkey(const JSONRPCRequest& request)
|
||||
ss << strMessageMagic;
|
||||
ss << strMessage;
|
||||
|
||||
vector<unsigned char> vchSig;
|
||||
std::vector<unsigned char> vchSig;
|
||||
if (!key.SignCompact(ss.GetHash(), vchSig))
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed");
|
||||
|
||||
@ -561,7 +559,7 @@ UniValue signmessagewithprivkey(const JSONRPCRequest& request)
|
||||
UniValue setmocktime(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"setmocktime timestamp\n"
|
||||
"\nSet the local time to given timestamp (-regtest only)\n"
|
||||
"\nArguments:\n"
|
||||
@ -570,7 +568,7 @@ UniValue setmocktime(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
if (!Params().MineBlocksOnDemand())
|
||||
throw runtime_error("setmocktime for regression testing (-regtest mode) only");
|
||||
throw std::runtime_error("setmocktime for regression testing (-regtest mode) only");
|
||||
|
||||
// For now, don't change mocktime if we're in the middle of validation, as
|
||||
// this could have an effect on mempool time-based eviction, as well as
|
||||
@ -1074,7 +1072,7 @@ UniValue getmemoryinfo(const JSONRPCRequest& request)
|
||||
* as users will undoubtedly confuse it with the other "memory pool"
|
||||
*/
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getmemoryinfo\n"
|
||||
"Returns an object containing information about memory usage.\n"
|
||||
"\nResult:\n"
|
||||
@ -1100,7 +1098,7 @@ UniValue getmemoryinfo(const JSONRPCRequest& request)
|
||||
UniValue echo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"echo|echojson \"message\" ...\n"
|
||||
"\nSimply echo back the input arguments. This command is for testing.\n"
|
||||
"\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in"
|
||||
|
@ -24,12 +24,10 @@
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
UniValue getconnectioncount(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getconnectioncount\n"
|
||||
"\nReturns the number of connections to other nodes.\n"
|
||||
"\nResult:\n"
|
||||
@ -48,7 +46,7 @@ UniValue getconnectioncount(const JSONRPCRequest& request)
|
||||
UniValue ping(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"ping\n"
|
||||
"\nRequests that a ping be sent to all other nodes, to measure ping time.\n"
|
||||
"Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n"
|
||||
@ -71,7 +69,7 @@ UniValue ping(const JSONRPCRequest& request)
|
||||
UniValue getpeerinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getpeerinfo\n"
|
||||
"\nReturns data about each connected network node as a json array of objects.\n"
|
||||
"\nResult:\n"
|
||||
@ -103,7 +101,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
|
||||
" n, (numeric) The heights of blocks we're currently asking from this peer\n"
|
||||
" ...\n"
|
||||
" ],\n"
|
||||
" \"whitelisted\": true|false, (boolean) Whether the peer is whitelisted\n"
|
||||
" \"whitelisted\": true|false, (boolean) Whether the peer is whitelisted\n"
|
||||
" \"bytessent_per_msg\": {\n"
|
||||
" \"addr\": n, (numeric) The total bytes sent aggregated by message type\n"
|
||||
" ...\n"
|
||||
@ -123,7 +121,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
|
||||
if(!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
|
||||
vector<CNodeStats> vstats;
|
||||
std::vector<CNodeStats> vstats;
|
||||
g_connman->GetNodeStats(vstats);
|
||||
|
||||
UniValue ret(UniValue::VARR);
|
||||
@ -192,12 +190,12 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
|
||||
|
||||
UniValue addnode(const JSONRPCRequest& request)
|
||||
{
|
||||
string strCommand;
|
||||
std::string strCommand;
|
||||
if (request.params.size() == 2)
|
||||
strCommand = request.params[1].get_str();
|
||||
if (request.fHelp || request.params.size() != 2 ||
|
||||
(strCommand != "onetry" && strCommand != "add" && strCommand != "remove"))
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"addnode \"node\" \"add|remove|onetry\"\n"
|
||||
"\nAttempts add or remove a node from the addnode list.\n"
|
||||
"Or try a connection to a node once.\n"
|
||||
@ -212,7 +210,7 @@ UniValue addnode(const JSONRPCRequest& request)
|
||||
if(!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
|
||||
string strNode = request.params[0].get_str();
|
||||
std::string strNode = request.params[0].get_str();
|
||||
|
||||
if (strCommand == "onetry")
|
||||
{
|
||||
@ -238,7 +236,7 @@ UniValue addnode(const JSONRPCRequest& request)
|
||||
UniValue disconnectnode(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"disconnectnode \"address\" \n"
|
||||
"\nImmediately disconnects from the specified node.\n"
|
||||
"\nArguments:\n"
|
||||
@ -261,7 +259,7 @@ UniValue disconnectnode(const JSONRPCRequest& request)
|
||||
UniValue getaddednodeinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() > 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getaddednodeinfo ( \"node\" )\n"
|
||||
"\nReturns information about the given added node, or all added nodes\n"
|
||||
"(note that onetry addnodes are not listed here)\n"
|
||||
@ -329,7 +327,7 @@ UniValue getaddednodeinfo(const JSONRPCRequest& request)
|
||||
UniValue getnettotals(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() > 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getnettotals\n"
|
||||
"\nReturns information about network traffic, including bytes in, bytes out,\n"
|
||||
"and current time.\n"
|
||||
@ -385,7 +383,7 @@ static UniValue GetNetworksInfo()
|
||||
obj.push_back(Pair("name", GetNetworkName(network)));
|
||||
obj.push_back(Pair("limited", IsLimited(network)));
|
||||
obj.push_back(Pair("reachable", IsReachable(network)));
|
||||
obj.push_back(Pair("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()));
|
||||
obj.push_back(Pair("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string()));
|
||||
obj.push_back(Pair("proxy_randomize_credentials", proxy.randomize_credentials));
|
||||
networks.push_back(obj);
|
||||
}
|
||||
@ -395,7 +393,7 @@ static UniValue GetNetworksInfo()
|
||||
UniValue getnetworkinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getnetworkinfo\n"
|
||||
"Returns an object containing various state info regarding P2P networking.\n"
|
||||
"\nResult:\n"
|
||||
@ -470,12 +468,12 @@ UniValue getnetworkinfo(const JSONRPCRequest& request)
|
||||
|
||||
UniValue setban(const JSONRPCRequest& request)
|
||||
{
|
||||
string strCommand;
|
||||
std::string strCommand;
|
||||
if (request.params.size() >= 2)
|
||||
strCommand = request.params[1].get_str();
|
||||
if (request.fHelp || request.params.size() < 2 ||
|
||||
(strCommand != "add" && strCommand != "remove"))
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"setban \"subnet\" \"add|remove\" (bantime) (absolute)\n"
|
||||
"\nAttempts add or remove a IP/Subnet from the banned list.\n"
|
||||
"\nArguments:\n"
|
||||
@ -495,7 +493,7 @@ UniValue setban(const JSONRPCRequest& request)
|
||||
CNetAddr netAddr;
|
||||
bool isSubnet = false;
|
||||
|
||||
if (request.params[0].get_str().find("/") != string::npos)
|
||||
if (request.params[0].get_str().find("/") != std::string::npos)
|
||||
isSubnet = true;
|
||||
|
||||
if (!isSubnet) {
|
||||
@ -535,7 +533,7 @@ UniValue setban(const JSONRPCRequest& request)
|
||||
UniValue listbanned(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"listbanned\n"
|
||||
"\nList all banned IPs/Subnets.\n"
|
||||
"\nExamples:\n"
|
||||
@ -568,7 +566,7 @@ UniValue listbanned(const JSONRPCRequest& request)
|
||||
UniValue clearbanned(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"clearbanned\n"
|
||||
"\nClear all banned IPs.\n"
|
||||
"\nExamples:\n"
|
||||
@ -586,7 +584,7 @@ UniValue clearbanned(const JSONRPCRequest& request)
|
||||
UniValue setnetworkactive(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1) {
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"setnetworkactive true|false\n"
|
||||
"\nDisable/enable all p2p network activity.\n"
|
||||
"\nArguments:\n"
|
||||
|
@ -16,8 +16,6 @@
|
||||
#include <stdint.h>
|
||||
#include <fstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* JSON-RPC protocol. Bitcoin speaks version 1.0 for maximum compatibility,
|
||||
* but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were
|
||||
@ -27,7 +25,7 @@ using namespace std;
|
||||
* 1.2 spec: http://jsonrpc.org/historical/json-rpc-over-http.html
|
||||
*/
|
||||
|
||||
UniValue JSONRPCRequestObj(const string& strMethod, const UniValue& params, const UniValue& id)
|
||||
UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id)
|
||||
{
|
||||
UniValue request(UniValue::VOBJ);
|
||||
request.push_back(Pair("method", strMethod));
|
||||
@ -48,13 +46,13 @@ UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const Un
|
||||
return reply;
|
||||
}
|
||||
|
||||
string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id)
|
||||
std::string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id)
|
||||
{
|
||||
UniValue reply = JSONRPCReplyObj(result, error, id);
|
||||
return reply.write() + "\n";
|
||||
}
|
||||
|
||||
UniValue JSONRPCError(int code, const string& message)
|
||||
UniValue JSONRPCError(int code, const std::string& message)
|
||||
{
|
||||
UniValue error(UniValue::VOBJ);
|
||||
error.push_back(Pair("code", code));
|
||||
|
@ -35,12 +35,10 @@
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex)
|
||||
{
|
||||
txnouttype type;
|
||||
vector<CTxDestination> addresses;
|
||||
std::vector<CTxDestination> addresses;
|
||||
int nRequired;
|
||||
|
||||
out.push_back(Pair("asm", ScriptToAsmStr(scriptPubKey)));
|
||||
@ -144,7 +142,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
|
||||
UniValue getrawtransaction(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"getrawtransaction \"txid\" ( verbose )\n"
|
||||
|
||||
"\nNOTE: By default this function only works for mempool transactions. If the -txindex option is\n"
|
||||
@ -229,7 +227,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
|
||||
}
|
||||
else {
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid type provided. Verbose parameter must be a boolean.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CTransactionRef tx;
|
||||
@ -239,7 +237,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
|
||||
: "No such mempool transaction. Use -txindex to enable blockchain transaction queries") +
|
||||
". Use gettransaction for wallet transactions.");
|
||||
|
||||
string strHex = EncodeHexTx(*tx);
|
||||
std::string strHex = EncodeHexTx(*tx, RPCSerializationFlags());
|
||||
|
||||
if (!fVerbose)
|
||||
return strHex;
|
||||
@ -253,7 +251,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
|
||||
UniValue gettxoutproof(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || (request.params.size() != 1 && request.params.size() != 2))
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"gettxoutproof [\"txid\",...] ( blockhash )\n"
|
||||
"\nReturns a hex-encoded proof that \"txid\" was included in a block.\n"
|
||||
"\nNOTE: By default this function only works sometimes. This is when there is an\n"
|
||||
@ -276,16 +274,16 @@ UniValue gettxoutproof(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("gettxoutproof", "[\"mytxid\",...], \"blockhash\"")
|
||||
);
|
||||
|
||||
set<uint256> setTxids;
|
||||
std::set<uint256> setTxids;
|
||||
uint256 oneTxid;
|
||||
UniValue txids = request.params[0].get_array();
|
||||
for (unsigned int idx = 0; idx < txids.size(); idx++) {
|
||||
const UniValue& txid = txids[idx];
|
||||
if (txid.get_str().length() != 64 || !IsHex(txid.get_str()))
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid txid ")+txid.get_str());
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid txid ")+txid.get_str());
|
||||
uint256 hash(uint256S(txid.get_str()));
|
||||
if (setTxids.count(hash))
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated txid: ")+txid.get_str());
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated txid: ")+txid.get_str());
|
||||
setTxids.insert(hash);
|
||||
oneTxid = hash;
|
||||
}
|
||||
@ -339,7 +337,7 @@ UniValue gettxoutproof(const JSONRPCRequest& request)
|
||||
UniValue verifytxoutproof(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"verifytxoutproof \"proof\"\n"
|
||||
"\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n"
|
||||
"and throwing an RPC error if the block is not in our best chain\n"
|
||||
@ -359,8 +357,8 @@ UniValue verifytxoutproof(const JSONRPCRequest& request)
|
||||
|
||||
UniValue res(UniValue::VARR);
|
||||
|
||||
vector<uint256> vMatch;
|
||||
vector<unsigned int> vIndex;
|
||||
std::vector<uint256> vMatch;
|
||||
std::vector<unsigned int> vIndex;
|
||||
if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != merkleBlock.header.hashMerkleRoot)
|
||||
return res;
|
||||
|
||||
@ -377,7 +375,7 @@ UniValue verifytxoutproof(const JSONRPCRequest& request)
|
||||
UniValue createrawtransaction(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,\"data\":\"hex\",...} ( locktime )\n"
|
||||
"\nCreate a transaction spending the given inputs and creating new outputs.\n"
|
||||
"Outputs can be addresses or data.\n"
|
||||
@ -458,9 +456,9 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
|
||||
rawTx.vin.push_back(in);
|
||||
}
|
||||
|
||||
set<CBitcoinAddress> setAddress;
|
||||
vector<string> addrList = sendTo.getKeys();
|
||||
BOOST_FOREACH(const string& name_, addrList) {
|
||||
std::set<CBitcoinAddress> setAddress;
|
||||
std::vector<std::string> addrList = sendTo.getKeys();
|
||||
BOOST_FOREACH(const std::string& name_, addrList) {
|
||||
|
||||
if (name_ == "data") {
|
||||
std::vector<unsigned char> data = ParseHexV(sendTo[name_].getValStr(),"Data");
|
||||
@ -470,10 +468,10 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
|
||||
} else {
|
||||
CBitcoinAddress address(name_);
|
||||
if (!address.IsValid())
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Dash address: ")+name_);
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Dash address: ")+name_);
|
||||
|
||||
if (setAddress.count(address))
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+name_);
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ")+name_);
|
||||
setAddress.insert(address);
|
||||
|
||||
CScript scriptPubKey = GetScriptForDestination(address.Get());
|
||||
@ -490,7 +488,7 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
|
||||
UniValue decoderawtransaction(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"decoderawtransaction \"hexstring\"\n"
|
||||
"\nReturn a JSON object representing the serialized, hex-encoded transaction.\n"
|
||||
|
||||
@ -556,7 +554,7 @@ UniValue decoderawtransaction(const JSONRPCRequest& request)
|
||||
UniValue decodescript(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"decodescript \"hexstring\"\n"
|
||||
"\nDecode a hex-encoded script.\n"
|
||||
"\nArguments:\n"
|
||||
@ -583,7 +581,7 @@ UniValue decodescript(const JSONRPCRequest& request)
|
||||
UniValue r(UniValue::VOBJ);
|
||||
CScript script;
|
||||
if (request.params[0].get_str().size() > 0){
|
||||
vector<unsigned char> scriptData(ParseHexV(request.params[0], "argument"));
|
||||
std::vector<unsigned char> scriptData(ParseHexV(request.params[0], "argument"));
|
||||
script = CScript(scriptData.begin(), scriptData.end());
|
||||
} else {
|
||||
// Empty scripts are valid
|
||||
@ -618,7 +616,7 @@ static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::
|
||||
UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"signrawtransaction \"hexstring\" ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] [\"privatekey1\",...] sighashtype )\n"
|
||||
"\nSign inputs for raw transaction (serialized, hex-encoded).\n"
|
||||
"The second optional argument (may be null) is an array of previous transaction outputs that\n"
|
||||
@ -682,9 +680,9 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
#endif
|
||||
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)(UniValue::VARR)(UniValue::VARR)(UniValue::VSTR), true);
|
||||
|
||||
vector<unsigned char> txData(ParseHexV(request.params[0], "argument 1"));
|
||||
std::vector<unsigned char> txData(ParseHexV(request.params[0], "argument 1"));
|
||||
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
|
||||
vector<CMutableTransaction> txVariants;
|
||||
std::vector<CMutableTransaction> txVariants;
|
||||
while (!ssData.empty()) {
|
||||
try {
|
||||
CMutableTransaction tx;
|
||||
@ -765,13 +763,13 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout must be positive");
|
||||
|
||||
COutPoint out(txid, nOut);
|
||||
vector<unsigned char> pkData(ParseHexO(prevOut, "scriptPubKey"));
|
||||
std::vector<unsigned char> pkData(ParseHexO(prevOut, "scriptPubKey"));
|
||||
CScript scriptPubKey(pkData.begin(), pkData.end());
|
||||
|
||||
{
|
||||
const Coin& coin = view.AccessCoin(out);
|
||||
if (!coin.IsSpent() && coin.out.scriptPubKey != scriptPubKey) {
|
||||
string err("Previous output scriptPubKey mismatch:\n");
|
||||
std::string err("Previous output scriptPubKey mismatch:\n");
|
||||
err = err + ScriptToAsmStr(coin.out.scriptPubKey) + "\nvs:\n"+
|
||||
ScriptToAsmStr(scriptPubKey);
|
||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, err);
|
||||
@ -795,7 +793,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
});
|
||||
UniValue v = find_value(prevOut, "redeemScript");
|
||||
if (!v.isNull()) {
|
||||
vector<unsigned char> rsData(ParseHexV(v, "redeemScript"));
|
||||
std::vector<unsigned char> rsData(ParseHexV(v, "redeemScript"));
|
||||
CScript redeemScript(rsData.begin(), rsData.end());
|
||||
tempKeystore.AddCScript(redeemScript);
|
||||
}
|
||||
@ -811,16 +809,16 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
|
||||
int nHashType = SIGHASH_ALL;
|
||||
if (request.params.size() > 3 && !request.params[3].isNull()) {
|
||||
static map<string, int> mapSigHashValues =
|
||||
static std::map<std::string, int> mapSigHashValues =
|
||||
boost::assign::map_list_of
|
||||
(string("ALL"), int(SIGHASH_ALL))
|
||||
(string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))
|
||||
(string("NONE"), int(SIGHASH_NONE))
|
||||
(string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY))
|
||||
(string("SINGLE"), int(SIGHASH_SINGLE))
|
||||
(string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY))
|
||||
(std::string("ALL"), int(SIGHASH_ALL))
|
||||
(std::string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))
|
||||
(std::string("NONE"), int(SIGHASH_NONE))
|
||||
(std::string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY))
|
||||
(std::string("SINGLE"), int(SIGHASH_SINGLE))
|
||||
(std::string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY))
|
||||
;
|
||||
string strHashType = request.params[3].get_str();
|
||||
std::string strHashType = request.params[3].get_str();
|
||||
if (mapSigHashValues.count(strHashType))
|
||||
nHashType = mapSigHashValues[strHashType];
|
||||
else
|
||||
@ -876,7 +874,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
UniValue sendrawtransaction(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"sendrawtransaction \"hexstring\" ( allowhighfees instantsend )\n"
|
||||
"\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n"
|
||||
"\nAlso see createrawtransaction and signrawtransaction calls.\n"
|
||||
|
@ -27,9 +27,6 @@
|
||||
#include <memory> // for unique_ptr
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace RPCServer;
|
||||
using namespace std;
|
||||
|
||||
static bool fRPCRunning = false;
|
||||
static bool fRPCInWarmup = true;
|
||||
static std::string rpcWarmupStatus("RPC server started");
|
||||
@ -68,7 +65,7 @@ void RPCServer::OnPostCommand(boost::function<void (const CRPCCommand&)> slot)
|
||||
}
|
||||
|
||||
void RPCTypeCheck(const UniValue& params,
|
||||
const list<UniValue::VType>& typesExpected,
|
||||
const std::list<UniValue::VType>& typesExpected,
|
||||
bool fAllowNull)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
@ -93,7 +90,7 @@ void RPCTypeCheckArgument(const UniValue& value, UniValue::VType typeExpected)
|
||||
}
|
||||
|
||||
void RPCTypeCheckObj(const UniValue& o,
|
||||
const map<string, UniValueType>& typesExpected,
|
||||
const std::map<std::string, UniValueType>& typesExpected,
|
||||
bool fAllowNull,
|
||||
bool fStrict)
|
||||
{
|
||||
@ -103,7 +100,7 @@ void RPCTypeCheckObj(const UniValue& o,
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first));
|
||||
|
||||
if (!(t.second.typeAny || v.type() == t.second.type || (fAllowNull && v.isNull()))) {
|
||||
string err = strprintf("Expected type %s for %s, got %s",
|
||||
std::string err = strprintf("Expected type %s for %s, got %s",
|
||||
uvTypeName(t.second.type), t.first, uvTypeName(v.type()));
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, err);
|
||||
}
|
||||
@ -111,11 +108,11 @@ void RPCTypeCheckObj(const UniValue& o,
|
||||
|
||||
if (fStrict)
|
||||
{
|
||||
BOOST_FOREACH(const string& k, o.getKeys())
|
||||
BOOST_FOREACH(const std::string& k, o.getKeys())
|
||||
{
|
||||
if (typesExpected.count(k) == 0)
|
||||
{
|
||||
string err = strprintf("Unexpected key %s", k);
|
||||
std::string err = strprintf("Unexpected key %s", k);
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, err);
|
||||
}
|
||||
}
|
||||
@ -144,9 +141,9 @@ UniValue ValueFromAmount(const CAmount& amount)
|
||||
strprintf("%s%d.%08d", sign ? "-" : "", quotient, remainder));
|
||||
}
|
||||
|
||||
uint256 ParseHashV(const UniValue& v, string strName)
|
||||
uint256 ParseHashV(const UniValue& v, std::string strName)
|
||||
{
|
||||
string strHex;
|
||||
std::string strHex;
|
||||
if (v.isStr())
|
||||
strHex = v.get_str();
|
||||
if (!IsHex(strHex)) // Note: IsHex("") is false
|
||||
@ -157,20 +154,20 @@ uint256 ParseHashV(const UniValue& v, string strName)
|
||||
result.SetHex(strHex);
|
||||
return result;
|
||||
}
|
||||
uint256 ParseHashO(const UniValue& o, string strKey)
|
||||
uint256 ParseHashO(const UniValue& o, std::string strKey)
|
||||
{
|
||||
return ParseHashV(find_value(o, strKey), strKey);
|
||||
}
|
||||
vector<unsigned char> ParseHexV(const UniValue& v, string strName)
|
||||
std::vector<unsigned char> ParseHexV(const UniValue& v, std::string strName)
|
||||
{
|
||||
string strHex;
|
||||
std::string strHex;
|
||||
if (v.isStr())
|
||||
strHex = v.get_str();
|
||||
if (!IsHex(strHex))
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
|
||||
return ParseHex(strHex);
|
||||
}
|
||||
vector<unsigned char> ParseHexO(const UniValue& o, string strKey)
|
||||
std::vector<unsigned char> ParseHexO(const UniValue& o, std::string strKey)
|
||||
{
|
||||
return ParseHexV(find_value(o, strKey), strKey);
|
||||
}
|
||||
@ -181,19 +178,19 @@ vector<unsigned char> ParseHexO(const UniValue& o, string strKey)
|
||||
|
||||
std::string CRPCTable::help(const std::string& strCommand) const
|
||||
{
|
||||
string strRet;
|
||||
string category;
|
||||
set<rpcfn_type> setDone;
|
||||
vector<pair<string, const CRPCCommand*> > vCommands;
|
||||
std::string strRet;
|
||||
std::string category;
|
||||
std::set<rpcfn_type> setDone;
|
||||
std::vector<std::pair<std::string, const CRPCCommand*> > vCommands;
|
||||
|
||||
for (map<string, const CRPCCommand*>::const_iterator mi = mapCommands.begin(); mi != mapCommands.end(); ++mi)
|
||||
for (std::map<std::string, const CRPCCommand*>::const_iterator mi = mapCommands.begin(); mi != mapCommands.end(); ++mi)
|
||||
vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second));
|
||||
sort(vCommands.begin(), vCommands.end());
|
||||
|
||||
BOOST_FOREACH(const PAIRTYPE(string, const CRPCCommand*)& command, vCommands)
|
||||
BOOST_FOREACH(const PAIRTYPE(std::string, const CRPCCommand*)& command, vCommands)
|
||||
{
|
||||
const CRPCCommand *pcmd = command.second;
|
||||
string strMethod = pcmd->name;
|
||||
std::string strMethod = pcmd->name;
|
||||
// We already filter duplicates, but these deprecated screw up the sort order
|
||||
if (strMethod.find("label") != string::npos)
|
||||
continue;
|
||||
@ -210,10 +207,10 @@ std::string CRPCTable::help(const std::string& strCommand) const
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Help text is returned in an exception
|
||||
string strHelp = string(e.what());
|
||||
std::string strHelp = std::string(e.what());
|
||||
if (strCommand == "")
|
||||
{
|
||||
if (strHelp.find('\n') != string::npos)
|
||||
if (strHelp.find('\n') != std::string::npos)
|
||||
strHelp = strHelp.substr(0, strHelp.find('\n'));
|
||||
|
||||
if (category != pcmd->category)
|
||||
@ -221,7 +218,7 @@ std::string CRPCTable::help(const std::string& strCommand) const
|
||||
if (!category.empty())
|
||||
strRet += "\n";
|
||||
category = pcmd->category;
|
||||
string firstLetter = category.substr(0,1);
|
||||
std::string firstLetter = category.substr(0,1);
|
||||
boost::to_upper(firstLetter);
|
||||
strRet += "== " + firstLetter + category.substr(1) + " ==\n";
|
||||
}
|
||||
@ -238,7 +235,7 @@ std::string CRPCTable::help(const std::string& strCommand) const
|
||||
UniValue help(const JSONRPCRequest& jsonRequest)
|
||||
{
|
||||
if (jsonRequest.fHelp || jsonRequest.params.size() > 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"help ( \"command\" )\n"
|
||||
"\nList all commands, or get help for a specified command.\n"
|
||||
"\nArguments:\n"
|
||||
@ -247,7 +244,7 @@ UniValue help(const JSONRPCRequest& jsonRequest)
|
||||
"\"text\" (string) The help text\n"
|
||||
);
|
||||
|
||||
string strCommand;
|
||||
std::string strCommand;
|
||||
if (jsonRequest.params.size() > 0)
|
||||
strCommand = jsonRequest.params[0].get_str();
|
||||
|
||||
@ -259,7 +256,7 @@ UniValue stop(const JSONRPCRequest& jsonRequest)
|
||||
{
|
||||
// Accept the deprecated and ignored 'detach' boolean argument
|
||||
if (jsonRequest.fHelp || jsonRequest.params.size() > 1)
|
||||
throw runtime_error(
|
||||
throw std::runtime_error(
|
||||
"stop\n"
|
||||
"\nStop Dash Core server.");
|
||||
// Event loop will exit after current HTTP requests have been handled, so
|
||||
@ -293,7 +290,7 @@ CRPCTable::CRPCTable()
|
||||
|
||||
const CRPCCommand *CRPCTable::operator[](const std::string &name) const
|
||||
{
|
||||
map<string, const CRPCCommand*>::const_iterator it = mapCommands.find(name);
|
||||
std::map<std::string, const CRPCCommand*>::const_iterator it = mapCommands.find(name);
|
||||
if (it == mapCommands.end())
|
||||
return NULL;
|
||||
return (*it).second;
|
||||
@ -305,7 +302,7 @@ bool CRPCTable::appendCommand(const std::string& name, const CRPCCommand* pcmd)
|
||||
return false;
|
||||
|
||||
// don't allow overwriting for now
|
||||
map<string, const CRPCCommand*>::const_iterator it = mapCommands.find(name);
|
||||
std::map<std::string, const CRPCCommand*>::const_iterator it = mapCommands.find(name);
|
||||
if (it != mapCommands.end())
|
||||
return false;
|
||||
|
||||
|
@ -13,9 +13,7 @@
|
||||
#include "script/script.h"
|
||||
#include "uint256.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef vector<unsigned char> valtype;
|
||||
typedef std::vector<unsigned char> valtype;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -56,10 +54,10 @@ bool CastToBool(const valtype& vch)
|
||||
*/
|
||||
#define stacktop(i) (stack.at(stack.size()+(i)))
|
||||
#define altstacktop(i) (altstack.at(altstack.size()+(i)))
|
||||
static inline void popstack(vector<valtype>& stack)
|
||||
static inline void popstack(std::vector<valtype>& stack)
|
||||
{
|
||||
if (stack.empty())
|
||||
throw runtime_error("popstack(): stack empty");
|
||||
throw std::runtime_error("popstack(): stack empty");
|
||||
stack.pop_back();
|
||||
}
|
||||
|
||||
@ -182,7 +180,7 @@ bool static IsDefinedHashtypeSignature(const valtype &vchSig) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckSignatureEncoding(const vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror) {
|
||||
bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror) {
|
||||
// Empty signature. Not strictly DER encoded, but allowed to provide a
|
||||
// compact way to provide an invalid signature for use with CHECK(MULTI)SIG
|
||||
if (vchSig.size() == 0) {
|
||||
@ -229,7 +227,7 @@ bool static CheckMinimalPush(const valtype& data, opcodetype opcode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* serror)
|
||||
bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* serror)
|
||||
{
|
||||
static const CScriptNum bnZero(0);
|
||||
static const CScriptNum bnOne(1);
|
||||
@ -244,8 +242,8 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
|
||||
CScript::const_iterator pbegincodehash = script.begin();
|
||||
opcodetype opcode;
|
||||
valtype vchPushValue;
|
||||
vector<bool> vfExec;
|
||||
vector<valtype> altstack;
|
||||
std::vector<bool> vfExec;
|
||||
std::vector<valtype> altstack;
|
||||
set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR);
|
||||
if (script.size() > MAX_SCRIPT_SIZE)
|
||||
return set_error(serror, SCRIPT_ERR_SCRIPT_SIZE);
|
||||
@ -1148,14 +1146,14 @@ bool TransactionSignatureChecker::VerifySignature(const std::vector<unsigned cha
|
||||
return pubkey.Verify(sighash, vchSig);
|
||||
}
|
||||
|
||||
bool TransactionSignatureChecker::CheckSig(const vector<unsigned char>& vchSigIn, const vector<unsigned char>& vchPubKey, const CScript& scriptCode) const
|
||||
bool TransactionSignatureChecker::CheckSig(const std::vector<unsigned char>& vchSigIn, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode) const
|
||||
{
|
||||
CPubKey pubkey(vchPubKey);
|
||||
if (!pubkey.IsValid())
|
||||
return false;
|
||||
|
||||
// Hash type is one byte tacked on to the end of the signature
|
||||
vector<unsigned char> vchSig(vchSigIn);
|
||||
std::vector<unsigned char> vchSig(vchSigIn);
|
||||
if (vchSig.empty())
|
||||
return false;
|
||||
int nHashType = vchSig.back();
|
||||
@ -1259,7 +1257,7 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, unsigne
|
||||
return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY);
|
||||
}
|
||||
|
||||
vector<vector<unsigned char> > stack, stackCopy;
|
||||
std::vector<std::vector<unsigned char> > stack, stackCopy;
|
||||
if (!EvalScript(stack, scriptSig, flags, checker, serror))
|
||||
// serror is set
|
||||
return false;
|
||||
|
@ -13,11 +13,9 @@
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using namespace std;
|
||||
typedef std::vector<unsigned char> valtype;
|
||||
|
||||
typedef vector<unsigned char> valtype;
|
||||
|
||||
unsigned int HaveKeys(const vector<valtype>& pubkeys, const CKeyStore& keystore)
|
||||
unsigned int HaveKeys(const std::vector<valtype>& pubkeys, const CKeyStore& keystore)
|
||||
{
|
||||
unsigned int nResult = 0;
|
||||
BOOST_FOREACH(const valtype& pubkey, pubkeys)
|
||||
@ -37,7 +35,7 @@ isminetype IsMine(const CKeyStore &keystore, const CTxDestination& dest)
|
||||
|
||||
isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
|
||||
{
|
||||
vector<valtype> vSolutions;
|
||||
std::vector<valtype> vSolutions;
|
||||
txnouttype whichType;
|
||||
if (!Solver(scriptPubKey, whichType, vSolutions)) {
|
||||
if (keystore.HaveWatchOnly(scriptPubKey))
|
||||
@ -79,7 +77,7 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
|
||||
// partially owned (somebody else has a key that can spend
|
||||
// them) enable spend-out-from-under-you attacks, especially
|
||||
// in shared-wallet situations.
|
||||
vector<valtype> keys(vSolutions.begin()+1, vSolutions.begin()+vSolutions.size()-1);
|
||||
std::vector<valtype> keys(vSolutions.begin()+1, vSolutions.begin()+vSolutions.size()-1);
|
||||
if (HaveKeys(keys, keystore) == keys.size())
|
||||
return ISMINE_SPENDABLE;
|
||||
break;
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include "tinyformat.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const char* GetOpName(opcodetype opcode)
|
||||
{
|
||||
switch (opcode)
|
||||
@ -185,7 +183,7 @@ unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const
|
||||
// get the last item that the scriptSig
|
||||
// pushes onto the stack:
|
||||
const_iterator pc = scriptSig.begin();
|
||||
vector<unsigned char> data;
|
||||
std::vector<unsigned char> data;
|
||||
while (pc < scriptSig.end())
|
||||
{
|
||||
opcodetype opcode;
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef std::vector<unsigned char> valtype;
|
||||
|
||||
TransactionSignatureCreator::TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, int nHashTypeIn) : BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), checker(txTo, nIn) {}
|
||||
@ -35,14 +33,14 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
|
||||
|
||||
static bool Sign1(const CKeyID& address, const BaseSignatureCreator& creator, const CScript& scriptCode, CScript& scriptSigRet)
|
||||
{
|
||||
vector<unsigned char> vchSig;
|
||||
std::vector<unsigned char> vchSig;
|
||||
if (!creator.CreateSig(vchSig, address, scriptCode))
|
||||
return false;
|
||||
scriptSigRet << vchSig;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SignN(const vector<valtype>& multisigdata, const BaseSignatureCreator& creator, const CScript& scriptCode, CScript& scriptSigRet)
|
||||
static bool SignN(const std::vector<valtype>& multisigdata, const BaseSignatureCreator& creator, const CScript& scriptCode, CScript& scriptSigRet)
|
||||
{
|
||||
int nSigned = 0;
|
||||
int nRequired = multisigdata.front()[0];
|
||||
@ -67,7 +65,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP
|
||||
{
|
||||
scriptSigRet.clear();
|
||||
|
||||
vector<valtype> vSolutions;
|
||||
std::vector<valtype> vSolutions;
|
||||
if (!Solver(scriptPubKey, whichTypeRet, vSolutions))
|
||||
return false;
|
||||
|
||||
@ -156,11 +154,11 @@ static CScript PushAll(const vector<valtype>& values)
|
||||
}
|
||||
|
||||
static CScript CombineMultisig(const CScript& scriptPubKey, const BaseSignatureChecker& checker,
|
||||
const vector<valtype>& vSolutions,
|
||||
const vector<valtype>& sigs1, const vector<valtype>& sigs2)
|
||||
const std::vector<valtype>& vSolutions,
|
||||
const std::vector<valtype>& sigs1, const std::vector<valtype>& sigs2)
|
||||
{
|
||||
// Combine all the signatures we've got:
|
||||
set<valtype> allsigs;
|
||||
std::set<valtype> allsigs;
|
||||
BOOST_FOREACH(const valtype& v, sigs1)
|
||||
{
|
||||
if (!v.empty())
|
||||
@ -176,7 +174,7 @@ static CScript CombineMultisig(const CScript& scriptPubKey, const BaseSignatureC
|
||||
assert(vSolutions.size() > 1);
|
||||
unsigned int nSigsRequired = vSolutions.front()[0];
|
||||
unsigned int nPubKeys = vSolutions.size()-2;
|
||||
map<valtype, valtype> sigs;
|
||||
std::map<valtype, valtype> sigs;
|
||||
BOOST_FOREACH(const valtype& sig, allsigs)
|
||||
{
|
||||
for (unsigned int i = 0; i < nPubKeys; i++)
|
||||
@ -211,7 +209,7 @@ static CScript CombineMultisig(const CScript& scriptPubKey, const BaseSignatureC
|
||||
}
|
||||
|
||||
static CScript CombineSignatures(const CScript& scriptPubKey, const BaseSignatureChecker& checker,
|
||||
const txnouttype txType, const vector<valtype>& vSolutions,
|
||||
const txnouttype txType, const std::vector<valtype>& vSolutions,
|
||||
vector<valtype>& sigs1, vector<valtype>& sigs2)
|
||||
{
|
||||
switch (txType)
|
||||
@ -240,7 +238,7 @@ static CScript CombineSignatures(const CScript& scriptPubKey, const BaseSignatur
|
||||
CScript pubKey2(spk.begin(), spk.end());
|
||||
|
||||
txnouttype txType2;
|
||||
vector<vector<unsigned char> > vSolutions2;
|
||||
std::vector<std::vector<unsigned char> > vSolutions2;
|
||||
Solver(pubKey2, txType2, vSolutions2);
|
||||
sigs1.pop_back();
|
||||
sigs2.pop_back();
|
||||
@ -266,7 +264,7 @@ CScript CombineSignatures(const CScript& scriptPubKey, const BaseSignatureChecke
|
||||
const CScript& scriptSig1, const CScript& scriptSig2)
|
||||
{
|
||||
txnouttype txType;
|
||||
vector<vector<unsigned char> > vSolutions;
|
||||
std::vector<std::vector<unsigned char> > vSolutions;
|
||||
Solver(scriptPubKey, txType, vSolutions);
|
||||
|
||||
vector<valtype> stack1;
|
||||
|
@ -12,9 +12,7 @@
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef vector<unsigned char> valtype;
|
||||
typedef std::vector<unsigned char> valtype;
|
||||
|
||||
bool fAcceptDatacarrier = DEFAULT_ACCEPT_DATACARRIER;
|
||||
unsigned nMaxDatacarrierBytes = MAX_OP_RETURN_RELAY;
|
||||
@ -38,20 +36,20 @@ const char* GetTxnOutputType(txnouttype t)
|
||||
/**
|
||||
* Return public keys or hashes from scriptPubKey, for 'standard' transaction types.
|
||||
*/
|
||||
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsigned char> >& vSolutionsRet)
|
||||
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet)
|
||||
{
|
||||
// Templates
|
||||
static multimap<txnouttype, CScript> mTemplates;
|
||||
static std::multimap<txnouttype, CScript> mTemplates;
|
||||
if (mTemplates.empty())
|
||||
{
|
||||
// Standard tx, sender provides pubkey, receiver adds signature
|
||||
mTemplates.insert(make_pair(TX_PUBKEY, CScript() << OP_PUBKEY << OP_CHECKSIG));
|
||||
mTemplates.insert(std::make_pair(TX_PUBKEY, CScript() << OP_PUBKEY << OP_CHECKSIG));
|
||||
|
||||
// Bitcoin address tx, sender provides hash of pubkey, receiver provides signature and pubkey
|
||||
mTemplates.insert(make_pair(TX_PUBKEYHASH, CScript() << OP_DUP << OP_HASH160 << OP_PUBKEYHASH << OP_EQUALVERIFY << OP_CHECKSIG));
|
||||
mTemplates.insert(std::make_pair(TX_PUBKEYHASH, CScript() << OP_DUP << OP_HASH160 << OP_PUBKEYHASH << OP_EQUALVERIFY << OP_CHECKSIG));
|
||||
|
||||
// Sender provides N pubkeys, receivers provides M signatures
|
||||
mTemplates.insert(make_pair(TX_MULTISIG, CScript() << OP_SMALLINTEGER << OP_PUBKEYS << OP_SMALLINTEGER << OP_CHECKMULTISIG));
|
||||
mTemplates.insert(std::make_pair(TX_MULTISIG, CScript() << OP_SMALLINTEGER << OP_PUBKEYS << OP_SMALLINTEGER << OP_CHECKMULTISIG));
|
||||
}
|
||||
|
||||
vSolutionsRet.clear();
|
||||
@ -61,7 +59,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
|
||||
if (scriptPubKey.IsPayToScriptHash())
|
||||
{
|
||||
typeRet = TX_SCRIPTHASH;
|
||||
vector<unsigned char> hashBytes(scriptPubKey.begin()+2, scriptPubKey.begin()+22);
|
||||
std::vector<unsigned char> hashBytes(scriptPubKey.begin()+2, scriptPubKey.begin()+22);
|
||||
vSolutionsRet.push_back(hashBytes);
|
||||
return true;
|
||||
}
|
||||
@ -84,7 +82,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
|
||||
vSolutionsRet.clear();
|
||||
|
||||
opcodetype opcode1, opcode2;
|
||||
vector<unsigned char> vch1, vch2;
|
||||
std::vector<unsigned char> vch1, vch2;
|
||||
|
||||
// Compare
|
||||
CScript::const_iterator pc1 = script1.begin();
|
||||
@ -163,7 +161,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
|
||||
|
||||
bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet)
|
||||
{
|
||||
vector<valtype> vSolutions;
|
||||
std::vector<valtype> vSolutions;
|
||||
txnouttype whichType;
|
||||
if (!Solver(scriptPubKey, whichType, vSolutions))
|
||||
return false;
|
||||
@ -191,11 +189,11 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vector<CTxDestination>& addressRet, int& nRequiredRet)
|
||||
bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet)
|
||||
{
|
||||
addressRet.clear();
|
||||
typeRet = TX_NONSTANDARD;
|
||||
vector<valtype> vSolutions;
|
||||
std::vector<valtype> vSolutions;
|
||||
if (!Solver(scriptPubKey, typeRet, vSolutions))
|
||||
return false;
|
||||
if (typeRet == TX_NULL_DATA){
|
||||
|
Loading…
Reference in New Issue
Block a user