BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface 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 } }
bool is_type() const
const T * find(object_id_type id) const
special_authority active_special_authority
This class represents an account on the object graphAccounts are the primary unit of authority on the...
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
Definition: api.cpp:56
static const uint8_t top_n_control_active
bool valid() const
Definition: optional.hpp:186
uint32_t head_block_num() const
Definition: db_getter.cpp:69
optional< account_id_type > buyback_account
account_id_type issuer
ID of the account which issued this asset.
static const uint8_t top_n_control_owner
#define ilog(FORMAT,...)
Definition: logger.hpp:117
uint16_t issuer_permissions
The flags which the issuer has permission to update. See asset_issuer_permission_flags.
Definition: asset_ops.hpp:61
bool is_configured(const database &db) const
Definition: fba_object.cpp:31
market trades in this asset may be charged
Definition: types.hpp:140
optional< asset_id_type > designated_asset
Definition: fba_object.hpp:44
tracks the parameters of an assetAll assets have a globally unique symbol name that controls how they...
uint16_t flags
The currently active flags on this permission. See asset_issuer_permission_flags. ...
Definition: asset_ops.hpp:63
special_authority owner_special_authority