BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
wallet_debug.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 "wallet_api_impl.hpp"
25 
26 namespace graphene { namespace wallet { namespace detail {
27 
28  void wallet_api_impl::dbg_make_uia(string creator, string symbol)
29  {
30  asset_options opts;
31  opts.flags &= (uint16_t)( ~(white_list | disable_force_settle | global_settle) );
32  opts.issuer_permissions = opts.flags;
33  opts.core_exchange_rate = price(asset(1), asset(1,asset_id_type(1)));
34  create_asset(get_account(creator).name, symbol, 2, opts, {}, true);
35  }
36 
37  void wallet_api_impl::dbg_make_mia(string creator, string symbol)
38  {
39  asset_options opts;
40  opts.flags &= (uint16_t)(~white_list);
41  opts.issuer_permissions = opts.flags;
42  opts.core_exchange_rate = price(asset(1), asset(1,asset_id_type(1)));
43  bitasset_options bopts;
44  create_asset(get_account(creator).name, symbol, 2, opts, bopts, true);
45  }
46 
47  void wallet_api_impl::dbg_push_blocks( const std::string& src_filename, uint32_t count )
48  {
49  use_debug_api();
50  (*_remote_debug)->debug_push_blocks( src_filename, count );
51  (*_remote_debug)->debug_stream_json_objects_flush();
52  }
53 
54  void wallet_api_impl::dbg_generate_blocks( const std::string& debug_wif_key, uint32_t count )
55  {
56  use_debug_api();
57  (*_remote_debug)->debug_generate_blocks( debug_wif_key, count );
58  (*_remote_debug)->debug_stream_json_objects_flush();
59  }
60 
61  void wallet_api_impl::dbg_stream_json_objects( const std::string& filename )
62  {
63  use_debug_api();
64  (*_remote_debug)->debug_stream_json_objects( filename );
65  (*_remote_debug)->debug_stream_json_objects_flush();
66  }
67 
69  {
70  use_debug_api();
71  (*_remote_debug)->debug_update_object( update );
72  (*_remote_debug)->debug_stream_json_objects_flush();
73  }
74 
76  {
77  if( _remote_debug )
78  return;
79  try
80  {
81  _remote_debug = _remote_api->debug();
82  }
83  catch( const fc::exception& e )
84  {
85  std::cerr << "\nCouldn't get debug node API. You probably are not configured\n"
86  "to access the debug API on the node you are connecting to.\n"
87  "\n"
88  "To fix this problem:\n"
89  "- Please ensure you are running debug_node, not witness_node.\n"
90  "- Please follow the instructions in README.md to set up an apiaccess file.\n"
91  "\n";
92  }
93  }
94 
95 }}} // namespace graphene::wallet::detail
graphene::wallet::detail::wallet_api_impl::create_asset
signed_transaction create_asset(string issuer, string symbol, uint8_t precision, asset_options common, fc::optional< bitasset_options > bitasset_opts, bool broadcast=false)
Definition: wallet_asset.cpp:88
fc::variant_object
An order-perserving dictionary of variant's.
Definition: variant_object.hpp:20
fc::exception
Used to generate a useful error report when an exception is thrown.
Definition: exception.hpp:56
graphene::protocol::price
The price struct stores asset prices in the BitShares system.
Definition: asset.hpp:108
graphene::protocol::asset_options::core_exchange_rate
price core_exchange_rate
Definition: asset_ops.hpp:72
graphene::wallet::detail::wallet_api_impl::dbg_stream_json_objects
void dbg_stream_json_objects(const std::string &filename)
Definition: wallet_debug.cpp:61
wallet_api_impl.hpp
graphene::protocol::asset_options
The asset_options struct contains options available on all assets in the network.
Definition: asset_ops.hpp:47
graphene::protocol::white_list
@ white_list
accounts must be whitelisted in order to hold or transact this asset
Definition: types.hpp:195
graphene::wallet::detail::wallet_api_impl::_remote_api
fc::api< login_api > _remote_api
Definition: wallet_api_impl.hpp:413
graphene::protocol::bitasset_options
The bitasset_options struct contains configurable options available only to BitAssets.
Definition: asset_ops.hpp:109
graphene::wallet::detail::wallet_api_impl::get_account
account_object get_account(account_id_type id) const
Definition: wallet_account.cpp:193
graphene::wallet::detail::wallet_api_impl::_remote_debug
optional< fc::api< graphene::debug_witness::debug_api > > _remote_debug
Definition: wallet_api_impl.hpp:419
graphene::wallet::detail::wallet_api_impl::use_debug_api
void use_debug_api()
Definition: wallet_debug.cpp:75
graphene::wallet::detail::wallet_api_impl::dbg_generate_blocks
void dbg_generate_blocks(const std::string &debug_wif_key, uint32_t count)
Definition: wallet_debug.cpp:54
graphene::protocol::disable_force_settle
@ disable_force_settle
disable force settling
Definition: types.hpp:198
graphene::wallet::detail::wallet_api_impl::dbg_make_uia
void dbg_make_uia(string creator, string symbol)
Definition: wallet_debug.cpp:28
graphene::wallet::detail::wallet_api_impl::dbg_make_mia
void dbg_make_mia(string creator, string symbol)
Definition: wallet_debug.cpp:37
graphene::protocol::asset_options::issuer_permissions
uint16_t issuer_permissions
The flags which the issuer has permission to update. See asset_issuer_permission_flags.
Definition: asset_ops.hpp:61
graphene::wallet::detail::wallet_api_impl::dbg_push_blocks
void dbg_push_blocks(const std::string &src_filename, uint32_t count)
Definition: wallet_debug.cpp:47
graphene::protocol::global_settle
@ global_settle
allow the bitasset owner to force a global settlement, permission only
Definition: types.hpp:199
fc::cerr
cerr_t & cerr
Definition: iostream.cpp:176
graphene::protocol::asset_options::flags
uint16_t flags
The currently active flags on this permission. See asset_issuer_permission_flags.
Definition: asset_ops.hpp:63
graphene::protocol::asset
Definition: asset.hpp:31
graphene::wallet::detail::wallet_api_impl::dbg_update_object
void dbg_update_object(const fc::variant_object &update)
Definition: wallet_debug.cpp:68
graphene
Definition: api.cpp:48