BitShares-Core  6.1.0
BitShares blockchain implementation and command-line interface software
account.hpp
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 #pragma once
25 
32 
33 namespace graphene { namespace protocol {
34 
35  bool is_valid_name( const string& s );
36  bool is_cheap_name( const string& n );
37 
40  {
49 
52  uint16_t num_witness = 0;
55  uint16_t num_committee = 0;
58  flat_set<vote_id_type> votes;
60 
62  inline bool is_voting() const
63  {
64  return ( voting_account != GRAPHENE_PROXY_TO_SELF_ACCOUNT || !votes.empty() );
65  }
66 
67  uint16_t num_committee_voted() const
68  {
69  if( voting_account != GRAPHENE_PROXY_TO_SELF_ACCOUNT )
70  return 0;
71  return std::count_if( votes.begin(), votes.end(),
72  [](vote_id_type v){ return v.type() == vote_id_type::vote_type::committee; } );
73  }
74 
75  void validate()const;
76  };
77 
82  {
83  struct ext
84  {
89  };
90 
92  {
93  uint64_t basic_fee = 5*GRAPHENE_BLOCKCHAIN_PRECISION;
94  uint64_t premium_fee = 2000*GRAPHENE_BLOCKCHAIN_PRECISION;
95  uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION;
96  };
97 
100  account_id_type registrar;
101 
103  account_id_type referrer;
106  uint16_t referrer_percent = 0;
107 
108  string name;
111 
114 
115  account_id_type fee_payer()const { return registrar; }
116  void validate()const;
117  share_type calculate_fee(const fee_parameters_type& )const;
118 
119  void get_required_active_authorities( flat_set<account_id_type>& a )const
120  {
121  // registrar should be required anyway as it is the fee_payer(), but we insert it here just to be sure
122  a.insert( registrar );
123  if( extensions.value.buyback_options.valid() )
124  a.insert( extensions.value.buyback_options->asset_to_buy_issuer );
125  }
126  };
127 
137  {
138  struct ext
139  {
143  };
144 
146  {
148  uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION;
149  };
150 
153  account_id_type account;
154 
159 
163 
164  account_id_type fee_payer()const { return account; }
165  void validate()const;
166  share_type calculate_fee( const fee_parameters_type& k )const;
167 
168  bool is_owner_update()const
169  { return owner || extensions.value.owner_special_authority.valid(); }
170 
171  void get_required_owner_authorities( flat_set<account_id_type>& a )const
172  { if( is_owner_update() ) a.insert( account ); }
173 
174  void get_required_active_authorities( flat_set<account_id_type>& a )const
175  { if( !is_owner_update() ) a.insert( account ); }
176  };
177 
198  {
199  struct fee_parameters_type { share_type fee = 300000; };
201  no_listing = 0x0,
202  white_listed = 0x1,
203  black_listed = 0x2,
204  white_and_black_listed = white_listed | black_listed
205  };
206 
210  account_id_type authorizing_account;
212  account_id_type account_to_list;
215  uint8_t new_listing = no_listing;
217 
218  account_id_type fee_payer()const { return authorizing_account; }
219  void validate()const { FC_ASSERT( fee.amount >= 0 ); FC_ASSERT(new_listing < 0x4); }
220  };
221 
236  {
238  uint64_t membership_annual_fee = 2000 * GRAPHENE_BLOCKCHAIN_PRECISION;
239  uint64_t membership_lifetime_fee = 10000 * GRAPHENE_BLOCKCHAIN_PRECISION;
240  };
241 
244  account_id_type account_to_upgrade;
246  bool upgrade_to_lifetime_member = false;
248 
249  account_id_type fee_payer()const { return account_to_upgrade; }
250  void validate()const;
251  share_type calculate_fee( const fee_parameters_type& k )const;
252  };
253 
268  {
269  struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; };
270 
272  account_id_type account_id;
273  account_id_type new_owner;
275 
276  account_id_type fee_payer()const { return account_id; }
277  void validate()const;
278  };
279 
280 } } // graphene::protocol
281 
284  (no_listing)(white_listed)(black_listed)(white_and_black_listed))
285 
286 FC_REFLECT(graphene::protocol::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) )
289  (fee)(registrar)
290  (referrer)(referrer_percent)
291  (name)(owner)(active)(options)(extensions)
292  )
293 
294 FC_REFLECT(graphene::protocol::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority) )
297  (fee)(account)(owner)(active)(new_options)(extensions)
298  )
299 
301  (fee)(account_to_upgrade)(upgrade_to_lifetime_member)(extensions) )
302 
303 FC_REFLECT( graphene::protocol::account_whitelist_operation, (fee)(authorizing_account)(account_to_list)(new_listing)(extensions))
304 
305 FC_REFLECT( graphene::protocol::account_create_operation::fee_parameters_type, (basic_fee)(premium_fee)(price_per_kbyte) )
308 FC_REFLECT( graphene::protocol::account_upgrade_operation::fee_parameters_type, (membership_annual_fee)(membership_lifetime_fee) )
310 
312 
optional< special_authority > active_special_authority
Definition: account.hpp:142
future_extensions::flat_set_type extensions_type
Definition: base.hpp:156
account_id_type registrar
This account pays the fee. Must be a lifetime member.
Definition: account.hpp:100
Identifies a weighted set of keys and accounts that must approve operations.
Definition: authority.hpp:34
Manage an account&#39;s membership statusThis operation is used to upgrade an account to a member...
Definition: account.hpp:235
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
Definition: api.cpp:48
bool is_cheap_name(const string &n)
Definition: account.cpp:133
Update an existing account.
Definition: account.hpp:136
account_id_type account_to_upgrade
The account to upgrade; must not already be a lifetime member.
Definition: account.hpp:244
#define GRAPHENE_PROXY_TO_SELF_ACCOUNT
Represents the canonical account for specifying you will vote directly (as opposed to a proxy) ...
Definition: config.hpp:150
optional< authority > active
New active authority. This can be updated by the current active authority.
Definition: account.hpp:158
optional< authority > owner
New owner authority. If set, this operation requires owner authority to execute.
Definition: account.hpp:156
optional< account_options > new_options
New account options.
Definition: account.hpp:161
uint16_t num_committee_voted() const
Definition: account.hpp:67
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
void get_required_active_authorities(flat_set< account_id_type > &a) const
Definition: account.hpp:174
FC_REFLECT_TYPENAME(fc::log_message)
FC_REFLECT_ENUM(graphene::net::core_message_type_enum,(trx_message_type)(block_message_type)(core_message_type_first)(item_ids_inventory_message_type)(blockchain_item_ids_inventory_message_type)(fetch_blockchain_item_ids_message_type)(fetch_items_message_type)(item_not_available_message_type)(hello_message_type)(connection_accepted_message_type)(connection_rejected_message_type)(address_request_message_type)(address_message_type)(closing_connection_message_type)(current_time_request_message_type)(current_time_reply_message_type)(check_firewall_message_type)(check_firewall_reply_message_type)(get_current_connections_request_message_type)(get_current_connections_reply_message_type)(core_message_type_last))(different_chain)(already_connected)(connected_to_self)(not_accepting_connections)(blocked)(invalid_hello_message)(client_too_old))(inbound)(outbound))(firewalled)(not_firewalled))(unable_to_connect)(connection_successful)) namespace std
account_id_type authorizing_account
The account which is specifying an opinion of another account.
Definition: account.hpp:210
These are the fields which can be updated by the active authority.
Definition: account.hpp:39
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
flat_set< vote_id_type > votes
Definition: account.hpp:58
account_id_type referrer
This account receives a portion of the fee split between registrar and referrer. Must be a member...
Definition: account.hpp:103
#define GRAPHENE_BLOCKCHAIN_PRECISION
Definition: config.hpp:29
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Definition: exception.hpp:345
An ID for some votable object.
Definition: vote.hpp:51
bool is_valid_name(const string &name)
Definition: account.cpp:64
bool is_voting() const
Whether this account is voting.
Definition: account.hpp:62
This operation is used to whitelist and blacklist accounts, primarily for transacting in whitelisted ...
Definition: account.hpp:197
asset fee
Paid by authorizing_account.
Definition: account.hpp:208
account_id_type account
The account to update.
Definition: account.hpp:153
optional< buyback_account_options > buyback_options
Definition: account.hpp:88
void get_required_active_authorities(flat_set< account_id_type > &a) const
Definition: account.hpp:119
optional< special_authority > owner_special_authority
Definition: account.hpp:141
optional< special_authority > owner_special_authority
Definition: account.hpp:86
transfers the account to another account while clearing the white listIn theory an account can be tra...
Definition: account.hpp:267
optional< special_authority > active_special_authority
Definition: account.hpp:87
account_id_type account_to_list
The account being opined about.
Definition: account.hpp:212
void get_required_owner_authorities(flat_set< account_id_type > &a) const
Definition: account.hpp:171