BitShares-Core  4.0.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 
136  {
137  struct ext
138  {
142  };
143 
145  {
147  uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION;
148  };
149 
152  account_id_type account;
153 
158 
162 
163  account_id_type fee_payer()const { return account; }
164  void validate()const;
165  share_type calculate_fee( const fee_parameters_type& k )const;
166 
167  bool is_owner_update()const
168  { return owner || extensions.value.owner_special_authority.valid(); }
169 
170  void get_required_owner_authorities( flat_set<account_id_type>& a )const
171  { if( is_owner_update() ) a.insert( account ); }
172 
173  void get_required_active_authorities( flat_set<account_id_type>& a )const
174  { if( !is_owner_update() ) a.insert( account ); }
175  };
176 
197  {
198  struct fee_parameters_type { share_type fee = 300000; };
200  no_listing = 0x0,
201  white_listed = 0x1,
202  black_listed = 0x2,
203  white_and_black_listed = white_listed | black_listed
204  };
205 
209  account_id_type authorizing_account;
211  account_id_type account_to_list;
214  uint8_t new_listing = no_listing;
216 
217  account_id_type fee_payer()const { return authorizing_account; }
218  void validate()const { FC_ASSERT( fee.amount >= 0 ); FC_ASSERT(new_listing < 0x4); }
219  };
220 
235  {
237  uint64_t membership_annual_fee = 2000 * GRAPHENE_BLOCKCHAIN_PRECISION;
238  uint64_t membership_lifetime_fee = 10000 * GRAPHENE_BLOCKCHAIN_PRECISION;
239  };
240 
243  account_id_type account_to_upgrade;
245  bool upgrade_to_lifetime_member = false;
247 
248  account_id_type fee_payer()const { return account_to_upgrade; }
249  void validate()const;
250  share_type calculate_fee( const fee_parameters_type& k )const;
251  };
252 
267  {
268  struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; };
269 
271  account_id_type account_id;
272  account_id_type new_owner;
274 
275  account_id_type fee_payer()const { return account_id; }
276  void validate()const;
277  };
278 
279 } } // graphene::protocol
280 
283  (no_listing)(white_listed)(black_listed)(white_and_black_listed))
284 
285 FC_REFLECT(graphene::protocol::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) )
288  (fee)(registrar)
289  (referrer)(referrer_percent)
290  (name)(owner)(active)(options)(extensions)
291  )
292 
293 FC_REFLECT(graphene::protocol::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority) )
296  (fee)(account)(owner)(active)(new_options)(extensions)
297  )
298 
300  (fee)(account_to_upgrade)(upgrade_to_lifetime_member)(extensions) )
301 
302 FC_REFLECT( graphene::protocol::account_whitelist_operation, (fee)(authorizing_account)(account_to_list)(new_listing)(extensions))
303 
304 FC_REFLECT( graphene::protocol::account_create_operation::fee_parameters_type, (basic_fee)(premium_fee)(price_per_kbyte) )
307 FC_REFLECT( graphene::protocol::account_upgrade_operation::fee_parameters_type, (membership_annual_fee)(membership_lifetime_fee) )
309 
311 
optional< special_authority > active_special_authority
Definition: account.hpp:141
future_extensions::flat_set_type extensions_type
Definition: base.hpp:128
account_id_type registrar
This account pays the fee. Must be a lifetime member.
Definition: account.hpp:100
void get_required_active_authorities(flat_set< account_id_type > &a) const
Definition: account.hpp:173
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:234
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:386
Definition: api.cpp:56
bool is_cheap_name(const string &n)
Definition: account.cpp:129
Update an existing account.
Definition: account.hpp:135
account_id_type account_to_upgrade
The account to upgrade; must not already be a lifetime member.
Definition: account.hpp:243
#define GRAPHENE_PROXY_TO_SELF_ACCOUNT
Represents the canonical account for specifying you will vote directly (as opposed to a proxy) ...
Definition: config.hpp:135
bool is_voting() const
Whether this account is voting.
Definition: account.hpp:62
optional< authority > active
New active authority. This can be updated by the current active authority.
Definition: account.hpp:157
optional< authority > owner
New owner authority. If set, this operation requires owner authority to execute.
Definition: account.hpp:155
optional< account_options > new_options
New account options.
Definition: account.hpp:160
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
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:209
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:73
flat_set< vote_id_type > votes
Definition: account.hpp:58
uint16_t num_committee_voted() const
Definition: account.hpp:67
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:60
void get_required_owner_authorities(flat_set< account_id_type > &a) const
Definition: account.hpp:170
This operation is used to whitelist and blacklist accounts, primarily for transacting in whitelisted ...
Definition: account.hpp:196
asset fee
Paid by authorizing_account.
Definition: account.hpp:207
account_id_type account
The account to update.
Definition: account.hpp:152
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:140
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:266
optional< special_authority > active_special_authority
Definition: account.hpp:87
account_id_type account_to_list
The account being opined about.
Definition: account.hpp:211