#include "kernel.h"
#include "bitcoinrpc.h"
-#include <boost/format.hpp>
-#include <boost/assign/list_of.hpp>
-#include <boost/iterator/counting_iterator.hpp>
using namespace json_spirit;
using namespace std;
if (params.size() != 0)
{
- CBigNum bnTarget(uint256(params[0].get_str()));
+ uint256 bnTarget(params[0].get_str());
nBits = bnTarget.GetCompact();
}
else
" days - time window, 90 days by default.\n"
);
- RPCTypeCheck(params, boost::assign::list_of(obj_type));
+ RPCTypeCheck(params, { obj_type });
- Object scanParams = params[0].get_obj();
+ auto scanParams = params[0].get_obj();
const Value& txid_v = find_value(scanParams, "txid");
if (txid_v.type() != str_type)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing txid key");
- string txid = txid_v.get_str();
+ auto txid = txid_v.get_str();
if (!IsHex(txid))
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected hex txid");
uint256 hash(txid);
int32_t nDays = 90;
- uint32_t nBits = GetNextTargetRequired(pindexBest, true);
+ auto nBits = GetNextTargetRequired(pindexBest, true);
const Value& diff_v = find_value(scanParams, "difficulty");
if (diff_v.type() == real_type || diff_v.type() == int_type)
if (dDiff <= 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, diff must be greater than zero");
- CBigNum bnTarget(nPoWBase);
+ uint256 bnTarget(nPoWBase);
bnTarget *= 1000;
bnTarget /= (int) (dDiff * 1000);
nBits = bnTarget.GetCompact();
const Value& inputs_v = find_value(scanParams, "vout");
if (inputs_v.type() == array_type)
{
- Array inputs = inputs_v.get_array();
+ auto inputs = inputs_v.get_array();
for(const Value &v_out: inputs)
{
int nOut = v_out.get_int();
if (nOut < 0 || nOut > (int)tx.vout.size() - 1)
{
stringstream strErrorMsg;
- strErrorMsg << boost::format("Invalid parameter, input number %d is out of range") % nOut;
+ strErrorMsg << "Invalid parameter, input number " << to_string(nOut) << " is out of range";
throw JSONRPCError(RPC_INVALID_PARAMETER, strErrorMsg.str());
}
if (nOut < 0 || nOut > (int)tx.vout.size() - 1)
{
stringstream strErrorMsg;
- strErrorMsg << boost::format("Invalid parameter, input number %d is out of range") % nOut;
+ strErrorMsg << "Invalid parameter, input number " << to_string(nOut) << " is out of range";
throw JSONRPCError(RPC_INVALID_PARAMETER, strErrorMsg.str());
}
}
else
{
- vInputs = vector<int>(boost::counting_iterator<int>( 0 ), boost::counting_iterator<int>( tx.vout.size() ));
+ for (size_t i = 0; i != tx.vout.size(); ++i) vInputs.push_back(i);
}
CTxDB txdb("r");
if (!GetKernelStakeModifier(block.GetHash(), nStakeModifier))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No kernel stake modifier generated yet");
- std::pair<uint32_t, uint32_t> interval;
+ pair<uint32_t, uint32_t> interval;
interval.first = GetTime();
// Only count coins meeting min age requirement
if (nStakeMinAge + block.nTime > interval.first)
ssKernel << block.nTime << (txindex.pos.nTxPos - txindex.pos.nBlockPos) << tx.nTime << nOut;
auto itK = ssKernel.begin();
- std::vector<std::pair<uint256, uint32_t> > result;
+ vector<pair<uint256, uint32_t> > result;
if (ScanKernelForward((unsigned char *)&itK[0], nBits, tx.nTime, tx.vout[nOut].nValue, interval, result))
{
for(const auto& solution : result)
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
// Save
- mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig);
+ mapNewBlock[pblock->hashMerkleRoot] = { pblock, pblock->vtx[0].vin[0].scriptSig };
// Prebuild hash buffers
char pmidstate[32];
char phash1[64];
FormatHashBuffers(pblock, pmidstate, pdata, phash1);
- uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
+ auto hashTarget = uint256().SetCompact(pblock->nBits);
- CTransaction coinbaseTx = pblock->vtx[0];
- std::vector<uint256> merkle = pblock->GetMerkleBranch(0);
+ auto coinbaseTx = pblock->vtx[0];
+ auto merkle = pblock->GetMerkleBranch(0);
Object result;
- result.push_back(Pair("data", HexStr(BEGIN(pdata), END(pdata))));
- result.push_back(Pair("target", HexStr(BEGIN(hashTarget), END(hashTarget))));
+ result.push_back(Pair("data", HexStr(begin(pdata), end(pdata))));
+ result.push_back(Pair("target", HexStr(hashTarget.begin(), hashTarget.end())));
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << coinbaseTx;
Array merkle_arr;
for(uint256 merkleh : merkle) {
- merkle_arr.push_back(HexStr(BEGIN(merkleh), END(merkleh)));
+ merkle_arr.push_back(HexStr(merkleh.begin(), merkleh.end()));
}
result.push_back(Pair("merkle", merkle_arr));
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
// Save
- mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig);
+ mapNewBlock[pblock->hashMerkleRoot] = { pblock, pblock->vtx[0].vin[0].scriptSig };
// Pre-build hash buffers
char pmidstate[32];
char phash1[64];
FormatHashBuffers(pblock, pmidstate, pdata, phash1);
- uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
+ auto hashTarget = uint256().SetCompact(pblock->nBits);
Object result;
- result.push_back(Pair("midstate", HexStr(BEGIN(pmidstate), END(pmidstate)))); // deprecated
- result.push_back(Pair("data", HexStr(BEGIN(pdata), END(pdata))));
- result.push_back(Pair("hash1", HexStr(BEGIN(phash1), END(phash1)))); // deprecated
- result.push_back(Pair("target", HexStr(BEGIN(hashTarget), END(hashTarget))));
+ result.push_back(Pair("midstate", HexStr(begin(pmidstate), end(pmidstate)))); // deprecated
+ result.push_back(Pair("data", HexStr(begin(pdata), end(pdata))));
+ result.push_back(Pair("hash1", HexStr(begin(phash1), end(phash1)))); // deprecated
+ result.push_back(Pair("target", HexStr(hashTarget.begin(), hashTarget.end())));
return result;
}
else
" \"height\" : height of the next block\n"
"See https://en.bitcoin.it/wiki/BIP_0022 for full specification.");
- std::string strMode = "template";
+ string strMode = "template";
if (params.size() > 0)
{
const Object& oparam = params[0].get_obj();
Object aux;
aux.push_back(Pair("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end())));
- uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
+ auto hashTarget = uint256().SetCompact(pblock->nBits);
static Array aMutable;
if (aMutable.empty())
try {
ssBlock >> block;
}
- catch (const std::exception&) {
+ catch (const exception&) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
}