BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet 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  {
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 
91  struct fee_params_t
92  {
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_params_t& )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  {
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_params_t& 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_params_t { share_type fee = 300000; };
201  no_listing = 0x0,
202  white_listed = 0x1,
203  black_listed = 0x2,
205  };
206 
210  account_id_type authorizing_account;
212  account_id_type account_to_list;
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  {
237  struct fee_params_t {
240  };
241 
244  account_id_type account_to_upgrade;
248 
249  account_id_type fee_payer()const { return account_to_upgrade; }
250  void validate()const;
251  share_type calculate_fee( const fee_params_t& k )const;
252  };
253 
268  {
269  struct fee_params_t { 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 
282 FC_REFLECT(graphene::protocol::account_options, (memo_key)(voting_account)(num_witness)(num_committee)(votes)(extensions))
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_params_t, (basic_fee)(premium_fee)(price_per_kbyte) )
308 FC_REFLECT( graphene::protocol::account_upgrade_operation::fee_params_t, (membership_annual_fee)(membership_lifetime_fee) )
310 
311 FC_REFLECT( graphene::protocol::account_transfer_operation, (fee)(account_id)(new_owner)(extensions) )
312 
graphene::protocol::extension
Definition: ext.hpp:36
graphene::protocol::account_whitelist_operation::authorizing_account
account_id_type authorizing_account
The account which is specifying an opinion of another account.
Definition: account.hpp:210
graphene::protocol::account_update_operation::ext::owner_special_authority
optional< special_authority > owner_special_authority
Definition: account.hpp:141
graphene::protocol::account_whitelist_operation::fee
asset fee
Paid by authorizing_account.
Definition: account.hpp:208
graphene::protocol::account_create_operation::fee
asset fee
Definition: account.hpp:98
graphene::protocol::account_options::num_committee
uint16_t num_committee
Definition: account.hpp:55
GRAPHENE_PROXY_TO_SELF_ACCOUNT
#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
special_authority.hpp
graphene::protocol::account_update_operation::active
optional< authority > active
New active authority. This can be updated by the current active authority.
Definition: account.hpp:158
FC_REFLECT_TYPENAME
FC_REFLECT_TYPENAME(fc::log_message)
graphene::protocol::account_create_operation::ext::owner_special_authority
optional< special_authority > owner_special_authority
Definition: account.hpp:86
graphene::protocol::account_create_operation::fee_params_t::premium_fee
uint64_t premium_fee
the cost to register the cheapest non-free account
Definition: account.hpp:94
graphene::protocol::account_update_operation::fee_params_t::price_per_kbyte
uint32_t price_per_kbyte
Definition: account.hpp:148
graphene::protocol::account_upgrade_operation::calculate_fee
share_type calculate_fee(const fee_params_t &k) const
Definition: account.cpp:263
graphene::protocol::account_update_operation::fee_params_t
Definition: account.hpp:145
graphene::protocol::account_options::voting_account
account_id_type voting_account
Definition: account.hpp:48
graphene::protocol::account_create_operation::fee_params_t::basic_fee
uint64_t basic_fee
the cost to register the cheapest non-free account
Definition: account.hpp:93
graphene::protocol::account_create_operation::fee_params_t::price_per_kbyte
uint32_t price_per_kbyte
Definition: account.hpp:95
graphene::protocol::account_create_operation::validate
void validate() const
Definition: account.cpp:187
graphene::protocol::account_create_operation::extensions
extension< ext > extensions
Definition: account.hpp:113
graphene::protocol::account_create_operation::active
authority active
Definition: account.hpp:110
graphene::protocol::account_options
These are the fields which can be updated by the active authority.
Definition: account.hpp:39
graphene::protocol::account_whitelist_operation::black_listed
@ black_listed
This account is blacklisted, but not whitelisted.
Definition: account.hpp:203
graphene::protocol::account_create_operation::get_required_active_authorities
void get_required_active_authorities(flat_set< account_id_type > &a) const
Definition: account.hpp:119
graphene::protocol::account_create_operation::registrar
account_id_type registrar
This account pays the fee. Must be a lifetime member.
Definition: account.hpp:100
graphene::protocol::vote_id_type
An ID for some votable object.
Definition: vote.hpp:51
graphene::protocol::account_transfer_operation
transfers the account to another account while clearing the white list
Definition: account.hpp:267
graphene::protocol::public_key_type
Definition: types.hpp:312
graphene::protocol::base_operation
Definition: base.hpp:124
graphene::protocol::account_update_operation::fee_payer
account_id_type fee_payer() const
Definition: account.hpp:164
graphene::protocol::account_upgrade_operation::fee_payer
account_id_type fee_payer() const
Definition: account.hpp:249
graphene::protocol::account_upgrade_operation::fee_params_t
Definition: account.hpp:237
graphene::protocol::account_update_operation
Update an existing account.
Definition: account.hpp:136
graphene::protocol::account_update_operation::validate
void validate() const
Definition: account.cpp:226
graphene::protocol::account_create_operation::referrer
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
graphene::protocol::account_update_operation::owner
optional< authority > owner
New owner authority. If set, this operation requires owner authority to execute.
Definition: account.hpp:156
graphene::protocol::account_update_operation::get_required_active_authorities
void get_required_active_authorities(flat_set< account_id_type > &a) const
Definition: account.hpp:174
graphene::protocol::account_update_operation::ext
Definition: account.hpp:138
graphene::protocol::account_whitelist_operation::white_listed
@ white_listed
This account is whitelisted, but not blacklisted.
Definition: account.hpp:202
graphene::protocol::account_whitelist_operation::fee_params_t::fee
share_type fee
Definition: account.hpp:199
graphene::protocol::account_whitelist_operation::account_to_list
account_id_type account_to_list
The account being opined about.
Definition: account.hpp:212
graphene::protocol::account_upgrade_operation::validate
void validate() const
Definition: account.cpp:270
GRAPHENE_BLOCKCHAIN_PRECISION
#define GRAPHENE_BLOCKCHAIN_PRECISION
Definition: config.hpp:29
graphene::protocol::account_transfer_operation::fee_params_t::fee
uint64_t fee
Definition: account.hpp:269
graphene::protocol::account_create_operation::name
string name
Definition: account.hpp:108
graphene::protocol::account_create_operation
Definition: account.hpp:81
graphene::protocol::account_upgrade_operation::extensions
extensions_type extensions
Definition: account.hpp:247
graphene::protocol::account_options::num_committee_voted
uint16_t num_committee_voted() const
Definition: account.hpp:67
graphene::protocol::account_create_operation::ext::active_special_authority
optional< special_authority > active_special_authority
Definition: account.hpp:87
graphene::protocol::account_upgrade_operation::account_to_upgrade
account_id_type account_to_upgrade
The account to upgrade; must not already be a lifetime member.
Definition: account.hpp:244
graphene::protocol::account_create_operation::fee_payer
account_id_type fee_payer() const
Definition: account.hpp:115
graphene::protocol::account_update_operation::ext::null_ext
optional< void_t > null_ext
Definition: account.hpp:140
graphene::protocol::account_transfer_operation::new_owner
account_id_type new_owner
Definition: account.hpp:273
graphene::protocol::account_update_operation::new_options
optional< account_options > new_options
New account options.
Definition: account.hpp:161
graphene::protocol::account_options::votes
flat_set< vote_id_type > votes
Definition: account.hpp:58
graphene::protocol::account_transfer_operation::fee_params_t
Definition: account.hpp:269
graphene::protocol::account_options::memo_key
public_key_type memo_key
Definition: account.hpp:44
authority.hpp
graphene::protocol::account_upgrade_operation::upgrade_to_lifetime_member
bool upgrade_to_lifetime_member
If true, the account will be upgraded to a lifetime member; otherwise, it will add a year to the subs...
Definition: account.hpp:246
GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
graphene::protocol::account_create_operation::ext::buyback_options
optional< buyback_account_options > buyback_options
Definition: account.hpp:88
graphene::protocol::account_update_operation::get_required_owner_authorities
void get_required_owner_authorities(flat_set< account_id_type > &a) const
Definition: account.hpp:171
graphene::protocol::account_whitelist_operation::validate
void validate() const
Definition: account.hpp:219
vote.hpp
graphene::protocol::account_options::num_witness
uint16_t num_witness
Definition: account.hpp:52
graphene::protocol::account_create_operation::owner
authority owner
Definition: account.hpp:109
graphene::protocol::account_create_operation::ext
Definition: account.hpp:83
graphene::protocol::account_create_operation::options
account_options options
Definition: account.hpp:112
FC_ASSERT
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Definition: exception.hpp:345
graphene::protocol::account_update_operation::extensions
extension< ext > extensions
Definition: account.hpp:162
graphene::protocol::account_transfer_operation::extensions
extensions_type extensions
Definition: account.hpp:274
graphene::protocol::account_whitelist_operation::extensions
extensions_type extensions
Definition: account.hpp:216
graphene::protocol::account_options::extensions
extensions_type extensions
Definition: account.hpp:59
FC_REFLECT_ENUM
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
Definition: core_messages.hpp:404
graphene::protocol::account_upgrade_operation::fee_params_t::membership_lifetime_fee
uint64_t membership_lifetime_fee
the cost to upgrade to a lifetime member
Definition: account.hpp:239
base.hpp
graphene::protocol::account_whitelist_operation::white_and_black_listed
@ white_and_black_listed
This account is both whitelisted and blacklisted.
Definition: account.hpp:204
graphene::protocol::account_transfer_operation::fee
asset fee
Definition: account.hpp:271
graphene::protocol::asset::amount
share_type amount
Definition: asset.hpp:36
graphene::protocol::account_whitelist_operation::account_listing
account_listing
Definition: account.hpp:200
graphene::protocol::account_options::is_voting
bool is_voting() const
Whether this account is voting.
Definition: account.hpp:62
graphene::protocol::account_update_operation::ext::active_special_authority
optional< special_authority > active_special_authority
Definition: account.hpp:142
graphene::protocol::is_cheap_name
bool is_cheap_name(const string &n)
Definition: account.cpp:133
graphene::protocol::account_whitelist_operation::no_listing
@ no_listing
No opinion is specified about this account.
Definition: account.hpp:201
graphene::protocol::account_update_operation::account
account_id_type account
The account to update.
Definition: account.hpp:153
graphene::protocol::account_create_operation::fee_params_t
Definition: account.hpp:91
graphene::protocol::account_upgrade_operation
Manage an account's membership status.
Definition: account.hpp:235
graphene::protocol::account_upgrade_operation::fee
asset fee
Definition: account.hpp:242
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
graphene::protocol::account_whitelist_operation::fee_params_t
Definition: account.hpp:199
graphene::protocol::authority
Identifies a weighted set of keys and accounts that must approve operations.
Definition: authority.hpp:34
fc::optional
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
graphene::protocol::account_whitelist_operation
This operation is used to whitelist and blacklist accounts, primarily for transacting in whitelisted ...
Definition: account.hpp:197
graphene::protocol::account_create_operation::referrer_percent
uint16_t referrer_percent
Definition: account.hpp:106
graphene::protocol::account_whitelist_operation::new_listing
uint8_t new_listing
Definition: account.hpp:215
graphene::protocol::account_options::validate
void validate() const
Definition: account.cpp:156
graphene::protocol::account_whitelist_operation::fee_payer
account_id_type fee_payer() const
Definition: account.hpp:218
buyback.hpp
graphene::protocol::asset
Definition: asset.hpp:31
graphene::protocol::account_update_operation::calculate_fee
share_type calculate_fee(const fee_params_t &k) const
Definition: account.cpp:218
graphene::protocol::account_transfer_operation::fee_payer
account_id_type fee_payer() const
Definition: account.hpp:276
asset.hpp
graphene::protocol::account_upgrade_operation::fee_params_t::membership_annual_fee
uint64_t membership_annual_fee
Definition: account.hpp:238
graphene::protocol::is_valid_name
bool is_valid_name(const string &name)
Definition: account.cpp:64
graphene::protocol::account_transfer_operation::validate
void validate() const
Definition: account.cpp:275
graphene::protocol::account_create_operation::calculate_fee
share_type calculate_fee(const fee_params_t &) const
Definition: account.cpp:173
graphene
Definition: api.cpp:48
graphene::protocol::account_update_operation::fee_params_t::fee
share_type fee
Definition: account.hpp:147
graphene::protocol::account_transfer_operation::account_id
account_id_type account_id
Definition: account.hpp:272
graphene::protocol::account_create_operation::ext::null_ext
optional< void_t > null_ext
Definition: account.hpp:85
graphene::protocol::extensions_type
future_extensions::flat_set_type extensions_type
Definition: base.hpp:156
graphene::protocol::account_update_operation::is_owner_update
bool is_owner_update() const
Definition: account.hpp:168
graphene::protocol::account_update_operation::fee
asset fee
Definition: account.hpp:151
fc::safe
Definition: safe.hpp:26