BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface software
api.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #include <cctype>
25 
26 #include <graphene/app/api.hpp>
38 
39 #include <fc/crypto/base64.hpp>
40 #include <fc/crypto/hex.hpp>
42 #include <fc/thread/future.hpp>
43 
54 
55 
56 namespace graphene { namespace app {
57 
58  login_api::login_api(application& a)
59  :_app(a)
60  {
61  }
62 
64  {
65  }
66 
67  bool login_api::login(const string& user, const string& password)
68  {
70  if( !acc.valid() )
71  return false;
72  if( acc->password_hash_b64 != "*" )
73  {
74  std::string password_salt = fc::base64_decode( acc->password_salt_b64 );
75  std::string acc_password_hash = fc::base64_decode( acc->password_hash_b64 );
76 
77  fc::sha256 hash_obj = fc::sha256::hash( password + password_salt );
78  if( hash_obj.data_size() != acc_password_hash.length() )
79  return false;
80  if( memcmp( hash_obj.data(), acc_password_hash.c_str(), hash_obj.data_size() ) != 0 )
81  return false;
82  }
83 
84  for( const std::string& api_name : acc->allowed_apis )
85  enable_api( api_name );
86  return true;
87  }
88 
89  void login_api::enable_api( const std::string& api_name )
90  {
91  if( api_name == "database_api" )
92  {
93  _database_api = std::make_shared< database_api >( std::ref( *_app.chain_database() ), &( _app.get_options() ) );
94  }
95  else if( api_name == "block_api" )
96  {
97  _block_api = std::make_shared< block_api >( std::ref( *_app.chain_database() ) );
98  }
99  else if( api_name == "network_broadcast_api" )
100  {
101  _network_broadcast_api = std::make_shared< network_broadcast_api >( std::ref( _app ) );
102  }
103  else if( api_name == "history_api" )
104  {
105  _history_api = std::make_shared< history_api >( _app );
106  }
107  else if( api_name == "network_node_api" )
108  {
109  _network_node_api = std::make_shared< network_node_api >( std::ref(_app) );
110  }
111  else if( api_name == "crypto_api" )
112  {
113  _crypto_api = std::make_shared< crypto_api >();
114  }
115  else if( api_name == "asset_api" )
116  {
117  _asset_api = std::make_shared< asset_api >( _app );
118  }
119  else if( api_name == "orders_api" )
120  {
121  _orders_api = std::make_shared< orders_api >( std::ref( _app ) );
122  }
123  else if( api_name == "custom_operations_api" )
124  {
125  if( _app.get_plugin( "custom_operations" ) )
126  _custom_operations_api = std::make_shared< custom_operations_api >( std::ref( _app ) );
127  }
128  else if( api_name == "debug_api" )
129  {
130  // can only enable this API if the plugin was loaded
131  if( _app.get_plugin( "debug_witness" ) )
132  _debug_api = std::make_shared< graphene::debug_witness::debug_api >( std::ref(_app) );
133  }
134  return;
135  }
136 
137  // block_api
140 
141  vector<optional<signed_block>> block_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to)const
142  {
143  FC_ASSERT( block_num_to >= block_num_from );
144  vector<optional<signed_block>> res;
145  for(uint32_t block_num=block_num_from; block_num<=block_num_to; block_num++) {
146  res.push_back(_db.fetch_block_by_number(block_num));
147  }
148  return res;
149  }
150 
152  {
153  _applied_block_connection = _app.chain_database()->applied_block.connect([this](const signed_block& b){ on_applied_block(b); });
154  }
155 
156  void network_broadcast_api::on_applied_block( const signed_block& b )
157  {
158  if( _callbacks.size() )
159  {
161  auto capture_this = shared_from_this();
162  for( uint32_t trx_num = 0; trx_num < b.transactions.size(); ++trx_num )
163  {
164  const auto& trx = b.transactions[trx_num];
165  auto id = trx.id();
166  auto itr = _callbacks.find(id);
167  if( itr != _callbacks.end() )
168  {
169  auto block_num = b.block_num();
170  auto& callback = _callbacks.find(id)->second;
171  auto v = fc::variant( transaction_confirmation{ id, block_num, trx_num, trx }, GRAPHENE_MAX_NESTED_OBJECTS );
172  fc::async( [capture_this,v,callback]() {
173  callback(v);
174  } );
175  }
176  }
177  }
178  }
179 
180  void network_broadcast_api::broadcast_transaction(const precomputable_transaction& trx)
181  {
182  _app.chain_database()->precompute_parallel( trx ).wait();
183  _app.chain_database()->push_transaction(trx);
184  if( _app.p2p_node() != nullptr )
185  _app.p2p_node()->broadcast_transaction(trx);
186  }
187 
189  {
192  prom->set_value(v);
193  }, trx );
194 
195  return fc::future<fc::variant>(prom).wait();
196  }
197 
198  void network_broadcast_api::broadcast_block( const signed_block& b )
199  {
200  _app.chain_database()->precompute_parallel( b ).wait();
201  _app.chain_database()->push_block(b);
202  if( _app.p2p_node() != nullptr )
203  _app.p2p_node()->broadcast( net::block_message( b ));
204  }
205 
207  {
208  _app.chain_database()->precompute_parallel( trx ).wait();
209  _callbacks[trx.id()] = cb;
210  _app.chain_database()->push_transaction(trx);
211  if( _app.p2p_node() != nullptr )
212  _app.p2p_node()->broadcast_transaction(trx);
213  }
214 
216  {
217  }
218 
220  {
221  fc::mutable_variant_object result = _app.p2p_node()->network_get_info();
222  result["connection_count"] = _app.p2p_node()->get_connection_count();
223  return result;
224  }
225 
227  {
228  _app.p2p_node()->add_node(ep);
229  }
230 
231  std::vector<net::peer_status> network_node_api::get_connected_peers() const
232  {
233  return _app.p2p_node()->get_connected_peers();
234  }
235 
236  std::vector<net::potential_peer_record> network_node_api::get_potential_peers() const
237  {
238  return _app.p2p_node()->get_potential_peers();
239  }
240 
242  {
243  return _app.p2p_node()->get_advanced_node_parameters();
244  }
245 
247  {
248  return _app.p2p_node()->set_advanced_node_parameters(params);
249  }
250 
252  {
253  FC_ASSERT(_network_broadcast_api);
254  return *_network_broadcast_api;
255  }
256 
258  {
259  FC_ASSERT(_block_api);
260  return *_block_api;
261  }
262 
264  {
265  FC_ASSERT(_network_node_api);
266  return *_network_node_api;
267  }
268 
270  {
271  FC_ASSERT(_database_api);
272  return *_database_api;
273  }
274 
276  {
277  FC_ASSERT(_history_api);
278  return *_history_api;
279  }
280 
282  {
283  FC_ASSERT(_crypto_api);
284  return *_crypto_api;
285  }
286 
288  {
289  FC_ASSERT(_asset_api);
290  return *_asset_api;
291  }
292 
294  {
295  FC_ASSERT(_orders_api);
296  return *_orders_api;
297  }
298 
300  {
301  FC_ASSERT(_debug_api);
302  return *_debug_api;
303  }
304 
306  {
307  FC_ASSERT(_custom_operations_api);
308  return *_custom_operations_api;
309  }
310 
311  vector<order_history_object> history_api::get_fill_order_history( std::string asset_a, std::string asset_b, uint32_t limit )const
312  {
313  FC_ASSERT(_app.chain_database());
314  const auto& db = *_app.chain_database();
315  asset_id_type a = database_api.get_asset_id_from_string( asset_a );
316  asset_id_type b = database_api.get_asset_id_from_string( asset_b );
317  if( a > b ) std::swap(a,b);
318  const auto& history_idx = db.get_index_type<graphene::market_history::history_index>().indices().get<by_key>();
319  history_key hkey;
320  hkey.base = a;
321  hkey.quote = b;
322  hkey.sequence = std::numeric_limits<int64_t>::min();
323 
324  uint32_t count = 0;
325  auto itr = history_idx.lower_bound( hkey );
326  vector<order_history_object> result;
327  while( itr != history_idx.end() && count < limit)
328  {
329  if( itr->key.base != a || itr->key.quote != b ) break;
330  result.push_back( *itr );
331  ++itr;
332  ++count;
333  }
334 
335  return result;
336  }
337 
338  vector<operation_history_object> history_api::get_account_history( const std::string account_id_or_name,
339  operation_history_id_type stop,
340  unsigned limit,
341  operation_history_id_type start ) const
342  {
343  FC_ASSERT( _app.chain_database() );
344  const auto& db = *_app.chain_database();
345 
346  const auto configured_limit = _app.get_options().api_limit_get_account_history;
347  FC_ASSERT( limit <= configured_limit,
348  "limit can not be greater than ${configured_limit}",
349  ("configured_limit", configured_limit) );
350 
351  vector<operation_history_object> result;
352  account_id_type account;
353  try {
354  account = database_api.get_account_id_from_string(account_id_or_name);
355  const account_transaction_history_object& node = account(db).statistics(db).most_recent_op(db);
356  if(start == operation_history_id_type() || start.instance.value > node.operation_id.instance.value)
357  start = node.operation_id;
358  } catch(...) { return result; }
359 
360  if(_app.is_plugin_enabled("elasticsearch")) {
361  auto es = _app.get_plugin<elasticsearch::elasticsearch_plugin>("elasticsearch");
362  if(es.get()->get_running_mode() != elasticsearch::mode::only_save) {
363  if(!_app.elasticsearch_thread)
364  _app.elasticsearch_thread= std::make_shared<fc::thread>("elasticsearch");
365 
366  return _app.elasticsearch_thread->async([&es, &account, &stop, &limit, &start]() {
367  return es->get_account_history(account, stop, limit, start);
368  }, "thread invoke for method " BOOST_PP_STRINGIZE(method_name)).wait();
369  }
370  }
371 
372  const auto& hist_idx = db.get_index_type<account_transaction_history_index>();
373  const auto& by_op_idx = hist_idx.indices().get<by_op>();
374  auto index_start = by_op_idx.begin();
375  auto itr = by_op_idx.lower_bound(boost::make_tuple(account, start));
376 
377  while(itr != index_start && itr->account == account && itr->operation_id.instance.value > stop.instance.value && result.size() < limit)
378  {
379  if(itr->operation_id.instance.value <= start.instance.value)
380  result.push_back(itr->operation_id(db));
381  --itr;
382  }
383  if(stop.instance.value == 0 && result.size() < limit && itr->account == account) {
384  result.push_back(itr->operation_id(db));
385  }
386 
387  return result;
388  }
389 
390  vector<operation_history_object> history_api::get_account_history_operations( const std::string account_id_or_name,
391  int operation_type,
392  operation_history_id_type start,
393  operation_history_id_type stop,
394  unsigned limit ) const
395  {
396  FC_ASSERT( _app.chain_database() );
397  const auto& db = *_app.chain_database();
398 
399  const auto configured_limit = _app.get_options().api_limit_get_account_history_operations;
400  FC_ASSERT( limit <= configured_limit,
401  "limit can not be greater than ${configured_limit}",
402  ("configured_limit", configured_limit) );
403 
404  vector<operation_history_object> result;
405  account_id_type account;
406  try {
407  account = database_api.get_account_id_from_string(account_id_or_name);
408  } catch(...) { return result; }
409  const auto& stats = account(db).statistics(db);
410  if( stats.most_recent_op == account_transaction_history_id_type() ) return result;
411  const account_transaction_history_object* node = &stats.most_recent_op(db);
412  if( start == operation_history_id_type() )
413  start = node->operation_id;
414 
415  while(node && node->operation_id.instance.value > stop.instance.value && result.size() < limit)
416  {
417  if( node->operation_id.instance.value <= start.instance.value ) {
418 
419  if(node->operation_id(db).op.which() == operation_type)
420  result.push_back( node->operation_id(db) );
421  }
422  if( node->next == account_transaction_history_id_type() )
423  node = nullptr;
424  else node = &node->next(db);
425  }
426  if( stop.instance.value == 0 && result.size() < limit ) {
427  auto head = db.find(account_transaction_history_id_type());
428  if (head != nullptr && head->account == account && head->operation_id(db).op.which() == operation_type)
429  result.push_back(head->operation_id(db));
430  }
431  return result;
432  }
433 
434 
435  vector<operation_history_object> history_api::get_relative_account_history( const std::string account_id_or_name,
436  uint64_t stop,
437  unsigned limit,
438  uint64_t start ) const
439  {
440  FC_ASSERT( _app.chain_database() );
441  const auto& db = *_app.chain_database();
442 
443  const auto configured_limit = _app.get_options().api_limit_get_relative_account_history;
444  FC_ASSERT( limit <= configured_limit,
445  "limit can not be greater than ${configured_limit}",
446  ("configured_limit", configured_limit) );
447 
448  vector<operation_history_object> result;
449  account_id_type account;
450  try {
451  account = database_api.get_account_id_from_string(account_id_or_name);
452  } catch(...) { return result; }
453  const auto& stats = account(db).statistics(db);
454  if( start == 0 )
455  start = stats.total_ops;
456  else
457  start = std::min( stats.total_ops, start );
458 
459  if( start >= stop && start > stats.removed_ops && limit > 0 )
460  {
461  const auto& hist_idx = db.get_index_type<account_transaction_history_index>();
462  const auto& by_seq_idx = hist_idx.indices().get<by_seq>();
463 
464  auto itr = by_seq_idx.upper_bound( boost::make_tuple( account, start ) );
465  auto itr_stop = by_seq_idx.lower_bound( boost::make_tuple( account, stop ) );
466 
467  do
468  {
469  --itr;
470  result.push_back( itr->operation_id(db) );
471  }
472  while ( itr != itr_stop && result.size() < limit );
473  }
474  return result;
475  }
476 
477  flat_set<uint32_t> history_api::get_market_history_buckets()const
478  {
479  auto hist = _app.get_plugin<market_history_plugin>( "market_history" );
480  FC_ASSERT( hist );
481  return hist->tracked_buckets();
482  }
483 
485  flat_set<uint16_t> operation_types,
486  uint32_t start, unsigned limit )const
487  {
488  const auto configured_limit = _app.get_options().api_limit_get_account_history_by_operations;
489  FC_ASSERT( limit <= configured_limit,
490  "limit can not be greater than ${configured_limit}",
491  ("configured_limit", configured_limit) );
492 
494  vector<operation_history_object> objs = get_relative_account_history( account_id_or_name, start, limit,
495  limit + start - 1 );
496  result.total_count = objs.size();
497 
498  if( operation_types.empty() )
499  result.operation_history_objs = std::move(objs);
500  else
501  {
502  for( const operation_history_object &o : objs )
503  {
504  if( operation_types.find(o.op.which()) != operation_types.end() ) {
505  result.operation_history_objs.push_back(o);
506  }
507  }
508  }
509 
510  return result;
511  }
512 
513  vector<bucket_object> history_api::get_market_history( std::string asset_a, std::string asset_b,
514  uint32_t bucket_seconds,
515  fc::time_point_sec start, fc::time_point_sec end )const
516  { try {
517  FC_ASSERT(_app.chain_database());
518  const auto& db = *_app.chain_database();
519  asset_id_type a = database_api.get_asset_id_from_string( asset_a );
520  asset_id_type b = database_api.get_asset_id_from_string( asset_b );
521  vector<bucket_object> result;
522  result.reserve(200);
523 
524  if( a > b ) std::swap(a,b);
525 
526  const auto& bidx = db.get_index_type<bucket_index>();
527  const auto& by_key_idx = bidx.indices().get<by_key>();
528 
529  auto itr = by_key_idx.lower_bound( bucket_key( a, b, bucket_seconds, start ) );
530  while( itr != by_key_idx.end() && itr->key.open <= end && result.size() < 200 )
531  {
532  if( !(itr->key.base == a && itr->key.quote == b && itr->key.seconds == bucket_seconds) )
533  {
534  return result;
535  }
536  result.push_back(*itr);
537  ++itr;
538  }
539  return result;
540  } FC_CAPTURE_AND_RETHROW( (asset_a)(asset_b)(bucket_seconds)(start)(end) ) }
541 
543 
545  {
546  return fc::ecc::blind( blind, value );
547  }
548 
549  blind_factor_type crypto_api::blind_sum( const std::vector<blind_factor_type>& blinds_in, uint32_t non_neg )
550  {
551  return fc::ecc::blind_sum( blinds_in, non_neg );
552  }
553 
554  bool crypto_api::verify_sum( const std::vector<commitment_type>& commits_in, const std::vector<commitment_type>& neg_commits_in, int64_t excess )
555  {
556  return fc::ecc::verify_sum( commits_in, neg_commits_in, excess );
557  }
558 
559  verify_range_result crypto_api::verify_range( const commitment_type& commit, const std::vector<char>& proof )
560  {
561  verify_range_result result;
562  result.success = fc::ecc::verify_range( result.min_val, result.max_val, commit, proof );
563  return result;
564  }
565 
566  std::vector<char> crypto_api::range_proof_sign( uint64_t min_value,
567  const commitment_type& commit,
568  const blind_factor_type& commit_blind,
569  const blind_factor_type& nonce,
570  int8_t base10_exp,
571  uint8_t min_bits,
572  uint64_t actual_value )
573  {
574  return fc::ecc::range_proof_sign( min_value, commit, commit_blind, nonce, base10_exp, min_bits, actual_value );
575  }
576 
578  const commitment_type& commit,
579  const std::vector<char>& proof )
580  {
583  result.value_out,
584  result.message_out,
585  nonce,
586  result.min_val,
587  result.max_val,
588  const_cast< commitment_type& >( commit ),
589  proof );
590  return result;
591  }
592 
593  range_proof_info crypto_api::range_get_info( const std::vector<char>& proof )
594  {
595  return fc::ecc::range_get_info( proof );
596  }
597 
598  // asset_api
600  _app(app),
601  _db( *app.chain_database()),
602  database_api( std::ref(*app.chain_database()), &(app.get_options())
603  ) { }
605 
606  vector<account_asset_balance> asset_api::get_asset_holders( std::string asset, uint32_t start, uint32_t limit ) const
607  {
608  const auto configured_limit = _app.get_options().api_limit_get_asset_holders;
609  FC_ASSERT( limit <= configured_limit,
610  "limit can not be greater than ${configured_limit}",
611  ("configured_limit", configured_limit) );
612 
613  asset_id_type asset_id = database_api.get_asset_id_from_string( asset );
614  const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
615  auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );
616 
617  vector<account_asset_balance> result;
618 
619  uint32_t index = 0;
620  for( const account_balance_object& bal : boost::make_iterator_range( range.first, range.second ) )
621  {
622  if( result.size() >= limit )
623  break;
624 
625  if( bal.balance.value == 0 )
626  continue;
627 
628  if( index++ < start )
629  continue;
630 
631  const auto account = _db.find(bal.owner);
632 
634  aab.name = account->name;
635  aab.account_id = account->id;
636  aab.amount = bal.balance.value;
637 
638  result.push_back(aab);
639  }
640 
641  return result;
642  }
643  // get number of asset holders.
644  int asset_api::get_asset_holders_count( std::string asset ) const {
645  const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
646  asset_id_type asset_id = database_api.get_asset_id_from_string( asset );
647  auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );
648 
649  int count = boost::distance(range) - 1;
650 
651  return count;
652  }
653  // function to get vector of system assets with holders count.
654  vector<asset_holders> asset_api::get_all_asset_holders() const {
655  vector<asset_holders> result;
656  vector<asset_id_type> total_assets;
657  for( const asset_object& asset_obj : _db.get_index_type<asset_index>().indices() )
658  {
659  const auto& dasset_obj = asset_obj.dynamic_asset_data_id(_db);
660 
661  asset_id_type asset_id;
662  asset_id = dasset_obj.id;
663 
664  const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
665  auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );
666 
667  int count = boost::distance(range) - 1;
668 
669  asset_holders ah;
670  ah.asset_id = asset_id;
671  ah.count = count;
672 
673  result.push_back(ah);
674  }
675 
676  return result;
677  }
678 
679  // orders_api
680  flat_set<uint16_t> orders_api::get_tracked_groups()const
681  {
682  auto plugin = _app.get_plugin<grouped_orders_plugin>( "grouped_orders" );
683  FC_ASSERT( plugin );
684  return plugin->tracked_groups();
685  }
686 
687  vector< limit_order_group > orders_api::get_grouped_limit_orders( std::string base_asset,
688  std::string quote_asset,
689  uint16_t group,
690  optional<price> start,
691  uint32_t limit )const
692  {
693  const auto configured_limit = _app.get_options().api_limit_get_grouped_limit_orders;
694  FC_ASSERT( limit <= configured_limit,
695  "limit can not be greater than ${configured_limit}",
696  ("configured_limit", configured_limit) );
697 
698  auto plugin = _app.get_plugin<graphene::grouped_orders::grouped_orders_plugin>( "grouped_orders" );
699  FC_ASSERT( plugin );
700  const auto& limit_groups = plugin->limit_order_groups();
701  vector< limit_order_group > result;
702 
703  asset_id_type base_asset_id = database_api.get_asset_id_from_string( base_asset );
704  asset_id_type quote_asset_id = database_api.get_asset_id_from_string( quote_asset );
705 
706  price max_price = price::max( base_asset_id, quote_asset_id );
707  price min_price = price::min( base_asset_id, quote_asset_id );
708  if( start.valid() && !start->is_null() )
709  max_price = std::max( std::min( max_price, *start ), min_price );
710 
711  auto itr = limit_groups.lower_bound( limit_order_group_key( group, max_price ) );
712  // use an end iterator to try to avoid expensive price comparison
713  auto end = limit_groups.upper_bound( limit_order_group_key( group, min_price ) );
714  while( itr != end && result.size() < limit )
715  {
716  result.emplace_back( *itr );
717  ++itr;
718  }
719  return result;
720  }
721 
722  // custom operations api
723  vector<account_storage_object> custom_operations_api::get_storage_info(std::string account_id_or_name,
724  std::string catalog)const
725  {
727  FC_ASSERT( plugin );
728 
729  const auto account_id = database_api.get_account_id_from_string(account_id_or_name);
730  vector<account_storage_object> results;
731  const auto& storage_index = _app.chain_database()->get_index_type<account_storage_index>();
732  const auto& by_account_catalog_idx = storage_index.indices().get<by_account_catalog_key>();
733  auto range = by_account_catalog_idx.equal_range(make_tuple(account_id, catalog));
734  for( const account_storage_object& aso : boost::make_iterator_range( range.first, range.second ) )
735  results.push_back(aso);
736  return results;
737  }
738 
739 } } // graphene::app
asset_id_type asset_id
Definition: api.hpp:91
fc::optional< api_access_info > get_api_access_info(const string &username) const
Tracks the balance of a single account/asset pairThis object is indexed on owner and asset_type so th...
std::shared_ptr< fc::thread > elasticsearch_thread
vector< optional< signed_block > > get_blocks(uint32_t block_num_from, uint32_t block_num_to) const
Get signed blocks.
Definition: api.cpp:141
fc::api< graphene::debug_witness::debug_api > debug() const
Retrieve the debug API (if available)
Definition: api.cpp:299
fc::variant broadcast_transaction_synchronous(const precomputable_transaction &trx)
Definition: api.cpp:188
auto async(Functor &&f, const char *desc FC_TASK_NAME_DEFAULT_ARG, priority prio=priority()) -> fc::future< decltype(f())>
Definition: thread.hpp:227
history_operation_detail get_account_history_by_operations(const std::string account_id_or_name, flat_set< uint16_t > operation_types, uint32_t start, unsigned limit) const
Get operations relevant to the specified account filtering by operation type.
Definition: api.cpp:484
static ptr create(const char *desc FC_TASK_NAME_DEFAULT_ARG)
Definition: future.hpp:114
a placeholder for the result of an asynchronous operation.
Definition: future.hpp:211
virtual void open(const fc::path &db)=0
void broadcast_transaction_with_callback(confirmation_callback cb, const precomputable_transaction &trx)
Definition: api.cpp:206
const T * find(object_id_type id) const
bool verify_range(uint64_t &min_val, uint64_t &max_val, const commitment_type &commit, const range_proof_type &proof)
fc::api< database_api > database() const
Retrieve the database API.
Definition: api.cpp:269
vector< operation_history_object > get_relative_account_history(const std::string account_id_or_name, uint64_t stop=0, unsigned limit=100, uint64_t start=0) const
Get operations relevant to the specified account referenced by an event numbering specific to the acc...
Definition: api.cpp:435
void on_applied_block(const signed_block &b)
Not reflected, thus not accessible to API clients.
Definition: api.cpp:156
static constexpr size_t data_size()
Definition: sha256.hpp:21
T wait(boost::signals2::signal< void(T)> &sig, const microseconds &timeout_us=microseconds::maximum())
Definition: signals.hpp:38
bool verify_sum(const std::vector< commitment_type > &commits, const std::vector< commitment_type > &neg_commits, int64_t excess)
#define GRAPHENE_MAX_NESTED_OBJECTS
Definition: config.hpp:31
tracks the history of all logical operations on blockchain stateAll operations and virtual operations...
flat_set< uint16_t > get_tracked_groups() const
Get tracked groups configured by the server.
Definition: api.cpp:680
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
An order-perserving dictionary of variant&#39;s.
Definition: api.cpp:56
range_proof_info range_get_info(const range_proof_type &proof)
vector< account_storage_object > get_storage_info(std::string account_id_or_name, std::string catalog) const
Get all stored objects of an account in a particular catalog.
Definition: api.cpp:723
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 fa...
Definition: api.cpp:566
void set_advanced_node_parameters(const fc::variant_object &params)
Set advanced node parameters, such as desired and max number of connections.
Definition: api.cpp:246
fc::api< crypto_api > crypto() const
Retrieve the cryptography API.
Definition: api.cpp:281
a node in a linked list of operation_history_objectsAccount history is important for users and wallet...
bool login(const string &user, const string &password)
Authenticate to the RPC server.
Definition: api.cpp:67
fc::api< history_api > history() const
Retrieve the history API.
Definition: api.cpp:275
bool valid() const
Definition: optional.hpp:186
block_api(graphene::chain::database &db)
Definition: api.cpp:138
fc::api< network_broadcast_api > network_broadcast() const
Retrieve the network broadcast API.
Definition: api.cpp:251
void enable_api(const string &api_name)
Called to enable an API, not reflected.
Definition: api.cpp:89
asset_id_type get_asset_id_from_string(const std::string &symbol_or_id) const
Get asset ID from an asset symbol or ID.
std::vector< net::potential_peer_record > get_potential_peers() const
Return list of potential peers.
Definition: api.cpp:236
fc::api< block_api > block() const
Retrieve the network block API.
Definition: api.cpp:257
bool is_plugin_enabled(const string &name) const
fc::api< network_node_api > network_node() const
Retrieve the network node API.
Definition: api.cpp:263
network_node_api(application &a)
Definition: api.cpp:215
vector< operation_history_object > get_account_history_operations(const std::string account_id_or_name, int operation_type, operation_history_id_type start=operation_history_id_type(), operation_history_id_type stop=operation_history_id_type(), unsigned limit=100) const
Get only asked operations relevant to the specified account.
Definition: api.cpp:390
fc::ecc::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...
Definition: api.cpp:544
price min() const
Definition: asset.hpp:131
optional< signed_block > fetch_block_by_number(uint32_t num) const
Definition: db_block.cpp:75
int get_asset_holders_count(std::string asset) const
Get asset holders count for a specific asset.
Definition: api.cpp:644
static sha256 hash(const char *d, uint32_t dlen)
Definition: sha256.cpp:41
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
void broadcast_transaction(const precomputable_transaction &trx)
Broadcast a transaction to the network.
Definition: api.cpp:180
commitment_type blind(const blind_factor_type &blind, uint64_t value)
fc::api< orders_api > orders() const
Retrieve the orders API.
Definition: api.cpp:293
asset_api(graphene::app::application &app)
Definition: api.cpp:599
char * data() const
Definition: sha256.cpp:29
std::shared_ptr< abstract_plugin > get_plugin(const string &name) const
vector< operation_history_object > operation_history_objs
Definition: api.hpp:97
void add_node(const fc::ip::endpoint &ep)
add_node Connect to a new peer
Definition: api.cpp:226
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.
Definition: api.cpp:554
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 t...
Definition: api.cpp:593
void set_value(const T &v)
Definition: future.hpp:136
account_id_type get_account_id_from_string(const std::string &name_or_id) const
Get account object from a name or ID.
verify_range_result verify_range(const fc::ecc::commitment_type &commit, const std::vector< char > &proof)
Verifies range proof for 33-byte pedersen commitment.
Definition: api.cpp:559
fc::variant_object get_info() const
Return general network information, such as p2p port.
Definition: api.cpp:219
void broadcast_block(const signed_block &block)
Broadcast a signed block to the network.
Definition: api.cpp:198
#define FC_CAPTURE_AND_RETHROW(...)
Definition: exception.hpp:478
flat_set< uint32_t > get_market_history_buckets() const
Get OHLCV time bucket lengths supported (configured) by this API server.
Definition: api.cpp:477
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Definition: exception.hpp:345
vector< asset_holders > get_all_asset_holders() const
Get all asset holders.
Definition: api.cpp:654
The database_api class implements the RPC API for the chain database.
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object&#39;s.
Definition: variant.hpp:198
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.
Definition: api.cpp:687
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.
Definition: api.cpp:513
std::function< void(variant)> confirmation_callback
Definition: api.hpp:266
bool verify_range_proof_rewind(blind_factor_type &blind_out, uint64_t &value_out, string &message_out, const blind_factor_type &nonce, uint64_t &min_val, uint64_t &max_val, commitment_type commit, const range_proof_type &proof)
vector< account_asset_balance > get_asset_holders(std::string asset, uint32_t start, uint32_t limit) const
Get asset holders for a specific asset.
Definition: api.cpp:606
fc::ecc::blind_factor_type blind_sum(const std::vector< blind_factor_type > &blinds_in, uint32_t non_neg)
Get sha-256 blind factor type.
Definition: api.cpp:549
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.
Definition: api.cpp:577
fc::api< asset_api > asset() const
Retrieve the asset API.
Definition: api.cpp:287
tracks the parameters of an assetAll assets have a globally unique symbol name that controls how they...
range_proof_type 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)
const application_options & get_options()
std::vector< net::peer_status > get_connected_peers() const
Get status of all current connections to peers.
Definition: api.cpp:231
blind_factor_type blind_sum(const std::vector< blind_factor_type > &blinds, uint32_t non_neg)
const object & get(object_id_type id) const
Definition: index.hpp:111
std::string base64_decode(const std::string &encoded_string)
Definition: base64.cpp:96
account_transaction_history_id_type next
the operation position within the given account
abstract base class for accessing objects indexed in various ways.
Definition: index.hpp:71
std::shared_ptr< chain::database > chain_database() const
vector< operation_history_object > get_account_history(const std::string account_id_or_name, operation_history_id_type stop=operation_history_id_type(), unsigned limit=100, operation_history_id_type start=operation_history_id_type()) const
Get operations relevant to the specificed account.
Definition: api.cpp:338
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.
Definition: api.cpp:311
fc::ecc::blind_factor_type blind_out
Definition: api.hpp:79
std::shared_ptr< promise< T > > ptr
Definition: future.hpp:111
price max() const
Definition: asset.hpp:130
fc::variant_object get_advanced_node_parameters() const
Get advanced node parameters, such as desired and max number of connections.
Definition: api.cpp:241
An order-perserving dictionary of variant&#39;s.
const IndexType & get_index_type() const
operation_history_id_type operation_id
the account this operation applies to
T value
Definition: safe.hpp:22
fc::api< custom_operations_api > custom_operations() const
Retrieve the custom operations API.
Definition: api.cpp:305
const index_type & indices() const
Definition: api.hpp:120
network_broadcast_api(application &a)
Definition: api.cpp:151