Bitcoin ABC  0.29.1
P2P Digital Currency
Classes | Enumerations | Functions | Variables
rest.cpp File Reference
#include <chain.h>
#include <chainparams.h>
#include <config.h>
#include <core_io.h>
#include <httpserver.h>
#include <index/txindex.h>
#include <node/blockstorage.h>
#include <node/context.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <rpc/blockchain.h>
#include <rpc/mempool.h>
#include <rpc/protocol.h>
#include <rpc/server.h>
#include <rpc/server_util.h>
#include <streams.h>
#include <sync.h>
#include <txmempool.h>
#include <util/system.h>
#include <validation.h>
#include <version.h>
#include <univalue.h>
#include <any>
Include dependency graph for rest.cpp:

Go to the source code of this file.

Classes

struct  CCoin
 

Enumerations

enum class  RetFormat { UNDEF , BINARY , HEX , JSON }
 

Functions

static bool RESTERR (HTTPRequest *req, enum HTTPStatusCode status, std::string message)
 
static NodeContextGetNodeContext (const std::any &context, HTTPRequest *req)
 Get the node context. More...
 
static CTxMemPoolGetMemPool (const std::any &context, HTTPRequest *req)
 Get the node context mempool. More...
 
static ChainstateManagerGetChainman (const std::any &context, HTTPRequest *req)
 Get the node context chainstatemanager. More...
 
static RetFormat ParseDataFormat (std::string &param, const std::string &strReq)
 
static std::string AvailableDataFormatsString ()
 
static bool CheckWarmup (HTTPRequest *req)
 
static bool rest_headers (Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_block (const Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart, bool showTxDetails)
 
static bool rest_block_extended (Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_block_notxdetails (Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_chaininfo (Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_mempool_info (Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_mempool_contents (Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_tx (Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_getutxos (Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
 
static bool rest_blockhash_by_height (Config &config, const std::any &context, HTTPRequest *req, const std::string &str_uri_part)
 
void StartREST (const std::any &context)
 Start HTTP REST subsystem. More...
 
void InterruptREST ()
 Interrupt RPC REST subsystem. More...
 
void StopREST ()
 Stop HTTP REST subsystem. More...
 

Variables

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

Enumeration Type Documentation

◆ RetFormat

enum RetFormat
strong
Enumerator
UNDEF 
BINARY 
HEX 
JSON 

Definition at line 39 of file rest.cpp.

Function Documentation

◆ AvailableDataFormatsString()

static std::string AvailableDataFormatsString ( )
static

Definition at line 157 of file rest.cpp.

Here is the caller graph for this function:

◆ CheckWarmup()

static bool CheckWarmup ( HTTPRequest req)
static

Definition at line 174 of file rest.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChainman()

static ChainstateManager* GetChainman ( const std::any &  context,
HTTPRequest req 
)
static

Get the node context chainstatemanager.

Parameters
[in]reqThe HTTP request, whose status code will be set if node context chainstatemanager is not found.
Returns
Pointer to the chainstatemanager or nullptr if none found.

Definition at line 120 of file rest.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMemPool()

static CTxMemPool* GetMemPool ( const std::any &  context,
HTTPRequest req 
)
static

Get the node context mempool.

Parameters
[in]reqThe HTTP request, whose status code will be set if node context mempool is not found.
Returns
Pointer to the mempool or nullptr if no mempool found.

Definition at line 104 of file rest.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNodeContext()

static NodeContext* GetNodeContext ( const std::any &  context,
HTTPRequest req 
)
static

Get the node context.

Parameters
[in]reqThe HTTP request, whose status code will be set if node context is not found.
Returns
Pointer to the node context or nullptr if not found.

Definition at line 84 of file rest.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InterruptREST()

void InterruptREST ( )

Interrupt RPC REST subsystem.

Definition at line 844 of file rest.cpp.

Here is the caller graph for this function:

◆ ParseDataFormat()

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

Definition at line 135 of file rest.cpp.

Here is the caller graph for this function:

◆ rest_block()

static bool rest_block ( const Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  strURIPart,
bool  showTxDetails 
)
static

Definition at line 278 of file rest.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rest_block_extended()

static bool rest_block_extended ( Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 359 of file rest.cpp.

Here is the call graph for this function:

◆ rest_block_notxdetails()

static bool rest_block_notxdetails ( Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 365 of file rest.cpp.

Here is the call graph for this function:

◆ rest_blockhash_by_height()

static bool rest_blockhash_by_height ( Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  str_uri_part 
)
static

Definition at line 760 of file rest.cpp.

Here is the call graph for this function:

◆ rest_chaininfo()

static bool rest_chaininfo ( Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 371 of file rest.cpp.

Here is the call graph for this function:

◆ rest_getutxos()

static bool rest_getutxos ( Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 532 of file rest.cpp.

Here is the call graph for this function:

◆ rest_headers()

static bool rest_headers ( Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 184 of file rest.cpp.

Here is the call graph for this function:

◆ rest_mempool_contents()

static bool rest_mempool_contents ( Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 429 of file rest.cpp.

Here is the call graph for this function:

◆ rest_mempool_info()

static bool rest_mempool_info ( Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 399 of file rest.cpp.

Here is the call graph for this function:

◆ rest_tx()

static bool rest_tx ( Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  strURIPart 
)
static

Definition at line 460 of file rest.cpp.

Here is the call graph for this function:

◆ RESTERR()

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

Definition at line 70 of file rest.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartREST()

void StartREST ( const std::any &  context)

Start HTTP REST subsystem.

Precondition; HTTP and RPC has been started.

Definition at line 834 of file rest.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StopREST()

void StopREST ( )

Stop HTTP REST subsystem.

Precondition; HTTP and RPC has been stopped.

Definition at line 846 of file rest.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ handler

bool(* handler) (Config &config, const std::any &context, HTTPRequest *req, const std::string &strReq) ( Config config,
const std::any &  context,
HTTPRequest req,
const std::string &  strReq 
)

Definition at line 820 of file rest.cpp.

◆ MAX_GETUTXOS_OUTPOINTS

const size_t MAX_GETUTXOS_OUTPOINTS = 15
static

Definition at line 37 of file rest.cpp.

◆ name

const char* name

Definition at line 48 of file rest.cpp.

◆ prefix

const char* prefix

Definition at line 819 of file rest.cpp.

◆ rf

Definition at line 47 of file rest.cpp.

◆ 

const { ... } rf_names[]
Initial value:

◆ 

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},
{"/rest/blockhashbyheight/", rest_blockhash_by_height},
}
static bool rest_blockhash_by_height(Config &config, const std::any &context, HTTPRequest *req, const std::string &str_uri_part)
Definition: rest.cpp:760
static bool rest_mempool_info(Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:399
static bool rest_headers(Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:184
static bool rest_block_extended(Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:359
static bool rest_mempool_contents(Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:429
static bool rest_block_notxdetails(Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:365
static bool rest_chaininfo(Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:371
static bool rest_tx(Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:460
static bool rest_getutxos(Config &config, const std::any &context, HTTPRequest *req, const std::string &strURIPart)
Definition: rest.cpp:532