-
Notifications
You must be signed in to change notification settings - Fork 649
/
Copy pathdatabase_api.hpp
1619 lines (1450 loc) · 77.2 KB
/
database_api.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2017 Cryptonomex, Inc., and contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#pragma once
#include <graphene/app/api_objects.hpp>
#include <graphene/protocol/types.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/balance_object.hpp>
#include <graphene/chain/chain_property_object.hpp>
#include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/credit_offer_object.hpp>
#include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/samet_fund_object.hpp>
#include <graphene/chain/ticket_object.hpp>
#include <graphene/chain/worker_object.hpp>
#include <graphene/chain/witness_object.hpp>
#include <fc/api.hpp>
#include <fc/variant_object.hpp>
#include <boost/container/flat_set.hpp>
#include <functional>
#include <map>
#include <memory>
#include <vector>
namespace graphene { namespace app {
using namespace graphene::chain;
using namespace graphene::market_history;
using std::string;
using std::vector;
using std::map;
class database_api_impl;
/**
* @brief 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 @ref network_broadcast_api.
*/
class database_api
{
public:
database_api(graphene::chain::database& db, const application_options* app_options = nullptr );
~database_api();
/////////////
// Objects //
/////////////
/**
* @brief Get the objects corresponding to the provided IDs
* @param ids IDs of the objects to retrieve
* @param subscribe @a true to subscribe to the queried objects, @a false to not subscribe,
* @a null to subscribe or not subscribe according to current auto-subscription setting
* (see @ref set_auto_subscription)
* @return The objects retrieved, in the order they are mentioned in ids
* @note operation_history_object (1.11.x) and account_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.
*/
fc::variants get_objects( const vector<object_id_type>& ids,
optional<bool> subscribe = optional<bool>() )const;
///////////////////
// Subscriptions //
///////////////////
/**
* @brief Register a callback handle which then can be used to subscribe to object database changes
* @param cb The callback handle to register
* @param 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.
*
* Note: auto-subscription is enabled by default and can be disabled with @ref set_auto_subscription API.
*/
void set_subscribe_callback( std::function<void(const variant&)> cb, bool notify_remove_create );
/**
* @brief Set auto-subscription behavior of follow-up API queries
* @param enable whether 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
* - get_liquidity_pools
* - get_liquidity_pools_by_share_asset
*
* Note: auto-subscription is enabled by default
*
* @see @ref set_subscribe_callback
*/
void set_auto_subscription( bool enable );
/**
* @brief Register a callback handle which will get notified when a transaction is pushed to database
* @param cb The 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.
*/
void set_pending_transaction_callback( std::function<void(const variant& signed_transaction_object)> cb );
/**
* @brief Register a callback handle which will get notified when a block is pushed to database
* @param cb The callback handle to register
*/
void set_block_applied_callback( std::function<void(const variant& block_id)> cb );
/**
* @brief Stop receiving any notifications
*
* This unsubscribes from all subscribed markets and objects.
*/
void cancel_all_subscriptions();
/////////////////////////////
// Blocks and transactions //
/////////////////////////////
/**
* @brief Retrieve a block header
* @param block_num Height of the block whose header should be returned
* @param with_witness_signature Whether to return witness signature. Optional.
* If omitted or is @a false, will not return witness signature.
* @return header of the referenced block, or null if no matching block was found
*/
optional<maybe_signed_block_header> get_block_header(
uint32_t block_num,
const optional<bool>& with_witness_signature = optional<bool>() )const;
/**
* @brief Retrieve multiple block headers by block numbers
* @param block_nums vector containing heights of the blocks whose headers should be returned
* @param with_witness_signatures Whether to return witness signatures. Optional.
* If omitted or is @a false, will not return witness signatures.
* @return array of headers of the referenced blocks, or null if no matching block was found
*/
map<uint32_t, optional<maybe_signed_block_header>> get_block_header_batch(
const vector<uint32_t>& block_nums,
const optional<bool>& with_witness_signatures = optional<bool>() )const;
/**
* @brief Retrieve a full, signed block
* @param block_num Height of the block to be returned
* @return the referenced block, or null if no matching block was found
*/
optional<signed_block> get_block(uint32_t block_num)const;
/**
* @brief used to fetch an individual transaction.
* @param block_num height of the block to fetch
* @param trx_in_block the index (sequence number) of the transaction in the block, starts from 0
* @return the transaction at the given position
*/
processed_transaction get_transaction( uint32_t block_num, uint32_t trx_in_block )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.
*
* @param txid hash of the transaction
* @return the corresponding transaction if found, or null if not found
*/
optional<signed_transaction> get_recent_transaction_by_id( const transaction_id_type& txid )const;
/////////////
// Globals //
/////////////
/**
* @brief Retrieve the @ref graphene::chain::chain_property_object associated with the chain
*/
chain_property_object get_chain_properties()const;
/**
* @brief Retrieve the current @ref graphene::chain::global_property_object
*/
global_property_object get_global_properties()const;
/**
* @brief Retrieve compile-time constants
*/
fc::variant_object get_config()const;
/**
* @brief Get the chain ID
*/
chain_id_type get_chain_id()const;
/**
* @brief Retrieve the current @ref graphene::chain::dynamic_global_property_object
*/
dynamic_global_property_object get_dynamic_global_properties()const;
/**
* @brief Get the next object ID in an object space
* @param space_id The space ID
* @param type_id The type ID
* @param with_pending_transactions Whether to include pending transactions
* @return The next object ID to be assigned
* @throw fc::exception If the object space does not exist, or @p with_pending_transactions is @a false but
* the api_helper_indexes plugin is not enabled
*/
object_id_type get_next_object_id( uint8_t space_id, uint8_t type_id, bool with_pending_transactions )const;
//////////
// Keys //
//////////
/**
* @brief Get all accounts that refer to the specified public keys in their owner authority, active authorities
* or memo key
* @param keys a list of public keys to query,
* the quantity should not be greater than the configured value of
* @a api_limit_get_key_references
* @return ID of all accounts that refer to the specified keys
*/
vector<flat_set<account_id_type>> get_key_references( vector<public_key_type> keys )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
* @param public_key Public key
* @return Whether a public key is known
*/
bool is_public_key_registered(string public_key) const;
//////////////
// Accounts //
//////////////
/**
* @brief Get account object from a name or ID
* @param name_or_id name or ID of the account
* @return Account ID
*
*/
account_id_type get_account_id_from_string(const std::string& name_or_id) const;
/**
* @brief Get a list of accounts by names or IDs
* @param account_names_or_ids names or IDs of the accounts to retrieve
* @param subscribe @a true to subscribe to the queried account objects, @a false to not subscribe,
* @a null to subscribe or not subscribe according to current auto-subscription setting
* (see @ref set_auto_subscription)
* @return The accounts corresponding to the provided names or IDs
*
* This function has semantics identical to @ref get_objects
*/
vector<optional<account_object>> get_accounts( const vector<std::string>& account_names_or_ids,
optional<bool> subscribe = optional<bool>() )const;
/**
* @brief Fetch objects relevant to the specified accounts and optionally subscribe to updates
* @param names_or_ids Each item must be the name or ID of an account to retrieve,
* the quantity should not be greater than the configured value of
* @a api_limit_get_full_accounts
* @param subscribe @a true to subscribe to the queried full account objects, @a false to not subscribe,
* @a null to subscribe or not subscribe according to current auto-subscription setting
* (see @ref set_auto_subscription)
* @return Map of string from @p names_or_ids to the corresponding account
*
* This function fetches relevant objects for the given accounts, and subscribes to updates to the given
* accounts. If any of the strings in @p names_or_ids cannot be tied to an account, that input will be
* ignored. Other accounts will be retrieved and subscribed.
* @note The maximum number of accounts allowed to subscribe per connection is configured by the
* @a api_limit_get_full_accounts_subscribe option. Exceeded subscriptions will be ignored.
* @note For each object type, the maximum number of objects to return is configured by the
* @a api_limit_get_full_accounts_lists option. Exceeded objects need to be queried with other APIs.
*
*/
map<string, full_account, std::less<>> get_full_accounts(
const vector<string>& names_or_ids,
const optional<bool>& subscribe = optional<bool>() )const;
/**
* @brief Returns vector of voting power sorted by reverse vp_active
* @param limit Maximum number of accounts to retrieve, must not exceed the configured value of
* @a api_limit_get_top_voters
* @return Desc Sorted voting power vector
*/
vector<account_statistics_object> get_top_voters(uint32_t limit)const;
/**
* @brief Get info of an account by name
* @param name Name of the account to retrieve
* @return The account holding the provided name
*/
optional<account_object> get_account_by_name( string name )const;
/**
* @brief Get all accounts that refer to the specified account in their owner or active authorities
* @param account_name_or_id Account name or ID to query
* @return all accounts that refer to the specified account in their owner or active authorities
*/
vector<account_id_type> get_account_references( const std::string account_name_or_id )const;
/**
* @brief Get a list of accounts by name
* @param account_names Names of the accounts to retrieve
* @return The accounts holding the provided names
*
* This function has semantics identical to @ref get_objects, but doesn't subscribe.
*/
vector<optional<account_object>> lookup_account_names(const vector<string>& account_names)const;
/**
* @brief Get names and IDs for registered accounts
* @param lower_bound_name Lower bound of the first name to return
* @param limit Maximum number of results to return, must not exceed the configured value of
* @a api_limit_lookup_accounts
* @param subscribe @a true to subscribe to the queried account objects, @a false to not subscribe,
* @a null to subscribe or not subscribe according to current auto-subscription setting
* (see @ref set_auto_subscription)
* @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 @p limit is 1.
*/
map<string, account_id_type, std::less<>> lookup_accounts( const string& lower_bound_name,
uint32_t limit,
const optional<bool>& subscribe = optional<bool>() )const;
//////////////
// Balances //
//////////////
/**
* @brief Get an account's balances in various assets
* @param account_name_or_id name or ID of the account to get balances for
* @param assets IDs of the assets to get balances of; if empty, get all assets account has a balance in
* @return Balances of the account
*/
vector<asset> get_account_balances( const std::string& account_name_or_id,
const flat_set<asset_id_type>& assets )const;
/// Semantically equivalent to @ref get_account_balances.
vector<asset> get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets)const;
/**
* @brief Return all unclaimed balance objects for a list of addresses
* @param addrs a list of addresses
* @return all unclaimed balance objects for the addresses
*/
vector<balance_object> get_balance_objects( const vector<address>& addrs )const;
/**
* @brief Calculate how much assets in the given balance objects are able to be claimed at current head
* block time
* @param objs a list of balance object IDs
* @return a list indicating how much asset in each balance object is available to be claimed
*/
vector<asset> get_vested_balances( const vector<balance_id_type>& objs )const;
/**
* @brief Return all vesting balance objects owned by an account
* @param account_name_or_id name or ID of an account
* @return all vesting balance objects owned by the account
*/
vector<vesting_balance_object> get_vesting_balances( const std::string account_name_or_id )const;
/**
* @brief Get the total number of accounts registered with the blockchain
*/
uint64_t get_account_count()const;
////////////
// Assets //
////////////
/**
* @brief Get asset ID from an asset symbol or ID
* @param symbol_or_id symbol name or ID of the asset
* @return asset ID
*/
asset_id_type get_asset_id_from_string(const std::string& symbol_or_id) const;
/**
* @brief Get a list of assets by symbol names or IDs
* @param asset_symbols_or_ids symbol names or IDs of the assets to retrieve
* @param subscribe @a true to subscribe to the queried asset objects, @a false to not subscribe,
* @a null to subscribe or not subscribe according to current auto-subscription setting
* (see @ref set_auto_subscription)
* @return The assets corresponding to the provided symbol names or IDs
*
* This function has semantics identical to @ref get_objects
*/
vector<optional<extended_asset_object>> get_assets( const vector<std::string>& asset_symbols_or_ids,
optional<bool> subscribe = optional<bool>() )const;
/**
* @brief Get assets alphabetically by symbol name
* @param lower_bound_symbol Lower bound of symbol names to retrieve
* @param limit Maximum number of assets to fetch, must not exceed the configured value of
* @a api_limit_get_assets
* @return The assets found
*/
vector<extended_asset_object> list_assets(const string& lower_bound_symbol, uint32_t limit)const;
/**
* @brief Get a list of assets by symbol names or IDs
* @param symbols_or_ids symbol names or IDs of the assets to retrieve
* @return The assets corresponding to the provided symbols or IDs
*
* This function has semantics identical to @ref get_objects, but doesn't subscribe
*/
vector<optional<extended_asset_object>> lookup_asset_symbols(const vector<string>& symbols_or_ids)const;
/**
* @brief Get assets count
* @return The assets count
*/
uint64_t get_asset_count()const;
/**
* @brief Get assets issued (owned) by a given account
* @param issuer_name_or_id Account name or ID to get objects from
* @param start Asset objects(1.3.X) before this ID will be skipped in results. Pagination purposes.
* @param limit Maximum number of assets to retrieve, must not exceed the configured value of
* @a api_limit_get_assets
* @return The assets issued (owned) by the account
*/
vector<extended_asset_object> get_assets_by_issuer(const std::string& issuer_name_or_id,
asset_id_type start, uint32_t limit)const;
/////////////////////
// Markets / feeds //
/////////////////////
/**
* @brief Get limit orders in a given market
* @param a symbol or ID of asset being sold
* @param b symbol or ID of asset being purchased
* @param limit Maximum number of orders to retrieve, must not exceed the configured value of
* @a api_limit_get_limit_orders
* @return The limit orders, ordered from least price to greatest
*/
vector<limit_order_object> get_limit_orders(std::string a, std::string b, uint32_t limit)const;
/**
* @brief Fetch open limit orders in all markets relevant to the specified account, ordered by ID
*
* @param account_name_or_id The name or ID of an account to retrieve
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_limit_orders_by_account
* @param start_id Start order id, fetch orders whose IDs are greater than or equal to this order
*
* @return List of limit orders of the specified account
*
* @note
* 1. If @p account_name_or_id cannot be tied to an account, an error will be returned
* 2. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_limit_orders_by_account will be used
* 3. @p start_id can be omitted or be null, if so the api will return the "first page" of orders
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<limit_order_object> get_limit_orders_by_account(
const string& account_name_or_id,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<limit_order_id_type>& start_id = optional<limit_order_id_type>() );
/**
* @brief Fetch all orders relevant to the specified account and specified market, result orders
* are sorted descendingly by price
*
* @param account_name_or_id The name or ID of an account to retrieve
* @param base Base asset
* @param quote Quote asset
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_account_limit_orders
* @param 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
* @param ostart_price Fetch orders with price lower than or equal to this price
*
* @return List of orders from @p account_name_or_id to the corresponding account
*
* @note
* 1. If @p account_name_or_id cannot be tied to an account, an error will be returned
* 2. @p ostart_id and @p ostart_price can be empty, if so the api will return the "first page" of orders;
* if @p ostart_id is specified, its price will be used to do page query preferentially,
* otherwise the @p ostart_price will be used;
* @p ostart_id and @p ostart_price may be used cooperatively in case of the order specified by @p ostart_id
* was just canceled accidentally, in such case, the result orders' price may lower or equal to
* @p ostart_price, but orders' id greater than @p ostart_id
*/
vector<limit_order_object> get_account_limit_orders( const string& account_name_or_id,
const string &base,
const string "e,
uint32_t limit = application_options::get_default().api_limit_get_account_limit_orders,
optional<limit_order_id_type> ostart_id = optional<limit_order_id_type>(),
optional<price> ostart_price = optional<price>());
/**
* @brief Get call orders (aka margin positions) for a given asset
* @param a symbol name or ID of the debt asset
* @param limit Maximum number of orders to retrieve, must not exceed the configured value of
* @a api_limit_get_call_orders
* @return The call orders, ordered from earliest to be called to latest
*/
vector<call_order_object> get_call_orders(const std::string& a, uint32_t limit)const;
/**
* @brief Get call orders (aka margin positions) of a given account
* @param account_name_or_id Account name or ID to get objects from
* @param start Asset objects(1.3.X) before this ID will be skipped in results. Pagination purposes.
* @param limit Maximum number of orders to retrieve, must not exceed the configured value of
* @a api_limit_get_call_orders
* @return The call orders of the account
*/
vector<call_order_object> get_call_orders_by_account(const std::string& account_name_or_id,
asset_id_type start, uint32_t limit)const;
/**
* @brief Get forced settlement orders in a given asset
* @param a Symbol or ID of asset being settled
* @param limit Maximum number of orders to retrieve, must not exceed the configured value of
* @a api_limit_get_settle_orders
* @return The settle orders, ordered from earliest settlement date to latest
*/
vector<force_settlement_object> get_settle_orders(const std::string& a, uint32_t limit)const;
/**
* @brief Get forced settlement orders of a given account
* @param account_name_or_id Account name or ID to get objects from
* @param start Force settlement objects(1.4.X) before this ID will be skipped in results. Pagination purposes.
* @param limit Maximum number of orders to retrieve, must not exceed the configured value of
* @a api_limit_get_settle_orders
* @return The settle orders, ordered from earliest settlement date to latest
* @return The settle orders of the account
*/
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;
/**
* @brief Get collateral_bid_objects for a given asset
* @param a Symbol or ID of asset
* @param limit Maximum number of objects to retrieve, must not exceed the configured value of
* @a api_limit_get_collateral_bids
* @param start skip that many results
* @return The settle orders, ordered from earliest settlement date to latest
*/
vector<collateral_bid_object> get_collateral_bids(const std::string& a, uint32_t limit, uint32_t start)const;
/**
* @brief Get open margin positions of a given account
* @param account_name_or_id name or ID of an account
* @return open margin positions of the account
*
* Similar to @ref get_call_orders_by_account, but only the first page will be returned, the page size is
* the configured value of @a api_limit_get_call_orders.
*/
vector<call_order_object> get_margin_positions( const std::string& account_name_or_id )const;
/**
* @brief Request notification when the active orders in the market between two assets changes
* @param callback Callback method which is called when the market changes
* @param a symbol name or ID of the first asset
* @param b symbol 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.
*/
void subscribe_to_market(std::function<void(const variant&)> callback,
const std::string& a, const std::string& b);
/**
* @brief Unsubscribe from updates to a given market
* @param a symbol name or ID of the first asset
* @param b symbol name or ID of the second asset
*/
void unsubscribe_from_market( const std::string& a, const std::string& b );
/**
* @brief Returns the ticker for the market assetA:assetB
* @param base symbol name or ID of the base asset
* @param quote symbol name or ID of the quote asset
* @return The market ticker for the past 24 hours.
*/
market_ticker get_ticker( const string& base, const string& quote )const;
/**
* @brief Returns the 24 hour volume for the market assetA:assetB
* @param base symbol name or ID of the base asset
* @param quote symbol name or ID of the quote asset
* @return The market volume over the past 24 hours
*/
market_volume get_24_volume( const string& base, const string& quote )const;
/**
* @brief Returns the order book for the market base:quote
* @param base symbol name or ID of the base asset
* @param quote symbol name or ID of the quote asset
* @param limit depth of the order book to retrieve, for bids and asks each, capped at the configured value of
* @a api_limit_get_order_book and @a api_limit_get_limit_orders
* @return Order book of the market
*/
order_book get_order_book( const string& base, const string& quote,
uint32_t limit = application_options::get_default().api_limit_get_order_book )const;
/**
* @brief Returns vector of tickers sorted by reverse base_volume
* @note this API is experimental and subject to change in next releases
* @param limit Max number of results, must not exceed the configured value of
* @a api_limit_get_top_markets
* @return Desc Sorted ticker vector
*/
vector<market_ticker> get_top_markets(uint32_t limit)const;
/**
* @brief Get market transactions occurred in the market base:quote, ordered by time, most recent first.
* @param base symbol or ID of the base asset
* @param quote symbol or ID of the quote asset
* @param start Start time as a UNIX timestamp, the latest transactions to retrieve
* @param stop Stop time as a UNIX timestamp, the earliest transactions to retrieve
* @param limit Maximum quantity of transactions to retrieve, capped at the configured value of
* @a api_limit_get_trade_history
* @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 transactions than @p limit occurred in the same second,
* this API only returns the most recent records, the rest records can be retrieved
* with the @ref get_trade_history_by_sequence API.
*/
vector<market_trade> get_trade_history( const string& base, const string& quote,
fc::time_point_sec start, fc::time_point_sec stop,
uint32_t limit = application_options::get_default().api_limit_get_trade_history )const;
/**
* @brief Get market transactions occurred in the market base:quote, ordered by time, most recent first.
* @param base symbol or ID of the base asset
* @param quote symbol or ID of the quote asset
* @param start Start sequence as an Integer, the latest transaction to retrieve
* @param stop Stop time as a UNIX timestamp, the earliest transactions to retrieve
* @param limit Maximum quantity of transactions to retrieve, capped at the configured value of
* @a api_limit_get_trade_history_by_sequence
* @return Transactions in the market
* @note The time must be UTC, timezone offsets are not supported. The range is [stop, start].
*/
vector<market_trade> get_trade_history_by_sequence( const string& base, const string& quote,
int64_t start, fc::time_point_sec stop,
uint32_t limit = application_options::get_default().api_limit_get_trade_history_by_sequence )const;
/////////////////////
// Liquidity pools //
/////////////////////
/**
* @brief Get a list of liquidity pools
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_liquidity_pools
* @param start_id Start liquidity pool id, fetch pools whose IDs are greater than or equal to this ID
* @param with_statistics Whether to return statistics
* @return The liquidity pools
*
* @note
* 1. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_liquidity_pools will be used
* 2. @p start_id can be omitted or be @a null, if so the api will return the "first page" of pools
* 3. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<extended_liquidity_pool_object> list_liquidity_pools(
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<liquidity_pool_id_type>& start_id = optional<liquidity_pool_id_type>(),
const optional<bool>& with_statistics = false )const;
/**
* @brief Get a list of liquidity pools by the symbol or ID of the first asset in the pool
* @param asset_symbol_or_id symbol name or ID of the asset
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_liquidity_pools
* @param start_id Start liquidity pool id, fetch pools whose IDs are greater than or equal to this ID
* @param with_statistics Whether to return statistics
* @return The liquidity pools
*
* @note
* 1. If @p asset_symbol_or_id cannot be tied to an asset, an error will be returned
* 2. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_liquidity_pools will be used
* 3. @p start_id can be omitted or be @a null, if so the api will return the "first page" of pools
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<extended_liquidity_pool_object> get_liquidity_pools_by_asset_a(
const std::string& asset_symbol_or_id,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<liquidity_pool_id_type>& start_id = optional<liquidity_pool_id_type>(),
const optional<bool>& with_statistics = false )const;
/**
* @brief Get a list of liquidity pools by the symbol or ID of the second asset in the pool
* @param asset_symbol_or_id symbol name or ID of the asset
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_liquidity_pools
* @param start_id Start liquidity pool id, fetch pools whose IDs are greater than or equal to this ID
* @param with_statistics Whether to return statistics
* @return The liquidity pools
*
* @note
* 1. If @p asset_symbol_or_id cannot be tied to an asset, an error will be returned
* 2. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_liquidity_pools will be used
* 3. @p start_id can be omitted or be @a null, if so the api will return the "first page" of pools
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<extended_liquidity_pool_object> get_liquidity_pools_by_asset_b(
const std::string& asset_symbol_or_id,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<liquidity_pool_id_type>& start_id = optional<liquidity_pool_id_type>(),
const optional<bool>& with_statistics = false )const;
/**
* @brief Get a list of liquidity pools by the symbol or ID of one asset in the pool
* @param asset_symbol_or_id symbol name or ID of the asset
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_liquidity_pools
* @param start_id Start liquidity pool id, fetch pools whose IDs are greater than or equal to this ID
* @param with_statistics Whether to return statistics
* @return The liquidity pools
*
* @note
* 1. If @p asset_symbol_or_id cannot be tied to an asset, an error will be returned
* 2. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_liquidity_pools will be used
* 3. @p start_id can be omitted or be @a null, if so the api will return the "first page" of pools
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<extended_liquidity_pool_object> get_liquidity_pools_by_one_asset(
const std::string& asset_symbol_or_id,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<liquidity_pool_id_type>& start_id = optional<liquidity_pool_id_type>(),
const optional<bool>& with_statistics = false )const;
/**
* @brief Get a list of liquidity pools by the symbols or IDs of the two assets in the pool
* @param asset_symbol_or_id_a symbol name or ID of one asset
* @param asset_symbol_or_id_b symbol name or ID of the other asset
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_liquidity_pools
* @param start_id Start liquidity pool id, fetch pools whose IDs are greater than or equal to this ID
* @param with_statistics Whether to return statistics
* @return The liquidity pools
*
* @note
* 1. If @p asset_symbol_or_id_a or @p asset_symbol_or_id_b cannot be tied to an asset,
* an error will be returned
* 2. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_liquidity_pools will be used
* 3. @p start_id can be omitted or be @a null, if so the api will return the "first page" of pools
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<extended_liquidity_pool_object> get_liquidity_pools_by_both_assets(
const std::string& asset_symbol_or_id_a,
const std::string& asset_symbol_or_id_b,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<liquidity_pool_id_type>& start_id = optional<liquidity_pool_id_type>(),
const optional<bool>& with_statistics = false )const;
/**
* @brief Get a list of liquidity pools by their IDs
* @param ids IDs of the liquidity pools,
* the quantity should not be greater than the configured value of
* @a api_limit_get_liquidity_pools
* @param subscribe @a true to subscribe to the queried objects, @a false to not subscribe,
* @a null to subscribe or not subscribe according to current auto-subscription setting
* (see @ref set_auto_subscription)
* @param with_statistics Whether to return statistics
* @return The liquidity pools
*
* @note if an ID in the list can not be found,
* the corresponding data in the returned list is null.
*/
vector<optional<extended_liquidity_pool_object>> get_liquidity_pools(
const vector<liquidity_pool_id_type>& ids,
const optional<bool>& subscribe = optional<bool>(),
const optional<bool>& with_statistics = false )const;
/**
* @brief Get a list of liquidity pools by their share asset symbols or IDs
* @param asset_symbols_or_ids symbol names or IDs of the share assets,
* the quantity should not be greater than the configured value of
* @a api_limit_get_liquidity_pools
* @param subscribe @a true to subscribe to the queried objects, @a false to not subscribe,
* @a null to subscribe or not subscribe according to current auto-subscription setting
* (see @ref set_auto_subscription)
* @param with_statistics Whether to return statistics
* @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.
*/
vector<optional<extended_liquidity_pool_object>> get_liquidity_pools_by_share_asset(
const vector<std::string>& asset_symbols_or_ids,
const optional<bool>& subscribe = optional<bool>(),
const optional<bool>& with_statistics = false )const;
/**
* @brief Get a list of liquidity pools by the name or ID of the owner account
* @param account_name_or_id name or ID of the owner account
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_liquidity_pools
* @param start_id Start share asset id, fetch pools whose share asset IDs are greater than or equal to this ID
* @param with_statistics Whether to return statistics
* @return The liquidity pools
*
* @note
* 1. If @p account_name_or_id cannot be tied to an account, an error will be returned
* 2. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_liquidity_pools will be used
* 3. @p start_id can be omitted or be @a null, if so the api will return the "first page" of pools
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<extended_liquidity_pool_object> get_liquidity_pools_by_owner(
const std::string& account_name_or_id,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<asset_id_type>& start_id = optional<asset_id_type>(),
const optional<bool>& with_statistics = false )const;
/////////////////////
/// SameT Funds
/// @{
/**
* @brief Get a list of SameT Funds
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_samet_funds
* @param start_id Start SameT Fund id, fetch items whose IDs are greater than or equal to this ID
* @return The SameT Funds
*
* @note
* 1. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_samet_funds will be used
* 2. @p start_id can be omitted or be @a null, if so the api will return the "first page" of data
* 3. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<samet_fund_object> list_samet_funds(
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<samet_fund_id_type>& start_id = optional<samet_fund_id_type>() )const;
/**
* @brief Get a list of SameT Funds by the name or ID of the owner account
* @param account_name_or_id name or ID of the owner account
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_samet_funds
* @param start_id Start SameT Fund id, fetch items whose IDs are greater than or equal to this ID
* @return The SameT Funds
*
* @note
* 1. If @p account_name_or_id cannot be tied to an account, an error will be returned
* 2. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_samet_funds will be used
* 3. @p start_id can be omitted or be @a null, if so the api will return the "first page" of data
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<samet_fund_object> get_samet_funds_by_owner(
const std::string& account_name_or_id,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<samet_fund_id_type>& start_id = optional<samet_fund_id_type>() )const;
/**
* @brief Get a list of SameT Funds by the symbol or ID of the asset type
* @param asset_symbol_or_id symbol or ID of the asset type
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_samet_funds
* @param start_id Start SameT Fund id, fetch items whose IDs are greater than or equal to this ID
* @return The SameT Funds
*
* @note
* 1. If @p asset_symbol_or_id cannot be tied to an asset, an error will be returned
* 2. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_samet_funds will be used
* 3. @p start_id can be omitted or be @a null, if so the api will return the "first page" of data
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<samet_fund_object> get_samet_funds_by_asset(
const std::string& asset_symbol_or_id,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<samet_fund_id_type>& start_id = optional<samet_fund_id_type>() )const;
/// @}
////////////////////////////////////
/// Credit offers and credit deals
/// @{
/**
* @brief Get a list of credit offers
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_credit_offers
* @param start_id Start credit offer id, fetch items whose IDs are greater than or equal to this ID
* @return The credit offers
*
* @note
* 1. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_credit_offers will be used
* 2. @p start_id can be omitted or be @a null, if so the api will return the "first page" of data
* 3. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<credit_offer_object> list_credit_offers(
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<credit_offer_id_type>& start_id = optional<credit_offer_id_type>() )const;
/**
* @brief Get a list of credit offers by the name or ID of the owner account
* @param account_name_or_id name or ID of the owner account
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_credit_offers
* @param start_id Start credit offer id, fetch items whose IDs are greater than or equal to this ID
* @return The credit offers
*
* @note
* 1. If @p account_name_or_id cannot be tied to an account, an error will be returned
* 2. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_credit_offers will be used
* 3. @p start_id can be omitted or be @a null, if so the api will return the "first page" of data
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<credit_offer_object> get_credit_offers_by_owner(
const std::string& account_name_or_id,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<credit_offer_id_type>& start_id = optional<credit_offer_id_type>() )const;
/**
* @brief Get a list of credit offers by the symbol or ID of the asset type
* @param asset_symbol_or_id symbol or ID of the asset type
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_credit_offers
* @param start_id Start credit offer id, fetch items whose IDs are greater than or equal to this ID
* @return The credit offers
*
* @note
* 1. If @p asset_symbol_or_id cannot be tied to an asset, an error will be returned
* 2. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_credit_offers will be used
* 3. @p start_id can be omitted or be @a null, if so the api will return the "first page" of data
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<credit_offer_object> get_credit_offers_by_asset(
const std::string& asset_symbol_or_id,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<credit_offer_id_type>& start_id = optional<credit_offer_id_type>() )const;
/**
* @brief Get a list of credit deals
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_credit_offers
* @param start_id Start credit deal id, fetch items whose IDs are greater than or equal to this ID
* @return The credit deals
*
* @note