Graphene::App

namespace app

Unnamed Group

template<typename T>
T dejsonify(const string &s, uint32_t max_depth)

::

Typedefs

typedef std::map<std::pair<graphene::chain::asset_id_type, graphene::chain::asset_id_type>, std::vector<fc::variant>> market_queue_type

Functions

void load_configuration_options(const fc::path &data_dir, const bpo::options_description &cfg_options, bpo::variables_map &options)
void load_configuration_options(const fc::path &data_dir, const boost::program_options::options_description &cfg_options, boost::program_options::variables_map &options)
std::string uint128_amount_to_string(const fc::uint128_t &amount, const uint8_t precision)
std::string price_to_string(const graphene::protocol::price &_price, const uint8_t base_precision, const uint8_t quote_precision)
std::string price_to_string(const graphene::protocol::price &_price, const graphene::chain::asset_object &_base, const graphene::chain::asset_object &_quote)
std::string price_diff_percent_string(const graphene::protocol::price &old_price, const graphene::protocol::price &new_price)
static fc::uint128_t to_capped_128(const uint256_t &t)
class abstract_plugin
#include <plugin.hpp>

Subclassed by graphene::app::plugin

Public Functions

virtual std::string plugin_name() const = 0

Get the name of the plugin.

virtual std::string plugin_description() const = 0

Get the description of the plugin.

application &app() const

Get a reference of the application bound to the plugin.

virtual void plugin_initialize(const boost::program_options::variables_map &options) = 0

Perform early startup routines and register plugin indexes, callbacks, etc.

Plugins MUST supply a method initialize() which will be called early in the application startup. This method should contain early setup code such as initializing variables, adding indexes to the database, registering callback methods from the database, adding APIs, etc., as well as applying any options in the options map

This method is called BEFORE the database is open, therefore any routines which require any chain state MUST NOT be called by this method. These routines should be performed in startup() instead.

Parameters
  • options: The options passed to the application, via configuration files or command line

virtual void plugin_startup() = 0

Begin normal runtime operations.

Plugins MUST supply a method startup() which will be called at the end of application startup. This method should contain code which schedules any tasks, or requires chain state.

virtual void plugin_shutdown() = 0

Cleanly shut down the plugin.

This is called to request a clean shutdown (e.g. due to SIGINT or SIGTERM).

virtual void plugin_set_program_options(boost::program_options::options_description &command_line_options, boost::program_options::options_description &config_file_options) = 0

Fill in command line parameters used by the plugin.

This method populates its arguments with any command-line and configuration file options the plugin supports. If a plugin does not need these options, it may simply provide an empty implementation of this method.

Parameters
  • command_line_options: All options this plugin supports taking on the command-line

  • config_file_options: All options this plugin supports storing in a configuration file

class application
#include <application.hpp>

Public Members

boost::signals2::signal<void()> syncing_finished

Emitted when syncing finishes (is_finished_syncing will return true)

class asset_api
#include <api.hpp>

The asset_api class allows query of info about asset holders.

Public Functions

vector<account_asset_balance> get_asset_holders(std::string asset, uint32_t start, uint32_t limit) const

Get asset holders for a specific asset.

Return

A list of asset holders for the specified asset

Parameters
  • asset: The specific asset id or symbol

  • start: The start index

  • limit: Maximum limit must not exceed 100

int get_asset_holders_count(std::string asset) const

Get asset holders count for a specific asset.

Return

Holders count for the specified asset

Parameters
  • asset: The specific asset id or symbol

vector<asset_holders> get_all_asset_holders() const

Get all asset holders.

Return

A list of all asset holders

class block_api
#include <api.hpp>

Block api.

Public Functions

vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to) const

Get signed blocks.

Return

A list of signed blocks from block_num_from till block_num_to

Parameters
  • block_num_from: The lowest block number

  • block_num_to: The highest block number

class crypto_api
#include <api.hpp>

The crypto_api class allows computations related to blinded transfers.

Public Functions

commitment_type blind(const fc::ecc::blind_factor_type &blind, uint64_t value)

Generates a pedersen commitment: *commit = blind * G + value * G2. The commitment is 33 bytes, the blinding factor is 32 bytes. For more information about pederson commitment check url https://en.wikipedia.org/wiki/Commitment_scheme.

Return

A 33-byte pedersen commitment: *commit = blind * G + value * G2

Parameters
  • blind: Sha-256 blind factor type

  • value: Positive 64-bit integer value

blind_factor_type blind_sum(const std::vector<blind_factor_type> &blinds_in, uint32_t non_neg)

Get sha-256 blind factor type.

Return

A blind factor type

Parameters
  • blinds_in: List of sha-256 blind factor types

  • non_neg: 32-bit integer value

bool verify_sum(const std::vector<commitment_type> &commits_in, const std::vector<commitment_type> &neg_commits_in, int64_t excess)

Verifies that commits + neg_commits + excess == 0.

Return

Boolean - true in event of commits + neg_commits + excess == 0, otherwise false

Parameters
  • commits_in: List of 33-byte pedersen commitments

  • neg_commits_in: List of 33-byte pedersen commitments

  • excess: Sum of two list of 33-byte pedersen commitments where sums the first set and subtracts the second

verify_range_result verify_range(const fc::ecc::commitment_type &commit, const std::vector<char> &proof)

Verifies range proof for 33-byte pedersen commitment.

Return

A structure with success, min and max values

Parameters
  • commit: 33-byte pedersen commitment

  • proof: List of characters

std::vector<char> range_proof_sign(uint64_t min_value, const commitment_type &commit, const blind_factor_type &commit_blind, const blind_factor_type &nonce, int8_t base10_exp, uint8_t min_bits, uint64_t actual_value)

Proves with respect to min_value the range for pedersen commitment which has the provided blinding factor and value.

Return

A list of characters as proof in proof

Parameters
  • min_value: Positive 64-bit integer value

  • commit: 33-byte pedersen commitment

  • commit_blind: Sha-256 blind factor type for the correct digits

  • nonce: Sha-256 blind factor type for our non-forged signatures

  • base10_exp: Exponents base 10 in range [-1 ; 18] inclusively

  • min_bits: 8-bit positive integer, must be in range [0 ; 64] inclusively

  • actual_value: 64-bit positive integer, must be greater or equal min_value

verify_range_proof_rewind_result verify_range_proof_rewind(const blind_factor_type &nonce, const fc::ecc::commitment_type &commit, const std::vector<char> &proof)

Verifies range proof rewind for 33-byte pedersen commitment.

Return

A structure with success, min, max, value_out, blind_out and message_out values

Parameters
  • nonce: Sha-256 blind refactor type

  • commit: 33-byte pedersen commitment

  • proof: List of characters

range_proof_info range_get_info(const std::vector<char> &proof)

Gets “range proof” info. The cli_wallet includes functionality for sending blind transfers in which the values of the input and outputs amounts are “blinded.” In the case where a transaction produces two or more outputs, (e.g. an amount to the intended recipient plus “change” back to the sender), a “range proof” must be supplied to prove that none of the outputs commit to a negative value.

Return

A range proof info structure with exponent, mantissa, min and max values

Parameters
  • proof: List of proof’s characters

class custom_operations_api
#include <api.hpp>

The custom_operations_api class exposes access to standard custom objects parsed by the custom_operations_plugin.

Public Functions

vector<account_storage_object> get_storage_info(std::string account_name_or_id, std::string catalog) const

Get all stored objects of an account in a particular catalog.

Return

The vector of objects of the account or empty

Parameters
  • account_name_or_id: The account name or ID to get info from

  • catalog: Category classification. Each account can store multiple catalogs.

class database_api
#include <database_api.hpp>

The database_api class implements the RPC API for the chain database.

This API exposes accessors on the database which query state tracked by a blockchain validating node. This API is read-only; all modifications to the database must be performed via transactions. Transactions are broadcast via the network_broadcast_api.

Public Functions

fc::variants get_objects(const vector<object_id_type> &ids, optional<bool> subscribe = optional<bool>()) const

Get the objects corresponding to the provided IDs.

If any of the provided IDs does not map to an object, a null variant is returned in its position.

Return

The objects retrieved, in the order they are mentioned in ids

Note

operation_history_object (1.11.x) and account_transaction_history_object (2.9.x) can not be subscribed.

Parameters
  • ids: IDs of the objects to retrieve

  • subscribe: true to subscribe to the queried objects; false to not subscribe; null to subscribe or not subscribe according to current auto-subscription setting (see set_auto_subscription)

void set_subscribe_callback(std::function<void(const variant&)> cb, bool notify_remove_create, )

Register a callback handle which then can be used to subscribe to object database changes.

Note: auto-subscription is enabled by default and can be disabled with

set_auto_subscription API.
Parameters
  • cb: The callback handle to register

  • notify_remove_create: Whether subscribe to universal object creation and removal events. If this is set to true, the API server will notify all newly created objects and ID of all newly removed objects to the client, no matter whether client subscribed to the objects. By default, API servers don’t allow subscribing to universal events, which can be changed on server startup.

void set_auto_subscription(bool enable)

Set auto-subscription behavior of follow-up API queries.

Impacts behavior of these APIs:

  • get_accounts

  • get_assets

  • get_objects

  • lookup_accounts

  • get_full_accounts

  • get_htlc

  • get_liquidity_pools

  • get_liquidity_pools_by_share_asset

Parameters
  • enable: whether follow-up API queries will automatically subscribe to queried objects

Note: auto-subscription is enabled by default

See

set_subscribe_callback

void set_pending_transaction_callback(std::function<void(const variant &signed_transaction_object)> cb)

Register a callback handle which will get notified when a transaction is pushed to database.

Note: a transaction can be pushed to database and be popped from database several times while processing, before and after included in a block. Everytime when a push is done, the client will be notified.

Parameters
  • cb: The callback handle to register

void set_block_applied_callback(std::function<void(const variant &block_id)> cb)

Register a callback handle which will get notified when a block is pushed to database.

Parameters
  • cb: The callback handle to register

void cancel_all_subscriptions()

Stop receiving any notifications.

This unsubscribes from all subscribed markets and objects.

optional<block_header> get_block_header(uint32_t block_num) const

Retrieve a block header.

Return

header of the referenced block, or null if no matching block was found

Parameters
  • block_num: Height of the block whose header should be returned

map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums) const

Retrieve multiple block header by block numbers.

Return

array of headers of the referenced blocks, or null if no matching block was found

Parameters
  • block_nums: vector containing heights of the block whose header should be returned

optional<signed_block> get_block(uint32_t block_num) const

Retrieve a full, signed block.

Return

the referenced block, or null if no matching block was found

Parameters
  • block_num: Height of the block to be returned

processed_transaction get_transaction(uint32_t block_num, uint32_t trx_in_block) const

used to fetch an individual transaction.

Return

the transaction at the given position

Parameters
  • block_num: height of the block to fetch

  • trx_in_block: the index (sequence number) of the transaction in the block, starts from 0

optional<signed_transaction> get_recent_transaction_by_id(const transaction_id_type &txid) const

If the transaction has not expired, this method will return the transaction for the given ID or it will return NULL if it is not known. Just because it is not known does not mean it wasn’t included in the blockchain.

Return

the corresponding transaction if found, or null if not found

Parameters
  • txid: hash of the transaction

chain_property_object get_chain_properties() const

Retrieve the graphene::chain::chain_property_object associated with the chain.

global_property_object get_global_properties() const

Retrieve the current graphene::chain::global_property_object.

fc::variant_object get_config() const

Retrieve compile-time constants.

chain_id_type get_chain_id() const

Get the chain ID.

dynamic_global_property_object get_dynamic_global_properties() const

Retrieve the current graphene::chain::dynamic_global_property_object.

vector<flat_set<account_id_type>> get_key_references(vector<public_key_type> keys) const

Get all accounts that refer to the specified public keys in their owner authority, active authorities or memo key.

Return

ID of all accounts that refer to the specified keys

Parameters
  • keys: a list of public keys to query

bool is_public_key_registered(string public_key) const

Determine whether a textual representation of a public key (in Base-58 format) is currently linked to any registered (i.e. non-stealth) account on the blockchain

Return

Whether a public key is known

Parameters
  • public_key: Public key

account_id_type get_account_id_from_string(const std::string &name_or_id) const

Get account object from a name or ID.

Return

Account ID

Parameters
  • name_or_id: name or ID of the account

vector<optional<account_object>> get_accounts(const vector<std::string> &account_names_or_ids, optional<bool> subscribe = optional<bool>()) const

Get a list of accounts by names or IDs.

This function has semantics identical to

get_objects
Return

The accounts corresponding to the provided names or IDs

Parameters
  • account_names_or_ids: names or IDs of the accounts to retrieve

  • subscribe: true to subscribe to the queried account objects; false to not subscribe; null to subscribe or not subscribe according to current auto-subscription setting (see set_auto_subscription)

std::map<string, full_account> get_full_accounts(const vector<string> &names_or_ids, optional<bool> subscribe = optional<bool>())

Fetch all objects relevant to the specified accounts and optionally subscribe to updates.

This function fetches all relevant objects for the given accounts, and subscribes to updates to the given accounts. If any of the strings in

names_or_ids cannot be tied to an account, that input will be ignored. All other accounts will be retrieved and subscribed.
Return

Map of string from names_or_ids to the corresponding account

Parameters
  • names_or_ids: Each item must be the name or ID of an account to retrieve

  • subscribe: true to subscribe to the queried full account objects; false to not subscribe; null to subscribe or not subscribe according to current auto-subscription setting (see set_auto_subscription)

vector<account_statistics_object> get_top_voters(uint32_t limit) const

Returns vector of voting power sorted by reverse vp_active.

Return

Desc Sorted voting power vector

Parameters
  • limit: Max number of results

optional<account_object> get_account_by_name(string name) const

Get info of an account by name.

Return

The account holding the provided name

Parameters
  • name: Name of the account to retrieve

vector<account_id_type> get_account_references(const std::string account_name_or_id) const

Get all accounts that refer to the specified account in their owner or active authorities.

Return

all accounts that refer to the specified account in their owner or active authorities

Parameters
  • account_name_or_id: Account name or ID to query

vector<optional<account_object>> lookup_account_names(const vector<string> &account_names) const

Get a list of accounts by name.

This function has semantics identical to

get_objects, but doesn’t subscribe.
Return

The accounts holding the provided names

Parameters
  • account_names: Names of the accounts to retrieve

map<string, account_id_type> lookup_accounts(const string &lower_bound_name, uint32_t limit, optional<bool> subscribe = optional<bool>()) const

Get names and IDs for registered accounts.

Return

Map of account names to corresponding IDs

Note

In addition to the common auto-subscription rules, this API will subscribe to the returned account only if limit is 1.

Parameters
  • lower_bound_name: Lower bound of the first name to return

  • limit: Maximum number of results to return must not exceed 1000

  • subscribe: true to subscribe to the queried account objects; false to not subscribe; null to subscribe or not subscribe according to current auto-subscription setting (see set_auto_subscription)

vector<asset> get_account_balances(const std::string &account_name_or_id, const flat_set<asset_id_type> &assets) const

Get an account’s balances in various assets.

Return

Balances of the account

Parameters
  • account_name_or_id: name or ID of the account to get balances for

  • assets: IDs of the assets to get balances of; if empty, get all assets account has a balance in

vector<asset> get_named_account_balances(const std::string &name, const flat_set<asset_id_type> &assets) const

Semantically equivalent to get_account_balances.

vector<balance_object> get_balance_objects(const vector<address> &addrs) const

Return all unclaimed balance objects for a list of addresses.

Return

all unclaimed balance objects for the addresses

Parameters
  • addrs: a list of addresses

vector<asset> get_vested_balances(const vector<balance_id_type> &objs) const

Calculate how much assets in the given balance objects are able to be claimed at current head block time.

Return

a list indicating how much asset in each balance object is available to be claimed

Parameters
  • objs: a list of balance object IDs

vector<vesting_balance_object> get_vesting_balances(const std::string account_name_or_id) const

Return all vesting balance objects owned by an account.

Return

all vesting balance objects owned by the account

Parameters
  • account_name_or_id: name or ID of an account

uint64_t get_account_count() const

Get the total number of accounts registered with the blockchain.

asset_id_type get_asset_id_from_string(const std::string &symbol_or_id) const

Get asset ID from an asset symbol or ID.

Return

asset ID

Parameters
  • symbol_or_id: symbol name or ID of the asset

vector<optional<extended_asset_object>> get_assets(const vector<std::string> &asset_symbols_or_ids, optional<bool> subscribe = optional<bool>()) const

Get a list of assets by symbol names or IDs.

This function has semantics identical to

get_objects
Return

The assets corresponding to the provided symbol names or IDs

Parameters
  • asset_symbols_or_ids: symbol names or IDs of the assets to retrieve

  • subscribe: true to subscribe to the queried asset objects; false to not subscribe; null to subscribe or not subscribe according to current auto-subscription setting (see set_auto_subscription)

vector<extended_asset_object> list_assets(const string &lower_bound_symbol, uint32_t limit) const

Get assets alphabetically by symbol name.

Return

The assets found

Parameters
  • lower_bound_symbol: Lower bound of symbol names to retrieve

  • limit: Maximum number of assets to fetch (must not exceed 101)

vector<optional<extended_asset_object>> lookup_asset_symbols(const vector<string> &symbols_or_ids) const

Get a list of assets by symbol names or IDs.

This function has semantics identical to

get_objects, but doesn’t subscribe
Return

The assets corresponding to the provided symbols or IDs

Parameters
  • symbols_or_ids: symbol names or IDs of the assets to retrieve

uint64_t get_asset_count() const

Get assets count.

Return

The assets count

vector<extended_asset_object> get_assets_by_issuer(const std::string &issuer_name_or_id, asset_id_type start, uint32_t limit) const

Get assets issued (owned) by a given account.

Return

The assets issued (owned) by the account

Parameters
  • issuer_name_or_id: Account name or ID to get objects from

  • start: Asset objects(1.3.X) before this ID will be skipped in results. Pagination purposes.

  • limit: Maximum number of orders to retrieve

vector<limit_order_object> get_limit_orders(std::string a, std::string b, uint32_t limit) const

Get limit orders in a given market.

Return

The limit orders, ordered from least price to greatest

Parameters
  • a: symbol or ID of asset being sold

  • b: symbol or ID of asset being purchased

  • limit: Maximum number of orders to retrieve

vector<limit_order_object> get_limit_orders_by_account(const string &account_name_or_id, optional<uint32_t> limit = 101, optional<limit_order_id_type> start_id = optional<limit_order_id_type>())

Fetch open limit orders in all markets relevant to the specified account, ordered by ID.

Return

List of limit orders of the specified account

Note

  1. if account_name_or_id cannot be tied to an account, an error will be returned

  2. limit can be omitted or be null, if so the default value 101 will be used

  3. start_id can be omitted or be null, if so the api will return the “first page” of orders

  4. can only omit one or more arguments in the end of the list, but not one or more in the middle

Parameters
  • account_name_or_id: The name or ID of an account to retrieve

  • limit: The limitation of items each query can fetch, not greater than a configured value

  • start_id: Start order id, fetch orders whose IDs are greater than or equal to this order

vector<limit_order_object> get_account_limit_orders(const string &account_name_or_id, const string &base, const string &quote, uint32_t limit = 101, optional<limit_order_id_type> ostart_id = optional<limit_order_id_type>(), optional<price> ostart_price = optional<price>())

Fetch all orders relevant to the specified account and specified market, result orders are sorted descendingly by price.

Return

List of orders from account_name_or_id to the corresponding account

Note

  1. if account_name_or_id cannot be tied to an account, an error will be returned

  2. ostart_id and ostart_price can be empty, if so the api will return the “first page” of orders; if ostart_id is specified, its price will be used to do page query preferentially, otherwise the ostart_price will be used; ostart_id and ostart_price may be used cooperatively in case of the order specified by ostart_id was just canceled accidentally, in such case, the result orders’ price may lower or equal to ostart_price, but orders’ id greater than ostart_id

Parameters
  • account_name_or_id: The name or ID of an account to retrieve

  • base: Base asset

  • quote: Quote asset

  • limit: The limitation of items each query can fetch, not greater than 101

  • ostart_id: Start order id, fetch orders which price lower than this order, or price equal to this order but order ID greater than this order

  • ostart_price: Fetch orders with price lower than or equal to this price

vector<call_order_object> get_call_orders(const std::string &a, uint32_t limit) const

Get call orders (aka margin positions) for a given asset.

Return

The call orders, ordered from earliest to be called to latest

Parameters
  • a: symbol name or ID of the debt asset

  • limit: Maximum number of orders to retrieve

vector<call_order_object> get_call_orders_by_account(const std::string &account_name_or_id, asset_id_type start, uint32_t limit) const

Get call orders (aka margin positions) of a given account.

Return

The call orders of the account

Parameters
  • account_name_or_id: Account name or ID to get objects from

  • start: Asset objects(1.3.X) before this ID will be skipped in results. Pagination purposes.

  • limit: Maximum number of objects to retrieve

vector<force_settlement_object> get_settle_orders(const std::string &a, uint32_t limit) const

Get forced settlement orders in a given asset.

Return

The settle orders, ordered from earliest settlement date to latest

Parameters
  • a: Symbol or ID of asset being settled

  • limit: Maximum number of orders to retrieve

vector<force_settlement_object> get_settle_orders_by_account(const std::string &account_name_or_id, force_settlement_id_type start, uint32_t limit) const

Get forced settlement orders of a given account.

Return

The settle orders of the account

Parameters
  • account_name_or_id: Account name or ID to get objects from

  • start: Force settlement objects(1.4.X) before this ID will be skipped in results. Pagination purposes.

  • limit: Maximum number of orders to retrieve

vector<collateral_bid_object> get_collateral_bids(const std::string &a, uint32_t limit, uint32_t start) const

Get collateral_bid_objects for a given asset.

Return

The settle orders, ordered from earliest settlement date to latest

Parameters
  • a: Symbol or ID of asset

  • limit: Maximum number of objects to retrieve

  • start: skip that many results

vector<call_order_object> get_margin_positions(const std::string account_name_or_id) const

Get all open margin positions of a given account.

Similar to

get_call_orders_by_account, but without pagination.
Return

all open margin positions of the account

Parameters
  • account_name_or_id: name or ID of an account

void subscribe_to_market(std::function<void(const variant&)> callback, const std::string &a, const std::string &b, )

Request notification when the active orders in the market between two assets changes.

Callback will be passed a variant containing a vector<pair<operation, operation_result>>. The vector will contain, in order, the operations which changed the market, and their results.

Parameters
  • callback: Callback method which is called when the market changes

  • a: symbol name or ID of the first asset

  • b: symbol name or ID of the second asset

void unsubscribe_from_market(const std::string &a, const std::string &b)

Unsubscribe from updates to a given market.

Parameters
  • a: symbol name or ID of the first asset

  • b: symbol name or ID of the second asset

market_ticker get_ticker(const string &base, const string &quote) const

Returns the ticker for the market assetA:assetB.

Return

The market ticker for the past 24 hours.

Parameters
  • base: symbol name or ID of the base asset

  • quote: symbol name or ID of the quote asset

market_volume get_24_volume(const string &base, const string &quote) const

Returns the 24 hour volume for the market assetA:assetB.

Return

The market volume over the past 24 hours

Parameters
  • base: symbol name or ID of the base asset

  • quote: symbol name or ID of the quote asset

order_book get_order_book(const string &base, const string &quote, unsigned limit = 50) const

Returns the order book for the market base:quote.

Return

Order book of the market

Parameters
  • base: symbol name or ID of the base asset

  • quote: symbol name or ID of the quote asset

  • limit: depth of the order book to retrieve, for bids and asks each, capped at 50

vector<market_ticker> get_top_markets(uint32_t limit) const

Returns vector of tickers sorted by reverse base_volume Note: this API is experimental and subject to change in next releases.

Return

Desc Sorted ticker vector

Parameters
  • limit: Max number of results

vector<market_trade> get_trade_history(const string &base, const string &quote, fc::time_point_sec start, fc::time_point_sec stop, unsigned limit = 100) const

Get market transactions occurred in the market base:quote, ordered by time, most recent first.

Return

Transactions in the market

Note

The time must be UTC, timezone offsets are not supported. The range is [stop, start]. In case when there are more than 100 transactions occurred in the same second, this API only returns the most recent 100 records, the rest records can be retrieved with the get_trade_history_by_sequence API.

Parameters
  • base: symbol or ID of the base asset

  • quote: symbol or ID of the quote asset

  • start: Start time as a UNIX timestamp, the latest transactions to retrieve

  • stop: Stop time as a UNIX timestamp, the earliest transactions to retrieve

  • limit: Maximum quantity of transactions to retrieve, capped at 100.

vector<market_trade> get_trade_history_by_sequence(const string &base, const string &quote, int64_t start, fc::time_point_sec stop, unsigned limit = 100) const

Get market transactions occurred in the market base:quote, ordered by time, most recent first.

Return

Transactions in the market

Note

The time must be UTC, timezone offsets are not supported. The range is [stop, start].

Parameters
  • base: symbol or ID of the base asset

  • quote: symbol or ID of the quote asset

  • start: Start sequence as an Integer, the latest transaction to retrieve

  • stop: Stop time as a UNIX timestamp, the earliest transactions to retrieve

  • limit: Maximum quantity of transactions to retrieve, capped at 100

vector<extended_liquidity_pool_object> list_liquidity_pools(optional<uint32_t> limit = 101, optional<liquidity_pool_id_type> start_id = optional<liquidity_pool_id_type>(), optional<bool> with_statistics = false) const

Get a list of liquidity pools.

Return

The liquidity pools

Note

  1. limit can be omitted or be null, if so the default value 101 will be used

  2. start_id can be omitted or be null, if so the api will return the “first page” of pools

  3. can only omit one or more arguments in the end of the list, but not one or more in the middle

Parameters
  • limit: The limitation of items each query can fetch, not greater than a configured value

  • start_id: Start liquidity pool id, fetch pools whose IDs are greater than or equal to this ID

  • with_statistics: Whether to return statistics

vector<extended_liquidity_pool_object> get_liquidity_pools_by_asset_a(std::string asset_symbol_or_id, optional<uint32_t> limit = 101, optional<liquidity_pool_id_type> start_id = optional<liquidity_pool_id_type>(), optional<bool> with_statistics = false) const

Get a list of liquidity pools by the symbol or ID of the first asset in the pool.

Return

The liquidity pools

Note

  1. if asset_symbol_or_id cannot be tied to an asset, an error will be returned

  2. limit can be omitted or be null, if so the default value 101 will be used

  3. start_id can be omitted or be null, if so the api will return the “first page” of pools

  4. can only omit one or more arguments in the end of the list, but not one or more in the middle

Parameters
  • asset_symbol_or_id: symbol name or ID of the asset

  • limit: The limitation of items each query can fetch, not greater than a configured value

  • start_id: Start liquidity pool id, fetch pools whose IDs are greater than or equal to this ID

  • with_statistics: Whether to return statistics

vector<extended_liquidity_pool_object> get_liquidity_pools_by_asset_b(std::string asset_symbol_or_id, optional<uint32_t> limit = 101, optional<liquidity_pool_id_type> start_id = optional<liquidity_pool_id_type>(), optional<bool> with_statistics = false) const

Get a list of liquidity pools by the symbol or ID of the second asset in the pool.

Return

The liquidity pools

Note

  1. if asset_symbol_or_id cannot be tied to an asset, an error will be returned

  2. limit can be omitted or be null, if so the default value 101 will be used

  3. start_id can be omitted or be null, if so the api will return the “first page” of pools

  4. can only omit one or more arguments in the end of the list, but not one or more in the middle

Parameters
  • asset_symbol_or_id: symbol name or ID of the asset

  • limit: The limitation of items each query can fetch, not greater than a configured value

  • start_id: Start liquidity pool id, fetch pools whose IDs are greater than or equal to this ID

  • with_statistics: Whether to return statistics

vector<extended_liquidity_pool_object> get_liquidity_pools_by_one_asset(const std::string &asset_symbol_or_id, const optional<uint32_t> &limit = 101, const optional<liquidity_pool_id_type> &start_id = optional<liquidity_pool_id_type>(), const optional<bool> &with_statistics = false) const

Get a list of liquidity pools by the symbol or ID of one asset in the pool.

Return

The liquidity pools

Note

  1. if asset_symbol_or_id cannot be tied to an asset, an error will be returned

  2. limit can be omitted or be null, if so the default value 101 will be used

  3. start_id can be omitted or be null, if so the api will return the “first page” of pools

  4. can only omit one or more arguments in the end of the list, but not one or more in the middle

Parameters
  • asset_symbol_or_id: symbol name or ID of the asset

  • limit: The limitation of items each query can fetch, not greater than a configured value

  • start_id: Start liquidity pool id, fetch pools whose IDs are greater than or equal to this ID

  • with_statistics: Whether to return statistics

vector<extended_liquidity_pool_object> get_liquidity_pools_by_both_assets(std::string asset_symbol_or_id_a, std::string asset_symbol_or_id_b, optional<uint32_t> limit = 101, optional<liquidity_pool_id_type> start_id = optional<liquidity_pool_id_type>(), optional<bool> with_statistics = false) const

Get a list of liquidity pools by the symbols or IDs of the two assets in the pool.

Return

The liquidity pools

Note

  1. if asset_symbol_or_id_a or asset_symbol_or_id_b cannot be tied to an asset, an error will be returned

  2. limit can be omitted or be null, if so the default value 101 will be used

  3. start_id can be omitted or be null, if so the api will return the “first page” of pools

  4. can only omit one or more arguments in the end of the list, but not one or more in the middle

Parameters
  • asset_symbol_or_id_a: symbol name or ID of one asset

  • asset_symbol_or_id_b: symbol name or ID of the other asset

  • limit: The limitation of items each query can fetch, not greater than a configured value

  • start_id: Start liquidity pool id, fetch pools whose IDs are greater than or equal to this ID

  • with_statistics: Whether to return statistics

vector<optional<extended_liquidity_pool_object>> get_liquidity_pools(const vector<liquidity_pool_id_type> &ids, optional<bool> subscribe = optional<bool>(), optional<bool> with_statistics = false) const

Get a list of liquidity pools by their IDs.

Return

The liquidity pools

Note

if an ID in the list can not be found, the corresponding data in the returned list is null.

Parameters
  • ids: IDs of the liquidity pools

  • subscribe: true to subscribe to the queried objects; false to not subscribe; null to subscribe or not subscribe according to current auto-subscription setting (see set_auto_subscription)

  • with_statistics: Whether to return statistics

vector<optional<extended_liquidity_pool_object>> get_liquidity_pools_by_share_asset(const vector<std::string> &asset_symbols_or_ids, optional<bool> subscribe = optional<bool>(), optional<bool> with_statistics = false) const

Get a list of liquidity pools by their share asset symbols or IDs.

Return

The liquidity pools that the assets are for

Note

if an asset in the list can not be found or is not a share asset of any liquidity pool, the corresponding data in the returned list is null.

Parameters
  • asset_symbols_or_ids: symbol names or IDs of the share assets

  • subscribe: true to subscribe to the queried objects; false to not subscribe; null to subscribe or not subscribe according to current auto-subscription setting (see set_auto_subscription)

  • with_statistics: Whether to return statistics

vector<extended_liquidity_pool_object> get_liquidity_pools_by_owner(std::string account_name_or_id, optional<uint32_t> limit = 101, optional<asset_id_type> start_id = optional<asset_id_type>(), optional<bool> with_statistics = false) const

Get a list of liquidity pools by the name or ID of the owner account.

Return

The liquidity pools

Note

  1. if account_name_or_id cannot be tied to an account, an error will be returned

  2. limit can be omitted or be null, if so the default value 101 will be used

  3. start_id can be omitted or be null, if so the api will return the “first page” of pools

  4. can only omit one or more arguments in the end of the list, but not one or more in the middle

Parameters
  • account_name_or_id: name or ID of the owner account

  • limit: The limitation of items each query can fetch, not greater than a configured value

  • start_id: Start share asset id, fetch pools whose share asset IDs are greater than or equal to this ID

  • with_statistics: Whether to return statistics

vector<optional<witness_object>> get_witnesses(const vector<witness_id_type> &witness_ids) const

Get a list of witnesses by ID.

This function has semantics identical to

get_objects, but doesn’t subscribe
Return

The witnesses corresponding to the provided IDs

Parameters
  • witness_ids: IDs of the witnesses to retrieve

fc::optional<witness_object> get_witness_by_account(const std::string account_name_or_id) const

Get the witness owned by a given account.

Return

The witness object, or null if the account does not have a witness

Parameters
  • account_name_or_id: The name or ID of the account whose witness should be retrieved

map<string, witness_id_type> lookup_witness_accounts(const string &lower_bound_name, uint32_t limit) const

Get names and IDs for registered witnesses.

Return

Map of witness names to corresponding IDs

Parameters
  • lower_bound_name: Lower bound of the first name to return

  • limit: Maximum number of results to return must not exceed 1000

uint64_t get_witness_count() const

Get the total number of witnesses registered with the blockchain.

vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type> &committee_member_ids) const

Get a list of committee_members by ID.

This function has semantics identical to

get_objects, but doesn’t subscribe
Return

The committee_members corresponding to the provided IDs

Parameters
  • committee_member_ids: IDs of the committee_members to retrieve

fc::optional<committee_member_object> get_committee_member_by_account(const string account_name_or_id) const

Get the committee_member owned by a given account.

Return

The committee_member object, or null if the account does not have a committee_member

Parameters
  • account_name_or_id: The name or ID of the account whose committee_member should be retrieved

map<string, committee_member_id_type> lookup_committee_member_accounts(const string &lower_bound_name, uint32_t limit) const

Get names and IDs for registered committee_members.

Return

Map of committee_member names to corresponding IDs

Parameters
  • lower_bound_name: Lower bound of the first name to return

  • limit: Maximum number of results to return must not exceed 1000

uint64_t get_committee_count() const

Get the total number of committee registered with the blockchain.

vector<worker_object> get_all_workers(const optional<bool> is_expired = optional<bool>()) const

Get workers.

Return

A list of worker objects

Parameters
  • is_expired: null for all workers, true for expired workers only, false for non-expired workers only

vector<worker_object> get_workers_by_account(const std::string account_name_or_id) const

Get the workers owned by a given account.

Return

A list of worker objects owned by the account

Parameters
  • account_name_or_id: The name or ID of the account whose worker should be retrieved

uint64_t get_worker_count() const

Get the total number of workers registered with the blockchain.

vector<variant> lookup_vote_ids(const vector<vote_id_type> &votes) const

Given a set of votes, return the objects they are voting for.

This will be a mixture of committee_member_objects, witness_objects, and worker_objects

Return

the referenced objects

Parameters
  • votes: a list of vote IDs

The results will be in the same order as the votes. Null will be returned for any vote IDs that are not found.

std::string get_transaction_hex(const signed_transaction &trx) const

Get a hexdump of the serialized binary form of a transaction.

Return

the hexdump of the transaction

Parameters
  • trx: a transaction to get hexdump from

std::string get_transaction_hex_without_sig(const transaction &trx) const

Get a hexdump of the serialized binary form of a signatures-stripped transaction.

Return

the hexdump of the transaction without the signatures

Parameters
  • trx: a transaction to get hexdump from

set<public_key_type> get_required_signatures(const signed_transaction &trx, const flat_set<public_key_type> &available_keys) const

This API will take a partially signed transaction and a set of public keys that the owner has the ability to sign for and return the minimal subset of public keys that should add signatures to the transaction.

Return

a subset of available_keys that could sign for the given transaction

Parameters
  • trx: the transaction to be signed

  • available_keys: a set of public keys

set<public_key_type> get_potential_signatures(const signed_transaction &trx) const

This method will return the set of all public keys that could possibly sign for a given transaction. This call can be used by wallets to filter their set of public keys to just the relevant subset prior to calling get_required_signatures to get the minimum subset.

Return

a set of public keys that could possibly sign for the given transaction

Parameters
  • trx: the transaction to be signed

set<address> get_potential_address_signatures(const signed_transaction &trx) const

This method will return the set of all addresses that could possibly sign for a given transaction.

Return

a set of addresses that could possibly sign for the given transaction

Parameters
  • trx: the transaction to be signed

bool verify_authority(const signed_transaction &trx) const

Check whether a transaction has all of the required signatures

Return

true if the trx has all of the required signatures, otherwise throws an exception

Parameters
  • trx: a transaction to be verified

bool verify_account_authority(const string &account_name_or_id, const flat_set<public_key_type> &signers) const

Verify that the public keys have enough authority to approve an operation for this account.

Return

true if the passed in keys have enough authority to approve an operation for this account

Parameters
  • account_name_or_id: name or ID of an account to check

  • signers: the public keys

processed_transaction validate_transaction(const signed_transaction &trx) const

Validates a transaction against the current state without broadcasting it on the network.

Return

a processed_transaction object if the transaction passes the validation, otherwise an exception will be thrown

Parameters
  • trx: a transaction to be validated

vector<fc::variant> get_required_fees(const vector<operation> &ops, const std::string &asset_symbol_or_id) const

For each operation calculate the required fee in the specified asset type.

Return

a list of objects which indicates required fees of each operation

Parameters
  • ops: a list of operations to be query for required fees

  • asset_symbol_or_id: symbol name or ID of an asset that to be used to pay the fees

vector<proposal_object> get_proposed_transactions(const std::string account_name_or_id) const

return a set of proposed transactions (aka proposals) that the specified account can add approval to or remove approval from

Return

a set of proposed transactions that the specified account can act on

Parameters
  • account_name_or_id: The name or ID of an account

vector<blinded_balance_object> get_blinded_balances(const flat_set<commitment_type> &commitments) const

return the set of blinded balance objects by commitment ID

Return

the set of blinded balance objects by commitment ID

Parameters
  • commitments: a set of commitments to query for

vector<withdraw_permission_object> get_withdraw_permissions_by_giver(const std::string account_name_or_id, withdraw_permission_id_type start, uint32_t limit) const

Get non expired withdraw permission objects for a giver(ex:recurring customer)

Return

Withdraw permission objects for the account

Parameters
  • account_name_or_id: Account name or ID to get objects from

  • start: Withdraw permission objects(1.12.X) before this ID will be skipped in results. Pagination purposes.

  • limit: Maximum number of objects to retrieve

vector<withdraw_permission_object> get_withdraw_permissions_by_recipient(const std::string account_name_or_id, withdraw_permission_id_type start, uint32_t limit) const

Get non expired withdraw permission objects for a recipient(ex:service provider)

Return

Withdraw permission objects for the account

Parameters
  • account_name_or_id: Account name or ID to get objects from

  • start: Withdraw permission objects(1.12.X) before this ID will be skipped in results. Pagination purposes.

  • limit: Maximum number of objects to retrieve

optional<htlc_object> get_htlc(htlc_id_type id, optional<bool> subscribe = optional<bool>()) const

Get HTLC object.

Return

HTLC object for the id

Parameters
  • id: HTLC contract id

  • subscribe: true to subscribe to the queried HTLC objects; false to not subscribe; null to subscribe or not subscribe according to current auto-subscription setting (see set_auto_subscription)

vector<htlc_object> get_htlc_by_from(const std::string account_name_or_id, htlc_id_type start, uint32_t limit) const

Get non expired HTLC objects using the sender account.

Return

HTLC objects for the account

Parameters
  • account_name_or_id: Account name or ID to get objects from

  • start: htlc objects before this ID will be skipped in results. Pagination purposes.

  • limit: Maximum number of objects to retrieve

vector<htlc_object> get_htlc_by_to(const std::string account_name_or_id, htlc_id_type start, uint32_t limit) const

Get non expired HTLC objects using the receiver account.

Return

HTLC objects for the account

Parameters
  • account_name_or_id: Account name or ID to get objects from

  • start: htlc objects before this ID will be skipped in results. Pagination purposes.

  • limit: Maximum number of objects to retrieve

vector<htlc_object> list_htlcs(const htlc_id_type start, uint32_t limit) const

Get all HTLCs.

Return

The htlc object list

Parameters
  • start: Lower bound of htlc id to start getting results

  • limit: Maximum number of htlc objects to fetch

vector<ticket_object> list_tickets(optional<uint32_t> limit = 101, optional<ticket_id_type> start_id = optional<ticket_id_type>()) const

Get a list of tickets.

Return

The tickets

Note

  1. limit can be omitted or be null, if so the default value 101 will be used

  2. start_id can be omitted or be null, if so the api will return the “first page” of tickets

  3. can only omit one or more arguments in the end of the list, but not one or more in the middle

Parameters
  • limit: The limitation of items each query can fetch, not greater than a configured value

  • start_id: Start ticket id, fetch tickets whose IDs are greater than or equal to this ID

vector<ticket_object> get_tickets_by_account(std::string account_name_or_id, optional<uint32_t> limit = 101, optional<ticket_id_type> start_id = optional<ticket_id_type>()) const

Get a list of tickets by the name or ID of the owner account.

Return

The tickets

Note

  1. if account_name_or_id cannot be tied to an account, an error will be returned

  2. limit can be omitted or be null, if so the default value 101 will be used

  3. start_id can be omitted or be null, if so the api will return the “first page” of tickets

  4. can only omit one or more arguments in the end of the list, but not one or more in the middle

Parameters
  • account_name_or_id: name or ID of the owner account

  • limit: The limitation of items each query can fetch, not greater than a configured value

  • start_id: Start ticket id, fetch tickets whose IDs are greater than or equal to this ID

class database_api_impl : public std::enable_shared_from_this<database_api_impl>
#include <database_api_impl.hxx>

Public Functions

vector<flat_set<account_id_type>> get_key_references(vector<public_key_type> key) const

Return

all accounts that referr to the key or account id in their owner or active authorities.

void on_objects_new(const vector<object_id_type> &ids, const flat_set<account_id_type> &impacted_accounts)

called every time a block is applied to report the objects that were changed

void on_applied_block()

note: this method cannot yield because it is called in the middle of apply a block.

struct get_required_fees_helper

Container method for mutually recursive functions used to implement get_required_fees() with potentially nested proposals.

class history_api
#include <api.hpp>

The history_api class implements the RPC API for account history.

This API contains methods to access account histories

Public Functions

vector<operation_history_object> get_account_history(const std::string account_name_or_id, operation_history_id_type stop = operation_history_id_type(), uint32_t limit = 100, operation_history_id_type start = operation_history_id_type()) const

Get operations relevant to the specificed account.

Return

A list of operations performed by account, ordered from most recent to oldest.

Parameters
  • account_name_or_id: The account name or ID whose history should be queried

  • stop: ID of the earliest operation to retrieve

  • limit: Maximum number of operations to retrieve (must not exceed 100)

  • start: ID of the most recent operation to retrieve

history_operation_detail get_account_history_by_operations(const std::string account_name_or_id, flat_set<uint16_t> operation_types, uint32_t start, uint32_t limit) const

Get operations relevant to the specified account filtering by operation type.

Return

history_operation_detail

Parameters
  • account_name_or_id: The account name or ID whose history should be queried

  • operation_types: The IDs of the operation we want to get operations in the account ( 0 = transfer , 1 = limit order create, …)

  • start: the sequence number where to start looping back throw the history

  • limit: the max number of entries to return (from start number)

vector<operation_history_object> get_account_history_operations(const std::string account_name_or_id, int64_t operation_type, operation_history_id_type start = operation_history_id_type(), operation_history_id_type stop = operation_history_id_type(), uint32_t limit = 100) const

Get only asked operations relevant to the specified account.

Return

A list of operations performed by account, ordered from most recent to oldest.

Parameters
  • account_name_or_id: The account name or ID whose history should be queried

  • operation_type: The type of the operation we want to get operations in the account ( 0 = transfer , 1 = limit order create, …)

  • stop: ID of the earliest operation to retrieve

  • limit: Maximum number of operations to retrieve (must not exceed 100)

  • start: ID of the most recent operation to retrieve

vector<operation_history_object> get_relative_account_history(const std::string account_name_or_id, uint64_t stop = 0, uint32_t limit = 100, uint64_t start = 0) const

Get operations relevant to the specified account referenced by an event numbering specific to the account. The current number of operations for the account can be found in the account statistics (or use 0 for start).

Return

A list of operations performed by account, ordered from most recent to oldest.

Parameters
  • account_name_or_id: The account name or ID whose history should be queried

  • stop: Sequence number of earliest operation. 0 is default and will query ‘limit’ number of operations.

  • limit: Maximum number of operations to retrieve (must not exceed 100)

  • start: Sequence number of the most recent operation to retrieve. 0 is default, which will start querying from the most recent operation.

vector<order_history_object> get_fill_order_history(std::string a, std::string b, uint32_t limit) const

Get details of order executions occurred most recently in a trading pair.

Return

a list of order_history objects, in “most recent first” order

Parameters
  • a: Asset symbol or ID in a trading pair

  • b: The other asset symbol or ID in the trading pair

  • limit: Maximum records to return

vector<bucket_object> get_market_history(std::string a, std::string b, uint32_t bucket_seconds, fc::time_point_sec start, fc::time_point_sec end) const

Get OHLCV data of a trading pair in a time range.

Return

A list of OHLCV data, in “least recent first” order. If there are more than 200 records in the specified time range, the first 200 records will be returned.

Parameters
  • a: Asset symbol or ID in a trading pair

  • b: The other asset symbol or ID in the trading pair

  • bucket_seconds: Length of each time bucket in seconds. Note: it need to be within result of get_market_history_buckets() API, otherwise no data will be returned

  • start: The start of a time range, E.G. “2018-01-01T00:00:00”

  • end: The end of the time range

flat_set<uint32_t> get_market_history_buckets() const

Get OHLCV time bucket lengths supported (configured) by this API server.

Return

A list of time bucket lengths in seconds. E.G. if the result contains a number “300”, it means this API server supports OHLCV data aggregated in 5-minute buckets.

vector<liquidity_pool_history_object> get_liquidity_pool_history(liquidity_pool_id_type pool_id, optional<fc::time_point_sec> start = optional<fc::time_point_sec>(), optional<fc::time_point_sec> stop = optional<fc::time_point_sec>(), optional<uint32_t> limit = 101, optional<int64_t> operation_type = optional<int64_t>()) const

Get history of a liquidity pool.

Return

operation history of the liquidity pool, ordered by time, most recent first.

Note

  1. The time must be UTC. The range is (stop, start].

  2. In case when there are more than 100 operations occurred in the same second, this API only returns the most recent records, the rest records can be retrieved with the get_liquidity_pool_history_by_sequence API.

  3. List of operation type code: 59-creation, 60-deletion, 61-deposit, 62-withdrawal, 63-exchange.

  4. Can only omit one or more arguments in the end of the list, but not one or more in the middle. If need to not specify an individual argument, can specify null in the place.

Parameters
  • pool_id: ID of the liquidity pool to query

  • start: A UNIX timestamp. Optional. If specified, only the operations occurred not later than this time will be returned.

  • stop: A UNIX timestamp. Optional. If specified, only the operations occurred later than this time will be returned.

  • limit: Maximum quantity of operations in the history to retrieve. Optional. If not specified, at most 101 records will be returned.

  • operation_type: Optional. If specified, only the operations whose type is the specified type will be returned. Otherwise all operations will be returned.

vector<liquidity_pool_history_object> get_liquidity_pool_history_by_sequence(liquidity_pool_id_type pool_id, optional<uint64_t> start = optional<uint64_t>(), optional<fc::time_point_sec> stop = optional<fc::time_point_sec>(), optional<uint32_t> limit = 101, optional<int64_t> operation_type = optional<int64_t>()) const

Get history of a liquidity pool.

Return

operation history of the liquidity pool, ordered by time, most recent first.

Note

  1. The time must be UTC. The range is (stop, start].

  2. In case when there are more than 100 operations occurred in the same second, this API only returns the most recent records, the rest records can be retrieved with the get_liquidity_pool_history_by_sequence API.

  3. List of operation type code: 59-creation, 60-deletion, 61-deposit, 62-withdrawal, 63-exchange.

  4. Can only omit one or more arguments in the end of the list, but not one or more in the middle. If need to not specify an individual argument, can specify null in the place.

Parameters
  • pool_id: ID of the liquidity pool to query

  • start: An Integer. Optional. If specified, only the operations whose sequences are not greater than this will be returned.

  • stop: A UNIX timestamp. Optional. If specified, only operations occurred later than this time will be returned.

  • limit: Maximum quantity of operations in the history to retrieve. Optional. If not specified, at most 101 records will be returned.

  • operation_type: Optional. If specified, only the operations whose type is the specified type will be returned. Otherwise all operations will be returned.

struct limit_order_group
#include <api.hpp>

summary data of a group of limit orders

Public Members

price min_price

possible lowest price in the group

price max_price

possible highest price in the group

share_type total_for_sale

total amount of asset for sale, asset id is min_price.base.asset_id

class login_api
#include <api.hpp>

The login_api class implements the bottom layer of the RPC API.

All other APIs must be requested from this API.

Public Functions

bool login(const string &user, const string &password)

Authenticate to the RPC server.

Return

True if logged in successfully; false otherwise

Note

This must be called prior to requesting other APIs. Other APIs may not be accessible until the client has sucessfully authenticated.

Parameters
  • user: Username to login with

  • password: Password to login with

fc::api<block_api> block() const

Retrieve the network block API.

fc::api<network_broadcast_api> network_broadcast() const

Retrieve the network broadcast API.

fc::api<database_api> database() const

Retrieve the database API.

fc::api<history_api> history() const

Retrieve the history API.

fc::api<network_node_api> network_node() const

Retrieve the network node API.

fc::api<crypto_api> crypto() const

Retrieve the cryptography API.

fc::api<asset_api> asset() const

Retrieve the asset API.

fc::api<orders_api> orders() const

Retrieve the orders API.

fc::api<graphene::debug_witness::debug_api> debug() const

Retrieve the debug API (if available)

fc::api<custom_operations_api> custom_operations() const

Retrieve the custom operations API.

void enable_api(const string &api_name)

Called to enable an API, not reflected.

class network_broadcast_api : public std::enable_shared_from_this<network_broadcast_api>
#include <api.hpp>

The network_broadcast_api class allows broadcasting of transactions.

Public Functions

void broadcast_transaction(const precomputable_transaction &trx)

Broadcast a transaction to the network.

The transaction will be checked for validity in the local database prior to broadcasting. If it fails to apply locally, an error will be thrown and the transaction will not be broadcast.

Parameters
  • trx: The transaction to broadcast

void broadcast_transaction_with_callback(confirmation_callback cb, const precomputable_transaction &trx)

This version of broadcast transaction registers a callback method that will be called when the transaction is included into a block. The callback method includes the transaction id, block number, and transaction number in the block.

Parameters
  • cb: the callback method

  • trx: the transaction

fc::variant broadcast_transaction_synchronous(const precomputable_transaction &trx)

This version of broadcast transaction waits until the transaction is included into a block, then the transaction id, block number, and transaction number in the block will be returned.

Return

info about the block including the transaction

Parameters
  • trx: the transaction

void broadcast_block(const signed_block &block)

Broadcast a signed block to the network.

Parameters
  • block: The signed block to broadcast

void on_applied_block(const signed_block &b)

Not reflected, thus not accessible to API clients.

This function is registered to receive the applied_block signal from the chain database when a block is received. It then dispatches callbacks to clients who have requested to be notified when a particular txid is included in a block.

class network_node_api
#include <api.hpp>

The network_node_api class allows maintenance of p2p connections.

Public Functions

fc::variant_object get_info() const

Return general network information, such as p2p port.

void add_node(const fc::ip::endpoint &ep)

add_node Connect to a new peer

Parameters
  • ep: The IP/Port of the peer to connect to

std::vector<net::peer_status> get_connected_peers() const

Get status of all current connections to peers.

fc::variant_object get_advanced_node_parameters() const

Get advanced node parameters, such as desired and max number of connections.

void set_advanced_node_parameters(const fc::variant_object &params)

Set advanced node parameters, such as desired and max number of connections.

Parameters
  • params: a JSON object containing the name/value pairs for the parameters to set

std::vector<net::potential_peer_record> get_potential_peers() const

Return list of potential peers.

class orders_api
#include <api.hpp>

the orders_api class exposes access to data processed with grouped orders plugin.

Public Functions

flat_set<uint16_t> get_tracked_groups() const

Get tracked groups configured by the server.

Return

A list of numbers which indicate configured groups, of those, 1 means 0.01% diff on price.

vector<limit_order_group> get_grouped_limit_orders(std::string base_asset, std::string quote_asset, uint16_t group, optional<price> start, uint32_t limit) const

Get grouped limit orders in given market.

Return

The grouped limit orders, ordered from best offered price to worst

Parameters
  • base_asset: symbol or ID of asset being sold

  • quote_asset: symbol or ID of asset being purchased

  • group: Maximum price diff within each order group, have to be one of configured values

  • start: Optional price to indicate the first order group to retrieve

  • limit: Maximum number of order groups to retrieve (must not exceed 101)

class plugin : public graphene::app::abstract_plugin
#include <plugin.hpp>

Provides basic default implementations of abstract_plugin functions.

Subclassed by graphene::account_history::account_history_plugin, graphene::api_helper_indexes::api_helper_indexes, graphene::custom_operations::custom_operations_plugin, graphene::debug_witness_plugin::debug_witness_plugin, graphene::delayed_node::delayed_node_plugin, graphene::elasticsearch::elasticsearch_plugin, graphene::es_objects::es_objects_plugin, graphene::grouped_orders::grouped_orders_plugin, graphene::market_history::market_history_plugin, graphene::snapshot_plugin::snapshot_plugin, graphene::template_plugin::template_plugin, graphene::witness_plugin::witness_plugin

Public Functions

std::string plugin_name() const

Get the name of the plugin.

std::string plugin_description() const

Get the description of the plugin.

void plugin_initialize(const boost::program_options::variables_map &options)

Perform early startup routines and register plugin indexes, callbacks, etc.

Plugins MUST supply a method initialize() which will be called early in the application startup. This method should contain early setup code such as initializing variables, adding indexes to the database, registering callback methods from the database, adding APIs, etc., as well as applying any options in the options map

This method is called BEFORE the database is open, therefore any routines which require any chain state MUST NOT be called by this method. These routines should be performed in startup() instead.

Parameters
  • options: The options passed to the application, via configuration files or command line

void plugin_startup()

Begin normal runtime operations.

Plugins MUST supply a method startup() which will be called at the end of application startup. This method should contain code which schedules any tasks, or requires chain state.

void plugin_shutdown()

Cleanly shut down the plugin.

This is called to request a clean shutdown (e.g. due to SIGINT or SIGTERM).

void plugin_set_program_options(boost::program_options::options_description &command_line_options, boost::program_options::options_description &config_file_options)

Fill in command line parameters used by the plugin.

This method populates its arguments with any command-line and configuration file options the plugin supports. If a plugin does not need these options, it may simply provide an empty implementation of this method.

Parameters
  • command_line_options: All options this plugin supports taking on the command-line

  • config_file_options: All options this plugin supports storing in a configuration file

namespace detail

Functions

graphene::chain::genesis_state_type create_example_genesis()
class application_impl : public graphene::net::node_delegate, public std::enable_shared_from_this<application_impl>
#include <application_impl.hxx>

Public Functions

bool has_item(const net::item_id &id)

If delegate has the item, the network has no need to fetch it.

bool handle_block(const graphene::net::block_message &blk_msg, bool sync_mode, std::vector<graphene::net::message_hash_type> &contained_transaction_msg_ids)

allows the application to validate an item prior to broadcasting to peers.

Return

true if this message caused the blockchain to switch forks, false if it did not

Return

true if this message caused the blockchain to switch forks, false if it did not

Parameters
  • blk_msg: the message which contains the block

  • sync_mode: true if the message was fetched through the sync process, false during normal operation

  • contained_transaction_msg_ids: container for the transactions to write back into

Exceptions
  • exception: if error validating the item, otherwise the item is safe to broadcast on.

Parameters
  • sync_mode: true if the message was fetched through the sync process, false during normal operation

Exceptions
  • exception: if error validating the item, otherwise the item is safe to broadcast on.

void handle_transaction(const graphene::net::trx_message &trx_msg)

Called when a new transaction comes in from the network.

Exceptions
  • exception: if error validating the item, otherwise the item is safe to broadcast on.

void handle_message(const graphene::net::message &message_to_process)

Called when a new message comes in from the network other than a block or a transaction. Currently there are no other possible messages, so this should never be called.

Exceptions
  • exception: if error validating the item, otherwise the item is safe to broadcast on.

std::vector<item_hash_t> get_block_ids(const std::vector<graphene::net::item_hash_t> &blockchain_synopsis, uint32_t &remaining_item_count, uint32_t limit)

Assuming all data elements are ordered in some way, this method should return up to limit ids that occur after the last ID in synopsis that we recognize.

On return, remaining_item_count will be set to the number of items in our blockchain after the last item returned in the result, or 0 if the result contains the last item in the blockchain

message get_item(const graphene::net::item_id &id)

Given the hash of the requested data, fetch the body.

std::vector<item_hash_t> get_blockchain_synopsis(const graphene::net::item_hash_t &reference_point, uint32_t number_of_blocks_after_reference_point)

Returns a synopsis of the blockchain used for syncing. This consists of a list of block hashes at intervals exponentially increasing towards the genesis block. When syncing to a peer, the peer uses this data to determine if we’re on the same fork as they are, and if not, what blocks they need to send us to get us on their fork.

In the over-simplified case, this is a straighforward synopsis of our current preferred blockchain; when we first connect up to a peer, this is what we will be sending. It looks like this: If the blockchain is empty, it will return the empty list. If the blockchain has one block, it will return a list containing just that block. If it contains more than one block: the first element in the list will be the hash of the highest numbered block that we cannot undo the second element will be the hash of an item at the half way point in the undoable segment of the blockchain the third will be ~3/4 of the way through the undoable segment of the block chain the fourth will be at ~7/8… &c. the last item in the list will be the hash of the most recent block on our preferred chain so if the blockchain had 26 blocks labeled a - z, the synopsis would be: a n u x z the idea being that by sending a small (<30) number of block ids, we can summarize a huge blockchain. The block ids are more dense near the end of the chain where because we are more likely to be almost in sync when we first connect, and forks are likely to be short. If the peer we’re syncing with in our example is on a fork that started at block ‘v’, then they will reply to our synopsis with a list of all blocks starting from block ‘u’, the last block they know that we had in common.

In the real code, there are several complications.

First, as an optimization, we don’t usually send a synopsis of the entire blockchain, we send a synopsis of only the segment of the blockchain that we have undo data for. If their fork doesn’t build off of something in our undo history, we would be unable to switch, so there’s no reason to fetch the blocks.

Second, when a peer replies to our initial synopsis and gives us a list of the blocks they think we are missing, they only send a chunk of a few thousand blocks at once. After we get those block ids, we need to request more blocks by sending another synopsis (we can’t just say “send me

the next 2000 ids” because they may have switched forks themselves and they don’t track what they’ve sent us). For faster performance, we want to get a fairly long list of block ids first, then start downloading the blocks. The peer doesn’t handle these follow-up block id requests any different from the initial request; it treats the synopsis we send as our blockchain and bases its response entirely off that. So to get the response we want (the next chunk of block ids following the last one they sent us, or, failing that, the shortest fork off of the last list of block ids they sent), we need to construct a synopsis as if our blockchain was made up of:

  1. the blocks in our block chain up to the fork point (if there is a fork) or the head block (if no fork)

  2. the blocks we’ve already pushed from their fork (if there’s a fork)

  3. the block ids they’ve previously sent us Segment 3 is handled in the p2p code, it just tells us the number of blocks it has (in number_of_blocks_after_reference_point) so we can leave space in the synopsis for them. We’re responsible for constructing the synopsis of Segments 1 and 2 from our active blockchain and fork database. The reference_point parameter is the last block from that peer that has been successfully pushed to the blockchain, so that tells us whether the peer is on a fork or on the main chain.

void sync_status(uint32_t item_type, uint32_t item_count)

Call this after the call to handle_message succeeds.

Parameters
  • item_type: the type of the item we’re synchronizing, will be the same as item passed to the sync_from() call

  • item_count: the number of items known to the node that haven’t been sent to handle_item() yet. After item_count more calls to handle_item(), the node will be in sync

void connection_count_changed(uint32_t c)

Call any time the number of connected peers changes.

fc::time_point_sec get_block_time(const graphene::net::item_hash_t &block_id)

Returns the time a block was produced (if block_id = 0, returns genesis time). If we don’t know about the block, returns time_point_sec::min()

void add_available_plugin(std::shared_ptr<abstract_plugin> p)

Add an available plugin.

void enable_plugin(const string &name)

Enables a plugin.

bool is_plugin_enabled(const string &name) const

Returns whether a plugin is enabled.

namespace impl

Functions

template<typename T>
T dejsonify(const string &s)