Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 926 Lines • ▼ Show 20 Lines | static UniValue getblockheader(const Config &config, | ||||
if (!pblockindex) { | if (!pblockindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
if (!fVerbose) { | if (!fVerbose) { | ||||
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION); | ||||
ssBlock << pblockindex->GetBlockHeader(); | ssBlock << pblockindex->GetBlockHeader(); | ||||
std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()); | std::string strHex = HexStr(ssBlock); | ||||
return strHex; | return strHex; | ||||
} | } | ||||
return blockheaderToJSON(tip, pblockindex); | return blockheaderToJSON(tip, pblockindex); | ||||
} | } | ||||
static CBlock GetBlockChecked(const Config &config, | static CBlock GetBlockChecked(const Config &config, | ||||
const CBlockIndex *pblockindex) { | const CBlockIndex *pblockindex) { | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | const CBlockIndex *tip; | ||||
block = GetBlockChecked(config, pblockindex); | block = GetBlockChecked(config, pblockindex); | ||||
} | } | ||||
if (verbosity <= 0) { | if (verbosity <= 0) { | ||||
CDataStream ssBlock(SER_NETWORK, | CDataStream ssBlock(SER_NETWORK, | ||||
PROTOCOL_VERSION | RPCSerializationFlags()); | PROTOCOL_VERSION | RPCSerializationFlags()); | ||||
ssBlock << block; | ssBlock << block; | ||||
std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()); | std::string strHex = HexStr(ssBlock); | ||||
return strHex; | return strHex; | ||||
} | } | ||||
return blockToJSON(block, tip, pblockindex, verbosity >= 2); | return blockToJSON(block, tip, pblockindex, verbosity >= 2); | ||||
} | } | ||||
static UniValue pruneblockchain(const Config &config, | static UniValue pruneblockchain(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
▲ Show 20 Lines • Show All 1,605 Lines • ▼ Show 20 Lines | if (request.params[0].get_str() == "status") { | ||||
const Coin &coin = it.second; | const Coin &coin = it.second; | ||||
const CTxOut &txo = coin.GetTxOut(); | const CTxOut &txo = coin.GetTxOut(); | ||||
input_txos.push_back(txo); | input_txos.push_back(txo); | ||||
total_in += txo.nValue; | total_in += txo.nValue; | ||||
UniValue unspent(UniValue::VOBJ); | UniValue unspent(UniValue::VOBJ); | ||||
unspent.pushKV("txid", outpoint.GetTxId().GetHex()); | unspent.pushKV("txid", outpoint.GetTxId().GetHex()); | ||||
unspent.pushKV("vout", int32_t(outpoint.GetN())); | unspent.pushKV("vout", int32_t(outpoint.GetN())); | ||||
unspent.pushKV("scriptPubKey", HexStr(txo.scriptPubKey.begin(), | unspent.pushKV("scriptPubKey", HexStr(txo.scriptPubKey)); | ||||
txo.scriptPubKey.end())); | |||||
unspent.pushKV("desc", descriptors[txo.scriptPubKey]); | unspent.pushKV("desc", descriptors[txo.scriptPubKey]); | ||||
unspent.pushKV("amount", ValueFromAmount(txo.nValue)); | unspent.pushKV("amount", ValueFromAmount(txo.nValue)); | ||||
unspent.pushKV("height", int32_t(coin.GetHeight())); | unspent.pushKV("height", int32_t(coin.GetHeight())); | ||||
unspents.push_back(unspent); | unspents.push_back(unspent); | ||||
} | } | ||||
result.pushKV("unspents", unspents); | result.pushKV("unspents", unspents); | ||||
result.pushKV("total_amount", ValueFromAmount(total_in)); | result.pushKV("total_amount", ValueFromAmount(total_in)); | ||||
▲ Show 20 Lines • Show All 257 Lines • Show Last 20 Lines |