BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
fba_object.cpp
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 
28 
29 namespace graphene { namespace chain {
30 
32 {
33  if( !designated_asset.valid() )
34  {
35  ilog( "FBA fee in block ${b} not paid because designated asset was not configured", ("b", db.head_block_num()) );
36  return false;
37  }
38  const asset_object* dasset = db.find(*designated_asset);
39  if( dasset == nullptr )
40  {
41  ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: designated asset does not exist", ("b", db.head_block_num()) );
42  return false;
43  }
44  if( dasset->is_market_issued() )
45  {
46  ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: FBA is a BitAsset", ("b", db.head_block_num()) );
47  return false;
48  }
49 
50  const uint16_t allowed_flags = charge_market_fee;
51 
52  // check enabled issuer_permissions bits is subset of allowed_flags bits
53  if( (dasset->options.issuer_permissions & allowed_flags) != dasset->options.issuer_permissions )
54  {
55  ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: Disallowed permissions enabled", ("b", db.head_block_num()) );
56  return false;
57  }
58 
59  // check enabled issuer_permissions bits is subset of allowed_flags bits
60  if( (dasset->options.flags & allowed_flags) != dasset->options.flags )
61  {
62  ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: Disallowed flags enabled", ("b", db.head_block_num()) );
63  return false;
64  }
65 
66  if( !dasset->buyback_account.valid() )
67  {
68  ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: designated asset does not have a buyback account", ("b", db.head_block_num()) );
69  return false;
70  }
71  const account_object& issuer_acct = dasset->issuer(db);
72 
74  {
75  ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: designated asset issuer has not set owner top_n control", ("b", db.head_block_num()) );
76  return false;
77  }
79  {
80  ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: designated asset issuer has not set active top_n control", ("b", db.head_block_num()) );
81  return false;
82  }
84  {
85  ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: designated asset issuer's top_n_control is not set to designated asset", ("b", db.head_block_num()) );
86  return false;
87  }
89  {
90  ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: designated asset issuer's top_n_control is not set to designated asset", ("b", db.head_block_num()) );
91  return false;
92  }
93 
95  {
96  ilog( "FBA fee in block ${b} not paid because designated asset's top_n control has not yet activated (wait until next maintenance interval)", ("b", db.head_block_num()) );
97  return false;
98  }
99 
100  return true;
101 }
102 
103 } }
graphene::chain::database
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
database.hpp
graphene::chain::account_object::top_n_control_flags
uint8_t top_n_control_flags
Definition: account_object.hpp:274
graphene::chain::asset_object
tracks the parameters of an asset
Definition: asset_object.hpp:75
graphene::chain::fba_accumulator_object::designated_asset
optional< asset_id_type > designated_asset
Definition: fba_object.hpp:42
graphene::protocol::charge_market_fee
@ charge_market_fee
market trades in this asset may be charged
Definition: types.hpp:194
graphene::db::object_database::find
const T * find(const object_id_type &id) const
Definition: object_database.hpp:126
graphene::chain::fba_accumulator_object::is_configured
bool is_configured(const database &db) const
Definition: fba_object.cpp:31
ilog
#define ilog(FORMAT,...)
Definition: logger.hpp:117
graphene::protocol::top_holders_special_authority::asset
asset_id_type asset
Definition: special_authority.hpp:34
fc::optional::valid
bool valid() const
Definition: optional.hpp:186
graphene::chain::account_object
This class represents an account on the object graph.
Definition: account_object.hpp:180
evaluator.hpp
graphene::chain::account_object::active_special_authority
special_authority active_special_authority
Definition: account_object.hpp:268
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::chain::account_object::top_n_control_owner
static const uint8_t top_n_control_owner
Definition: account_object.hpp:275
graphene::chain::database::head_block_num
uint32_t head_block_num() const
Definition: db_getter.cpp:72
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::top_holders_special_authority
Definition: special_authority.hpp:32
graphene::chain::account_object::owner_special_authority
special_authority owner_special_authority
Definition: account_object.hpp:267
graphene::chain::asset_object::issuer
account_id_type issuer
ID of the account which issued this asset.
Definition: asset_object.hpp:135
fc::static_variant::is_type
bool is_type() const
Definition: static_variant.hpp:332
fc::static_variant::get
X & get()
Definition: static_variant.hpp:236
graphene::chain::asset_object::options
asset_options options
Definition: asset_object.hpp:137
graphene::chain::account_object::top_n_control_active
static const uint8_t top_n_control_active
Definition: account_object.hpp:276
fba_object.hpp
graphene::chain::asset_object::is_market_issued
bool is_market_issued() const
Definition: asset_object.hpp:84
graphene::chain::asset_object::buyback_account
optional< account_id_type > buyback_account
Definition: asset_object.hpp:144
graphene
Definition: api.cpp:48