Changeset View
Changeset View
Standalone View
Standalone View
src/rest.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-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 <chain.h> | #include <chain.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <core_io.h> | #include <core_io.h> | ||||
#include <httpserver.h> | #include <httpserver.h> | ||||
#include <index/txindex.h> | |||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <rpc/blockchain.h> | #include <rpc/blockchain.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <streams.h> | #include <streams.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <utilstrencodings.h> | #include <utilstrencodings.h> | ||||
▲ Show 20 Lines • Show All 379 Lines • ▼ Show 20 Lines | static bool rest_tx(Config &config, HTTPRequest *req, | ||||
uint256 hash; | uint256 hash; | ||||
if (!ParseHashStr(hashStr, hash)) { | if (!ParseHashStr(hashStr, hash)) { | ||||
return RESTERR(req, HTTP_BAD_REQUEST, "Invalid hash: " + hashStr); | return RESTERR(req, HTTP_BAD_REQUEST, "Invalid hash: " + hashStr); | ||||
} | } | ||||
const TxId txid(hash); | const TxId txid(hash); | ||||
if (g_txindex) { | |||||
g_txindex->BlockUntilSyncedToCurrentChain(); | |||||
} | |||||
CTransactionRef tx; | CTransactionRef tx; | ||||
uint256 hashBlock = uint256(); | uint256 hashBlock = uint256(); | ||||
if (!GetTransaction(config, txid, tx, hashBlock, true)) { | if (!GetTransaction(config, txid, tx, hashBlock, true)) { | ||||
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); | return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); | ||||
} | } | ||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags()); | CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags()); | ||||
ssTx << tx; | ssTx << tx; | ||||
▲ Show 20 Lines • Show All 287 Lines • Show Last 20 Lines |