Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
// Copyright (c) 2010 Satoshi Nakamoto | // Copyright (c) 2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "rpc/blockchain.h" | #include "rpc/blockchain.h" | ||||
#include "amount.h" | #include "amount.h" | ||||
#include "chain.h" | #include "chain.h" | ||||
#include "chainparams.h" | #include "chainparams.h" | ||||
#include "checkpoints.h" | #include "checkpoints.h" | ||||
#include "coins.h" | #include "coins.h" | ||||
#include "config.h" | #include "config.h" | ||||
#include "consensus/validation.h" | #include "consensus/validation.h" | ||||
#include "core_io.h" | |||||
#include "hash.h" | #include "hash.h" | ||||
#include "policy/policy.h" | #include "policy/policy.h" | ||||
#include "primitives/transaction.h" | #include "primitives/transaction.h" | ||||
#include "rpc/server.h" | #include "rpc/server.h" | ||||
#include "rpc/tojson.h" | |||||
#include "streams.h" | #include "streams.h" | ||||
#include "sync.h" | #include "sync.h" | ||||
#include "txdb.h" | #include "txdb.h" | ||||
#include "txmempool.h" | #include "txmempool.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
#include "validation.h" | #include "validation.h" | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | UniValue blockToJSON(const Config &config, const CBlock &block, | ||||
result.pushKV("height", blockindex->nHeight); | result.pushKV("height", blockindex->nHeight); | ||||
result.pushKV("version", block.nVersion); | result.pushKV("version", block.nVersion); | ||||
result.pushKV("versionHex", strprintf("%08x", block.nVersion)); | result.pushKV("versionHex", strprintf("%08x", block.nVersion)); | ||||
result.pushKV("merkleroot", block.hashMerkleRoot.GetHex()); | result.pushKV("merkleroot", block.hashMerkleRoot.GetHex()); | ||||
UniValue txs(UniValue::VARR); | UniValue txs(UniValue::VARR); | ||||
for (const auto &tx : block.vtx) { | for (const auto &tx : block.vtx) { | ||||
if (txDetails) { | if (txDetails) { | ||||
UniValue objTx(UniValue::VOBJ); | UniValue objTx(UniValue::VOBJ); | ||||
TxToJSON(config, *tx, uint256(), objTx); | TxToUniv(*tx, uint256(), objTx); | ||||
txs.push_back(objTx); | txs.push_back(objTx); | ||||
} else { | } else { | ||||
txs.push_back(tx->GetId().GetHex()); | txs.push_back(tx->GetId().GetHex()); | ||||
} | } | ||||
} | } | ||||
result.pushKV("tx", txs); | result.pushKV("tx", txs); | ||||
result.pushKV("time", block.GetBlockTime()); | result.pushKV("time", block.GetBlockTime()); | ||||
result.pushKV("mediantime", int64_t(blockindex->GetMedianTimePast())); | result.pushKV("mediantime", int64_t(blockindex->GetMedianTimePast())); | ||||
▲ Show 20 Lines • Show All 1,012 Lines • ▼ Show 20 Lines | UniValue gettxout(const Config &config, const JSONRPCRequest &request) { | ||||
if (coin.GetHeight() == MEMPOOL_HEIGHT) { | if (coin.GetHeight() == MEMPOOL_HEIGHT) { | ||||
ret.pushKV("confirmations", 0); | ret.pushKV("confirmations", 0); | ||||
} else { | } else { | ||||
ret.pushKV("confirmations", | ret.pushKV("confirmations", | ||||
int64_t(pindex->nHeight - coin.GetHeight() + 1)); | int64_t(pindex->nHeight - coin.GetHeight() + 1)); | ||||
} | } | ||||
ret.pushKV("value", ValueFromAmount(coin.GetTxOut().nValue)); | ret.pushKV("value", ValueFromAmount(coin.GetTxOut().nValue)); | ||||
UniValue o(UniValue::VOBJ); | UniValue o(UniValue::VOBJ); | ||||
ScriptPubKeyToJSON(config, coin.GetTxOut().scriptPubKey, o, true); | ScriptPubKeyToUniv(coin.GetTxOut().scriptPubKey, o, true); | ||||
ret.pushKV("scriptPubKey", o); | ret.pushKV("scriptPubKey", o); | ||||
ret.pushKV("coinbase", coin.IsCoinBase()); | ret.pushKV("coinbase", coin.IsCoinBase()); | ||||
return ret; | return ret; | ||||
} | } | ||||
UniValue verifychain(const Config &config, const JSONRPCRequest &request) { | UniValue verifychain(const Config &config, const JSONRPCRequest &request) { | ||||
int nCheckLevel = gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL); | int nCheckLevel = gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL); | ||||
▲ Show 20 Lines • Show All 698 Lines • Show Last 20 Lines |