Dash Core  0.12.2.1
P2P Digital Currency
rest.cpp File Reference
#include "chain.h"
#include "chainparams.h"
#include "primitives/block.h"
#include "primitives/transaction.h"
#include "validation.h"
#include "httpserver.h"
#include "rpc/server.h"
#include "streams.h"
#include "sync.h"
#include "txmempool.h"
#include "utilstrencodings.h"
#include "version.h"
#include <boost/algorithm/string.hpp>
#include <boost/dynamic_bitset.hpp>
#include <univalue.h>

Go to the source code of this file.

Classes

struct  CCoin
 

Enumerations

enum  RetFormat { RF_UNDEF, RF_BINARY, RF_HEX, RF_JSON }
 

Functions

void TxToJSON (const CTransaction &tx, const uint256 hashBlock, UniValue &entry)
 
UniValue blockToJSON (const CBlock &block, const CBlockIndex *blockindex, bool txDetails=false)
 
UniValue mempoolInfoToJSON ()
 
UniValue mempoolToJSON (bool fVerbose=false)
 
void ScriptPubKeyToJSON (const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
 
UniValue blockheaderToJSON (const CBlockIndex *blockindex)
 
static bool RESTERR (HTTPRequest *req, enum HTTPStatusCode status, string message)
 
static enum RetFormat ParseDataFormat (std::string &param, const std::string &strReq)
 
static string AvailableDataFormatsString ()
 
static bool ParseHashStr (const string &strReq, uint256 &v)
 
static bool CheckWarmup (HTTPRequest *req)
 
static bool rest_headers (HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_block (HTTPRequest *req, const std::string &strURIPart, bool showTxDetails)
 
static bool rest_block_extended (HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_block_notxdetails (HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_chaininfo (HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_mempool_info (HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_mempool_contents (HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_tx (HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_getutxos (HTTPRequest *req, const std::string &strURIPart)
 
bool StartREST ()
 
void InterruptREST ()
 
void StopREST ()
 

Variables

static const size_t MAX_GETUTXOS_OUTPOINTS = 15
 
struct {
   enum RetFormat   rf
 
   const char *   name
 
rf_names []
 
struct {
   const char *   prefix
 
   bool(*   handler )(HTTPRequest *req, const
      std::string &strReq)
 
uri_prefixes []
 

Enumeration Type Documentation

◆ RetFormat

enum RetFormat
Enumerator
RF_UNDEF 
RF_BINARY 
RF_HEX 
RF_JSON 

Definition at line 28 of file rest.cpp.

Function Documentation

◆ AvailableDataFormatsString()

static string AvailableDataFormatsString ( )
static

Definition at line 96 of file rest.cpp.

Referenced by rest_block(), rest_getutxos(), and rest_tx().

◆ blockheaderToJSON()

UniValue blockheaderToJSON ( const CBlockIndex blockindex)

Definition at line 63 of file blockchain.cpp.

Referenced by getblockheader(), getblockheaders(), and rest_headers().

◆ blockToJSON()

UniValue blockToJSON ( const CBlock block,
const CBlockIndex blockindex,
bool  txDetails = false 
)

Definition at line 90 of file blockchain.cpp.

Referenced by getblock(), and rest_block().

◆ CheckWarmup()

static bool CheckWarmup ( HTTPRequest req)
static

◆ InterruptREST()

void InterruptREST ( )

Interrupt RPC REST subsystem.

Definition at line 620 of file rest.cpp.

Referenced by Interrupt().

◆ mempoolInfoToJSON()

UniValue mempoolInfoToJSON ( )

Definition at line 948 of file blockchain.cpp.

Referenced by getmempoolinfo(), and rest_mempool_info().

◆ mempoolToJSON()

UniValue mempoolToJSON ( bool  fVerbose = false)

Definition at line 182 of file blockchain.cpp.

Referenced by getrawmempool(), and rest_mempool_contents().

◆ ParseDataFormat()

static enum RetFormat ParseDataFormat ( std::string &  param,
const std::string &  strReq 
)
static

◆ ParseHashStr()

static bool ParseHashStr ( const string &  strReq,
uint256 v 
)
static

Definition at line 112 of file rest.cpp.

Referenced by rest_block(), rest_headers(), and rest_tx().

◆ rest_block()

static bool rest_block ( HTTPRequest req,
const std::string &  strURIPart,
bool  showTxDetails 
)
static

Definition at line 203 of file rest.cpp.

Referenced by rest_block_extended(), and rest_block_notxdetails().

◆ rest_block_extended()

static bool rest_block_extended ( HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 266 of file rest.cpp.

◆ rest_block_notxdetails()

static bool rest_block_notxdetails ( HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 271 of file rest.cpp.

◆ rest_chaininfo()

static bool rest_chaininfo ( HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 276 of file rest.cpp.

◆ rest_getutxos()

static bool rest_getutxos ( HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 403 of file rest.cpp.

◆ rest_headers()

static bool rest_headers ( HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 129 of file rest.cpp.

◆ rest_mempool_contents()

static bool rest_mempool_contents ( HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 326 of file rest.cpp.

◆ rest_mempool_info()

static bool rest_mempool_info ( HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 301 of file rest.cpp.

◆ rest_tx()

static bool rest_tx ( HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 351 of file rest.cpp.

◆ RESTERR()

static bool RESTERR ( HTTPRequest req,
enum HTTPStatusCode  status,
string  message 
)
static

◆ ScriptPubKeyToJSON()

void ScriptPubKeyToJSON ( const CScript scriptPubKey,
UniValue out,
bool  fIncludeHex 
)

Definition at line 40 of file rawtransaction.cpp.

Referenced by rest_getutxos().

◆ StartREST()

bool StartREST ( )

Start HTTP REST subsystem. Precondition; HTTP and RPC has been started.

Definition at line 613 of file rest.cpp.

Referenced by AppInitServers().

◆ StopREST()

void StopREST ( )

Stop HTTP REST subsystem. Precondition; HTTP and RPC has been stopped.

Definition at line 624 of file rest.cpp.

Referenced by PrepareShutdown().

◆ TxToJSON()

void TxToJSON ( const CTransaction tx,
const uint256  hashBlock,
UniValue entry 
)

Definition at line 64 of file rawtransaction.cpp.

Referenced by rest_tx().

Variable Documentation

◆ handler

bool(* handler) (HTTPRequest *req, const std::string &strReq)

Definition at line 601 of file rest.cpp.

Referenced by RegisterHTTPHandler(), and StartREST().

◆ MAX_GETUTXOS_OUTPOINTS

const size_t MAX_GETUTXOS_OUTPOINTS = 15
static

Definition at line 26 of file rest.cpp.

Referenced by rest_getutxos().

◆ name

◆ prefix

◆ rf

◆ rf_names

const { ... } rf_names[]
Initial value:
= {
{RF_UNDEF, ""},
{RF_BINARY, "bin"},
{RF_HEX, "hex"},
{RF_JSON, "json"},
}
Definition: rest.cpp:31
Definition: rest.cpp:32

Referenced by AvailableDataFormatsString(), and ParseDataFormat().

◆ uri_prefixes

const { ... } uri_prefixes[]
Initial value:
= {
{"/rest/tx/", rest_tx},
{"/rest/block/notxdetails/", rest_block_notxdetails},
{"/rest/block/", rest_block_extended},
{"/rest/chaininfo", rest_chaininfo},
{"/rest/mempool/info", rest_mempool_info},
{"/rest/mempool/contents", rest_mempool_contents},
{"/rest/headers/", rest_headers},
{"/rest/getutxos", rest_getutxos},
}
static bool rest_mempool_info(HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:301
static bool rest_chaininfo(HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:276
static bool rest_tx(HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:351
static bool rest_headers(HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:129
static bool rest_getutxos(HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:403
static bool rest_mempool_contents(HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:326
static bool rest_block_notxdetails(HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:271
static bool rest_block_extended(HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:266

Referenced by StartREST(), and StopREST().