BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface software
Public Member Functions | List of all members
graphene::app::database_api Class Reference

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

#include <database_api.hpp>

Public Member Functions

 database_api (graphene::chain::database &db, const application_options *app_options=nullptr)
 
 ~database_api ()
 
fc::variants get_objects (const vector< object_id_type > &ids, optional< bool > subscribe=optional< bool >()) const
 Get the objects corresponding to the provided IDs. More...
 
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. More...
 
void set_auto_subscription (bool enable)
 Set auto-subscription behavior of follow-up API queries. More...
 
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. More...
 
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. More...
 
void cancel_all_subscriptions ()
 Stop receiving any notifications. More...
 
optional< block_headerget_block_header (uint32_t block_num) const
 Retrieve a block header. More...
 
map< uint32_t, optional< block_header > > get_block_header_batch (const vector< uint32_t > block_nums) const
 Retrieve multiple block header by block numbers. More...
 
optional< signed_blockget_block (uint32_t block_num) const
 Retrieve a full, signed block. More...
 
processed_transaction get_transaction (uint32_t block_num, uint32_t trx_in_block) const
 used to fetch an individual transaction. More...
 
optional< signed_transaction > get_recent_transaction_by_id (const transaction_id_type &txid) const
 
chain_property_object get_chain_properties () const
 Retrieve the graphene::chain::chain_property_object associated with the chain. More...
 
global_property_object get_global_properties () const
 Retrieve the current graphene::chain::global_property_object. More...
 
fc::variant_object get_config () const
 Retrieve compile-time constants. More...
 
chain_id_type get_chain_id () const
 Get the chain ID. More...
 
dynamic_global_property_object get_dynamic_global_properties () const
 Retrieve the current graphene::chain::dynamic_global_property_object. More...
 
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. More...
 
bool is_public_key_registered (string public_key) const
 
account_id_type get_account_id_from_string (const std::string &name_or_id) const
 Get account object from a name or ID. More...
 
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. More...
 
std::map< string, full_accountget_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. More...
 
optional< account_objectget_account_by_name (string name) const
 Get info of an account by name. More...
 
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. More...
 
vector< optional< account_object > > lookup_account_names (const vector< string > &account_names) const
 Get a list of accounts by name. More...
 
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. More...
 
vector< assetget_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. More...
 
vector< assetget_named_account_balances (const std::string &name, const flat_set< asset_id_type > &assets) const
 Semantically equivalent to get_account_balances. More...
 
vector< balance_objectget_balance_objects (const vector< address > &addrs) const
 Return all unclaimed balance objects for a list of addresses. More...
 
vector< assetget_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. More...
 
vector< vesting_balance_objectget_vesting_balances (const std::string account_name_or_id) const
 Return all vesting balance objects owned by an account. More...
 
uint64_t get_account_count () const
 Get the total number of accounts registered with the blockchain. More...
 
asset_id_type get_asset_id_from_string (const std::string &symbol_or_id) const
 Get asset ID from an asset symbol or ID. More...
 
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. More...
 
vector< extended_asset_objectlist_assets (const string &lower_bound_symbol, uint32_t limit) const
 Get assets alphabetically by symbol name. More...
 
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. More...
 
uint64_t get_asset_count () const
 Get assets count. More...
 
vector< extended_asset_objectget_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. More...
 
vector< limit_order_objectget_limit_orders (std::string a, std::string b, uint32_t limit) const
 Get limit orders in a given market. More...
 
vector< limit_order_objectget_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. More...
 
vector< limit_order_objectget_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. More...
 
vector< call_order_objectget_call_orders (const std::string &a, uint32_t limit) const
 Get call orders (aka margin positions) for a given asset. More...
 
vector< call_order_objectget_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. More...
 
vector< force_settlement_objectget_settle_orders (const std::string &a, uint32_t limit) const
 Get forced settlement orders in a given asset. More...
 
vector< force_settlement_objectget_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. More...
 
vector< collateral_bid_objectget_collateral_bids (const std::string &a, uint32_t limit, uint32_t start) const
 Get collateral_bid_objects for a given asset. More...
 
vector< call_order_objectget_margin_positions (const std::string account_name_or_id) const
 Get all open margin positions of a given account. More...
 
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. More...
 
void unsubscribe_from_market (const std::string &a, const std::string &b)
 Unsubscribe from updates to a given market. More...
 
market_ticker get_ticker (const string &base, const string &quote) const
 Returns the ticker for the market assetA:assetB. More...
 
market_volume get_24_volume (const string &base, const string &quote) const
 Returns the 24 hour volume for the market assetA:assetB. More...
 
order_book get_order_book (const string &base, const string &quote, unsigned limit=50) const
 Returns the order book for the market base:quote. More...
 
vector< market_tickerget_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. More...
 
vector< market_tradeget_trade_history (const string &base, const string &quote, fc::time_point_sec start, fc::time_point_sec stop, unsigned limit=100) const
 Returns recent trades for the market base:quote, ordered by time, most recent first. Note: Currently, timezone offsets are not supported. The time must be UTC. The range is [stop, start). In case when there are more than 100 trades occurred in the same second, this API only returns the first 100 records, can use another API get_trade_history_by_sequence to query for the rest. More...
 
vector< market_tradeget_trade_history_by_sequence (const string &base, const string &quote, int64_t start, fc::time_point_sec stop, unsigned limit=100) const
 Returns trades for the market base:quote, ordered by time, most recent first. Note: Currently, timezone offsets are not supported. The time must be UTC. The range is [stop, start). More...
 
vector< optional< witness_object > > get_witnesses (const vector< witness_id_type > &witness_ids) const
 Get a list of witnesses by ID. More...
 
fc::optional< witness_objectget_witness_by_account (const std::string account_name_or_id) const
 Get the witness owned by a given account. More...
 
map< string, witness_id_type > lookup_witness_accounts (const string &lower_bound_name, uint32_t limit) const
 Get names and IDs for registered witnesses. More...
 
uint64_t get_witness_count () const
 Get the total number of witnesses registered with the blockchain. More...
 
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. More...
 
fc::optional< committee_member_objectget_committee_member_by_account (const string account_name_or_id) const
 Get the committee_member owned by a given account. More...
 
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. More...
 
uint64_t get_committee_count () const
 Get the total number of committee registered with the blockchain. More...
 
vector< worker_objectget_all_workers (const optional< bool > is_expired=optional< bool >()) const
 Get workers. More...
 
vector< worker_objectget_workers_by_account (const std::string account_name_or_id) const
 Get the workers owned by a given account. More...
 
uint64_t get_worker_count () const
 Get the total number of workers registered with the blockchain. More...
 
vector< variant > lookup_vote_ids (const vector< vote_id_type > &votes) const
 Given a set of votes, return the objects they are voting for. More...
 
std::string get_transaction_hex (const signed_transaction &trx) const
 Get a hexdump of the serialized binary form of a transaction. More...
 
std::string get_transaction_hex_without_sig (const signed_transaction &trx) const
 Get a hexdump of the serialized binary form of a signatures-stripped transaction. More...
 
set< public_key_type > get_required_signatures (const signed_transaction &trx, const flat_set< public_key_type > &available_keys) const
 
set< public_key_type > get_potential_signatures (const signed_transaction &trx) const
 
set< address > get_potential_address_signatures (const signed_transaction &trx) const
 
bool verify_authority (const signed_transaction &trx) const
 
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. More...
 
processed_transaction validate_transaction (const signed_transaction &trx) const
 Validates a transaction against the current state without broadcasting it on the network. More...
 
vector< fc::variantget_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. More...
 
vector< proposal_objectget_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 More...
 
vector< blinded_balance_objectget_blinded_balances (const flat_set< commitment_type > &commitments) const
 return the set of blinded balance objects by commitment ID More...
 
vector< withdraw_permission_objectget_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) More...
 
vector< withdraw_permission_objectget_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) More...
 
optional< htlc_objectget_htlc (htlc_id_type id, optional< bool > subscribe=optional< bool >()) const
 Get HTLC object. More...
 
vector< htlc_objectget_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. More...
 
vector< htlc_objectget_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. More...
 
vector< htlc_objectlist_htlcs (const htlc_id_type start, uint32_t limit) const
 Get all HTLCs. More...
 

Detailed Description

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.

Definition at line 69 of file database_api.hpp.

Constructor & Destructor Documentation

graphene::app::database_api::database_api ( graphene::chain::database db,
const application_options app_options = nullptr 
)

Definition at line 50 of file database_api.cpp.

graphene::app::database_api::~database_api ( )

Definition at line 53 of file database_api.cpp.

Member Function Documentation

void graphene::app::database_api::cancel_all_subscriptions ( )

Stop receiving any notifications.

This unsubscribes from all subscribed markets and objects.

Definition at line 181 of file database_api.cpp.

market_volume graphene::app::database_api::get_24_volume ( const string &  base,
const string &  quote 
) const

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

Parameters
basesymbol name or ID of the base asset
quotesymbol name or ID of the quote asset
Returns
The market volume over the past 24 hours

Definition at line 1390 of file database_api.cpp.

vector< asset > graphene::app::database_api::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.

Parameters
account_name_or_idname or ID of the account to get balances for
assetsIDs of the assets to get balances of; if empty, get all assets account has a balance in
Returns
Balances of the account

Definition at line 753 of file database_api.cpp.

optional< account_object > graphene::app::database_api::get_account_by_name ( string  name) const

Get info of an account by name.

Parameters
nameName of the account to retrieve
Returns
The account holding the provided name

Definition at line 643 of file database_api.cpp.

uint64_t graphene::app::database_api::get_account_count ( ) const

Get the total number of accounts registered with the blockchain.

Definition at line 737 of file database_api.cpp.

account_id_type graphene::app::database_api::get_account_id_from_string ( const std::string &  name_or_id) const

Get account object from a name or ID.

Parameters
name_or_idname or ID of the account
Returns
Account ID

Definition at line 429 of file database_api.cpp.

vector< limit_order_object > graphene::app::database_api::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.

Parameters
account_name_or_idThe name or ID of an account to retrieve
baseBase asset
quoteQuote asset
limitThe limitation of items each query can fetch, not greater than 101
ostart_idStart order id, fetch orders which price lower than this order, or price equal to this order but order ID greater than this order
ostart_priceFetch orders with price lower than or equal to this price
Returns
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

Definition at line 1053 of file database_api.cpp.

vector< account_id_type > graphene::app::database_api::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.

Parameters
account_name_or_idAccount name or ID to query
Returns
all accounts that refer to the specified account in their owner or active authorities

Definition at line 657 of file database_api.cpp.

vector< optional< account_object > > graphene::app::database_api::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.

Parameters
account_names_or_idsnames or IDs of the accounts to retrieve
subscribetrue 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)
Returns
The accounts corresponding to the provided names or IDs

This function has semantics identical to get_objects

Definition at line 434 of file database_api.cpp.

vector< worker_object > graphene::app::database_api::get_all_workers ( const optional< bool >  is_expired = optional<bool>()) const

Get workers.

Parameters
is_expirednull for all workers, true for expired workers only, false for non-expired workers only
Returns
A list of worker objects

Definition at line 1890 of file database_api.cpp.

uint64_t graphene::app::database_api::get_asset_count ( ) const

Get assets count.

Returns
The assets count

Definition at line 924 of file database_api.cpp.

asset_id_type graphene::app::database_api::get_asset_id_from_string ( const std::string &  symbol_or_id) const

Get asset ID from an asset symbol or ID.

Parameters
symbol_or_idsymbol name or ID of the asset
Returns
asset ID

Definition at line 865 of file database_api.cpp.

vector< optional< extended_asset_object > > graphene::app::database_api::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.

Parameters
asset_symbols_or_idssymbol names or IDs of the assets to retrieve
subscribetrue 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)
Returns
The assets corresponding to the provided symbol names or IDs

This function has semantics identical to get_objects

Definition at line 870 of file database_api.cpp.

vector< extended_asset_object > graphene::app::database_api::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.

Parameters
issuer_name_or_idAccount name or ID to get objects from
startAsset objects(1.3.X) before this ID will be skipped in results. Pagination purposes.
limitMaximum number of orders to retrieve
Returns
The assets issued (owned) by the account

Definition at line 934 of file database_api.cpp.

vector< balance_object > graphene::app::database_api::get_balance_objects ( const vector< address > &  addrs) const

Return all unclaimed balance objects for a list of addresses.

Parameters
addrsa list of addresses
Returns
all unclaimed balance objects for the addresses

Definition at line 791 of file database_api.cpp.

vector< blinded_balance_object > graphene::app::database_api::get_blinded_balances ( const flat_set< commitment_type > &  commitments) const

return the set of blinded balance objects by commitment ID

Parameters
commitmentsa set of commitments to query for
Returns
the set of blinded balance objects by commitment ID

Definition at line 2344 of file database_api.cpp.

optional< signed_block > graphene::app::database_api::get_block ( uint32_t  block_num) const

Retrieve a full, signed block.

Parameters
block_numHeight of the block to be returned
Returns
the referenced block, or null if no matching block was found

Definition at line 234 of file database_api.cpp.

optional< block_header > graphene::app::database_api::get_block_header ( uint32_t  block_num) const

Retrieve a block header.

Parameters
block_numHeight of the block whose header should be returned
Returns
header of the referenced block, or null if no matching block was found

Definition at line 206 of file database_api.cpp.

map< uint32_t, optional< block_header > > graphene::app::database_api::get_block_header_batch ( const vector< uint32_t >  block_nums) const

Retrieve multiple block header by block numbers.

Parameters
block_numsvector containing heights of the block whose header should be returned
Returns
array of headers of the referenced blocks, or null if no matching block was found

Definition at line 218 of file database_api.cpp.

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

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

Parameters
asymbol name or ID of the debt asset
limitMaximum number of orders to retrieve
Returns
The call orders, ordered from earliest to be called to latest

Definition at line 1145 of file database_api.cpp.

vector< call_order_object > graphene::app::database_api::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.

Parameters
account_name_or_idAccount name or ID to get objects from
startAsset objects(1.3.X) before this ID will be skipped in results. Pagination purposes.
limitMaximum number of objects to retrieve
Returns
The call orders of the account

Definition at line 1173 of file database_api.cpp.

chain_id_type graphene::app::database_api::get_chain_id ( ) const

Get the chain ID.

Definition at line 302 of file database_api.cpp.

chain_property_object graphene::app::database_api::get_chain_properties ( ) const

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

Definition at line 272 of file database_api.cpp.

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

Get collateral_bid_objects for a given asset.

Parameters
aSymbol or ID of asset
limitMaximum number of objects to retrieve
startskip that many results
Returns
The settle orders, ordered from earliest settlement date to latest

Definition at line 1286 of file database_api.cpp.

uint64_t graphene::app::database_api::get_committee_count ( ) const

Get the total number of committee registered with the blockchain.

Definition at line 1873 of file database_api.cpp.

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

Get the committee_member owned by a given account.

Parameters
account_name_or_idThe name or ID of the account whose committee_member should be retrieved
Returns
The committee_member object, or null if the account does not have a committee_member

Definition at line 1821 of file database_api.cpp.

vector< optional< committee_member_object > > graphene::app::database_api::get_committee_members ( const vector< committee_member_id_type > &  committee_member_ids) const

Get a list of committee_members by ID.

Parameters
committee_member_idsIDs of the committee_members to retrieve
Returns
The committee_members corresponding to the provided IDs

This function has semantics identical to get_objects, but doesn't subscribe

Definition at line 1802 of file database_api.cpp.

fc::variant_object graphene::app::database_api::get_config ( ) const

Retrieve compile-time constants.

Definition at line 292 of file database_api.cpp.

dynamic_global_property_object graphene::app::database_api::get_dynamic_global_properties ( ) const

Retrieve the current graphene::chain::dynamic_global_property_object.

Definition at line 312 of file database_api.cpp.

std::map< string, full_account > graphene::app::database_api::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.

Parameters
names_or_idsEach item must be the name or ID of an account to retrieve
subscribetrue 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)
Returns
Map of string from names_or_ids to the corresponding account

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.

Definition at line 458 of file database_api.cpp.

global_property_object graphene::app::database_api::get_global_properties ( ) const

Retrieve the current graphene::chain::global_property_object.

Definition at line 282 of file database_api.cpp.

optional< htlc_object > graphene::app::database_api::get_htlc ( htlc_id_type  id,
optional< bool >  subscribe = optional<bool>() 
) const

Get HTLC object.

Parameters
idHTLC contract id
subscribetrue 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)
Returns
HTLC object for the id

Definition at line 2444 of file database_api.cpp.

vector< htlc_object > graphene::app::database_api::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.

Parameters
account_name_or_idAccount name or ID to get objects from
starthtlc objects before this ID will be skipped in results. Pagination purposes.
limitMaximum number of objects to retrieve
Returns
HTLC objects for the account

Definition at line 2459 of file database_api.cpp.

vector< htlc_object > graphene::app::database_api::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.

Parameters
account_name_or_idAccount name or ID to get objects from
starthtlc objects before this ID will be skipped in results. Pagination purposes.
limitMaximum number of objects to retrieve
Returns
HTLC objects for the account

Definition at line 2489 of file database_api.cpp.

vector< flat_set< account_id_type > > graphene::app::database_api::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.

Parameters
keysa list of public keys to query
Returns
ID of all accounts that refer to the specified keys

Definition at line 328 of file database_api.cpp.

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

Get limit orders in a given market.

Parameters
asymbol or ID of asset being sold
bsymbol or ID of asset being purchased
limitMaximum number of orders to retrieve
Returns
The limit orders, ordered from least price to greatest

Definition at line 993 of file database_api.cpp.

vector< limit_order_object > graphene::app::database_api::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.

Parameters
account_name_or_idThe name or ID of an account to retrieve
limitThe limitation of items each query can fetch, not greater than a configured value
start_idStart order id, fetch orders whose IDs are greater than or equal to this order
Returns
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

Definition at line 1013 of file database_api.cpp.

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

Get all open margin positions of a given account.

Parameters
account_name_or_idname or ID of an account
Returns
all open margin positions of the account

Similar to get_call_orders_by_account, but without pagination.

Definition at line 1262 of file database_api.cpp.

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

Semantically equivalent to get_account_balances.

Definition at line 785 of file database_api.cpp.

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

Get the objects corresponding to the provided IDs.

Parameters
idsIDs of the objects to retrieve
subscribetrue 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)
Returns
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.

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

Definition at line 100 of file database_api.cpp.

order_book graphene::app::database_api::get_order_book ( const string &  base,
const string &  quote,
unsigned  limit = 50 
) const

Returns the order book for the market base:quote.

Parameters
basesymbol name or ID of the base asset
quotesymbol name or ID of the quote asset
limitdepth of the order book to retrieve, for bids and asks each, capped at 50
Returns
Order book of the market

Definition at line 1409 of file database_api.cpp.

set< address > graphene::app::database_api::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.

Parameters
trxthe transaction to be signed
Returns
a set of addresses that could possibly sign for the given transaction

Definition at line 2085 of file database_api.cpp.

set< public_key_type > graphene::app::database_api::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.

Parameters
trxthe transaction to be signed
Returns
a set of public keys that could possibly sign for the given transaction

Definition at line 2081 of file database_api.cpp.

vector< proposal_object > graphene::app::database_api::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

Parameters
account_name_or_idThe name or ID of an account
Returns
a set of proposed transactions that the specified account can act on

Definition at line 2309 of file database_api.cpp.

optional< signed_transaction > graphene::app::database_api::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.

Parameters
txidhash of the transaction
Returns
the corresponding transaction if found, or null if not found

Definition at line 249 of file database_api.cpp.

vector< fc::variant > graphene::app::database_api::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.

Parameters
opsa list of operations to be query for required fees
asset_symbol_or_idsymbol name or ID of an asset that to be used to pay the fees
Returns
a list of objects which indicates required fees of each operation

Definition at line 2218 of file database_api.cpp.

set< public_key_type > graphene::app::database_api::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.

Parameters
trxthe transaction to be signed
available_keysa set of public keys
Returns
a subset of available_keys that could sign for the given transaction

Definition at line 2059 of file database_api.cpp.

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

Get forced settlement orders in a given asset.

Parameters
aSymbol or ID of asset being settled
limitMaximum number of orders to retrieve
Returns
The settle orders, ordered from earliest settlement date to latest

Definition at line 1201 of file database_api.cpp.

vector< force_settlement_object > graphene::app::database_api::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.

Parameters
account_name_or_idAccount name or ID to get objects from
startForce settlement objects(1.4.X) before this ID will be skipped in results. Pagination purposes.
limitMaximum number of orders to retrieve
Returns
The settle orders of the account

Definition at line 1229 of file database_api.cpp.

market_ticker graphene::app::database_api::get_ticker ( const string &  base,
const string &  quote 
) const

Returns the ticker for the market assetA:assetB.

Parameters
basesymbol name or ID of the base asset
quotesymbol name or ID of the quote asset
Returns
The market ticker for the past 24 hours.

Definition at line 1356 of file database_api.cpp.

vector< market_ticker > graphene::app::database_api::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.

Parameters
limitMax number of results
Returns
Desc Sorted ticker vector

Definition at line 1461 of file database_api.cpp.

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

Returns recent trades for the market base:quote, ordered by time, most recent first. Note: Currently, timezone offsets are not supported. The time must be UTC. The range is [stop, start). In case when there are more than 100 trades occurred in the same second, this API only returns the first 100 records, can use another API get_trade_history_by_sequence to query for the rest.

Parameters
basesymbol or ID of the base asset
quotesymbol or ID of the quote asset
startStart time as a UNIX timestamp, the latest trade to retrieve
stopStop time as a UNIX timestamp, the earliest trade to retrieve
limitNumber of trasactions to retrieve, capped at 100.
Returns
Recent transactions in the market

Definition at line 1494 of file database_api.cpp.

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

Returns trades for the market base:quote, ordered by time, most recent first. Note: Currently, timezone offsets are not supported. The time must be UTC. The range is [stop, start).

Parameters
basesymbol or ID of the base asset
quotesymbol or ID of the quote asset
startStart sequence as an Integer, the latest trade to retrieve
stopStop time as a UNIX timestamp, the earliest trade to retrieve
limitNumber of trasactions to retrieve, capped at 100
Returns
Transactions in the market

Definition at line 1595 of file database_api.cpp.

processed_transaction graphene::app::database_api::get_transaction ( uint32_t  block_num,
uint32_t  trx_in_block 
) const

used to fetch an individual transaction.

Parameters
block_numheight of the block to fetch
trx_in_blockthe index (sequence number) of the transaction in the block, starts from 0
Returns
the transaction at the given position

Definition at line 244 of file database_api.cpp.

std::string graphene::app::database_api::get_transaction_hex ( const signed_transaction &  trx) const

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

Parameters
trxa transaction to get hexdump from
Returns
the hexdump of the transaction

Definition at line 2037 of file database_api.cpp.

std::string graphene::app::database_api::get_transaction_hex_without_sig ( const signed_transaction &  trx) const

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

Parameters
trxa transaction to get hexdump from
Returns
the hexdump of the transaction without the signatures

Definition at line 2047 of file database_api.cpp.

vector< asset > graphene::app::database_api::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.

Parameters
objsa list of balance object IDs
Returns
a list indicating how much asset in each balance object is available to be claimed

Definition at line 819 of file database_api.cpp.

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

Return all vesting balance objects owned by an account.

Parameters
account_name_or_idname or ID of an account
Returns
all vesting balance objects owned by the account

Definition at line 837 of file database_api.cpp.

vector< withdraw_permission_object > graphene::app::database_api::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)

Parameters
account_name_or_idAccount name or ID to get objects from
startWithdraw permission objects(1.12.X) before this ID will be skipped in results. Pagination purposes.
limitMaximum number of objects to retrieve
Returns
Withdraw permission objects for the account

Definition at line 2371 of file database_api.cpp.

vector< withdraw_permission_object > graphene::app::database_api::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)

Parameters
account_name_or_idAccount name or ID to get objects from
startWithdraw permission objects(1.12.X) before this ID will be skipped in results. Pagination purposes.
limitMaximum number of objects to retrieve
Returns
Withdraw permission objects for the account

Definition at line 2405 of file database_api.cpp.

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

Get the witness owned by a given account.

Parameters
account_name_or_idThe name or ID of the account whose witness should be retrieved
Returns
The witness object, or null if the account does not have a witness

Definition at line 1736 of file database_api.cpp.

uint64_t graphene::app::database_api::get_witness_count ( ) const

Get the total number of witnesses registered with the blockchain.

Definition at line 1786 of file database_api.cpp.

vector< optional< witness_object > > graphene::app::database_api::get_witnesses ( const vector< witness_id_type > &  witness_ids) const

Get a list of witnesses by ID.

Parameters
witness_idsIDs of the witnesses to retrieve
Returns
The witnesses corresponding to the provided IDs

This function has semantics identical to get_objects, but doesn't subscribe

Definition at line 1719 of file database_api.cpp.

uint64_t graphene::app::database_api::get_worker_count ( ) const

Get the total number of workers registered with the blockchain.

Definition at line 1942 of file database_api.cpp.

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

Get the workers owned by a given account.

Parameters
account_name_or_idThe name or ID of the account whose worker should be retrieved
Returns
A list of worker objects owned by the account

Definition at line 1923 of file database_api.cpp.

bool graphene::app::database_api::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

Parameters
public_keyPublic key
Returns
Whether a public key is known

Definition at line 389 of file database_api.cpp.

vector< extended_asset_object > graphene::app::database_api::list_assets ( const string &  lower_bound_symbol,
uint32_t  limit 
) const

Get assets alphabetically by symbol name.

Parameters
lower_bound_symbolLower bound of symbol names to retrieve
limitMaximum number of assets to fetch (must not exceed 101)
Returns
The assets found

Definition at line 896 of file database_api.cpp.

vector< htlc_object > graphene::app::database_api::list_htlcs ( const htlc_id_type  start,
uint32_t  limit 
) const

Get all HTLCs.

Parameters
startLower bound of htlc id to start getting results
limitMaximum number of htlc objects to fetch
Returns
The htlc object list

Definition at line 2519 of file database_api.cpp.

vector< optional< account_object > > graphene::app::database_api::lookup_account_names ( const vector< string > &  account_names) const

Get a list of accounts by name.

Parameters
account_namesNames of the accounts to retrieve
Returns
The accounts holding the provided names

This function has semantics identical to get_objects, but doesn't subscribe.

Definition at line 683 of file database_api.cpp.

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

Get names and IDs for registered accounts.

Parameters
lower_bound_nameLower bound of the first name to return
limitMaximum number of results to return – must not exceed 1000
subscribetrue 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)
Returns
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.

Definition at line 701 of file database_api.cpp.

vector< optional< extended_asset_object > > graphene::app::database_api::lookup_asset_symbols ( const vector< string > &  symbols_or_ids) const

Get a list of assets by symbol names or IDs.

Parameters
symbols_or_idssymbol names or IDs of the assets to retrieve
Returns
The assets corresponding to the provided symbols or IDs

This function has semantics identical to get_objects, but doesn't subscribe

Definition at line 962 of file database_api.cpp.

map< string, committee_member_id_type > graphene::app::database_api::lookup_committee_member_accounts ( const string &  lower_bound_name,
uint32_t  limit 
) const

Get names and IDs for registered committee_members.

Parameters
lower_bound_nameLower bound of the first name to return
limitMaximum number of results to return – must not exceed 1000
Returns
Map of committee_member names to corresponding IDs

Definition at line 1838 of file database_api.cpp.

vector< variant > graphene::app::database_api::lookup_vote_ids ( const vector< vote_id_type > &  votes) const

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

Parameters
votesa list of vote IDs
Returns
the referenced objects

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

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

Definition at line 1960 of file database_api.cpp.

map< string, witness_id_type > graphene::app::database_api::lookup_witness_accounts ( const string &  lower_bound_name,
uint32_t  limit 
) const

Get names and IDs for registered witnesses.

Parameters
lower_bound_nameLower bound of the first name to return
limitMaximum number of results to return – must not exceed 1000
Returns
Map of witness names to corresponding IDs

Definition at line 1751 of file database_api.cpp.

void graphene::app::database_api::set_auto_subscription ( bool  enable)

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

Parameters
enablewhether follow-up API queries will automatically subscribe to queried objects

Impacts behavior of these APIs:

  • get_accounts
  • get_assets
  • get_objects
  • lookup_accounts
  • get_full_accounts
  • get_htlc

Note: auto-subscription is enabled by default

See also
set_subscribe_callback

Definition at line 151 of file database_api.cpp.

void graphene::app::database_api::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
cbThe callback handle to register

Definition at line 171 of file database_api.cpp.

void graphene::app::database_api::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.

Parameters
cbThe callback handle to register

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.

Definition at line 161 of file database_api.cpp.

void graphene::app::database_api::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.

Parameters
cbThe callback handle to register
notify_remove_createWhether 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.

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

Definition at line 132 of file database_api.cpp.

void graphene::app::database_api::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.

Parameters
callbackCallback method which is called when the market changes
asymbol name or ID of the first asset
bsymbol name or ID of the second asset

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.

Definition at line 1324 of file database_api.cpp.

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

Unsubscribe from updates to a given market.

Parameters
asymbol name or ID of the first asset
bsymbol name or ID of the second asset

Definition at line 1341 of file database_api.cpp.

processed_transaction graphene::app::database_api::validate_transaction ( const signed_transaction &  trx) const

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

Parameters
trxa transaction to be validated
Returns
a processed_transaction object if the transaction passes the validation, otherwise an exception will be thrown

Definition at line 2208 of file database_api.cpp.

bool graphene::app::database_api::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.

Parameters
account_name_or_idname or ID of an account to check
signersthe public keys
Returns
true if the passed in keys have enough authority to approve an operation for this account

Definition at line 2176 of file database_api.cpp.

bool graphene::app::database_api::verify_authority ( const signed_transaction &  trx) const

Check whether a transaction has all of the required signatures

Parameters
trxa transaction to be verified
Returns
true if the trx has all of the required signatures, otherwise throws an exception

Definition at line 2158 of file database_api.cpp.


The documentation for this class was generated from the following files: