Get rid of enforce_white_list() #416
This commit is contained in:
parent
db045f453c
commit
d821d4a993
9 changed files with 36 additions and 14 deletions
|
|
@ -41,6 +41,12 @@ share_type cut_fee(share_type a, uint16_t p)
|
||||||
|
|
||||||
bool account_object::is_authorized_asset(const asset_object& asset_obj, const database& d) const
|
bool account_object::is_authorized_asset(const asset_object& asset_obj, const database& d) const
|
||||||
{
|
{
|
||||||
|
if( d.head_block_time() > HARDFORK_416_TIME )
|
||||||
|
{
|
||||||
|
if( !(asset_obj.options.flags & white_list) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
for( const auto id : blacklisting_accounts )
|
for( const auto id : blacklisting_accounts )
|
||||||
{
|
{
|
||||||
if( asset_obj.options.blacklist_authorities.find(id) != asset_obj.options.blacklist_authorities.end() )
|
if( asset_obj.options.blacklist_authorities.find(id) != asset_obj.options.blacklist_authorities.end() )
|
||||||
|
|
@ -68,7 +74,6 @@ void account_balance_object::adjust_balance(const asset& delta)
|
||||||
balance += delta.amount;
|
balance += delta.amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void account_statistics_object::process_fees(const account_object& a, database& d) const
|
void account_statistics_object::process_fees(const account_object& a, database& d) const
|
||||||
{
|
{
|
||||||
if( pending_fees > 0 || pending_vested_fees > 0 )
|
if( pending_fees > 0 || pending_vested_fees > 0 )
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ void_result transfer_to_blind_evaluator::do_evaluate( const transfer_to_blind_op
|
||||||
const auto& atype = o.amount.asset_id(db());
|
const auto& atype = o.amount.asset_id(db());
|
||||||
FC_ASSERT( atype.allow_confidential() );
|
FC_ASSERT( atype.allow_confidential() );
|
||||||
FC_ASSERT( !atype.is_transfer_restricted() );
|
FC_ASSERT( !atype.is_transfer_restricted() );
|
||||||
FC_ASSERT( !atype.enforce_white_list() );
|
FC_ASSERT( !(atype.options.flags & white_list) );
|
||||||
|
|
||||||
for( const auto& out : o.outputs )
|
for( const auto& out : o.outputs )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,6 @@ namespace graphene { namespace chain {
|
||||||
/// @return true if symbol is a valid ticker symbol; false otherwise.
|
/// @return true if symbol is a valid ticker symbol; false otherwise.
|
||||||
static bool is_valid_symbol( const string& symbol );
|
static bool is_valid_symbol( const string& symbol );
|
||||||
|
|
||||||
/// @return true if accounts must be on a whitelist in order to hold this asset; false otherwise.
|
|
||||||
bool enforce_white_list()const { return options.flags & white_list; }
|
|
||||||
/// @return true if this is a market-issued asset; false otherwise.
|
/// @return true if this is a market-issued asset; false otherwise.
|
||||||
bool is_market_issued()const { return bitasset_data_id.valid(); }
|
bool is_market_issued()const { return bitasset_data_id.valid(); }
|
||||||
/// @return true if users may request force-settlement of this market-issued asset; false otherwise
|
/// @return true if users may request force-settlement of this market-issued asset; false otherwise
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,4 @@
|
||||||
#define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 ))
|
#define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 ))
|
||||||
#define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 ))
|
#define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 ))
|
||||||
#define HARDFORK_415_TIME (fc::time_point_sec( 1446652800 ))
|
#define HARDFORK_415_TIME (fc::time_point_sec( 1446652800 ))
|
||||||
|
#define HARDFORK_416_TIME (fc::time_point_sec( 1446652800 ))
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,11 @@ namespace graphene { namespace chain {
|
||||||
/// the core exchange rate.
|
/// the core exchange rate.
|
||||||
price core_exchange_rate;
|
price core_exchange_rate;
|
||||||
|
|
||||||
/// A set of accounts which maintain whitelists to consult for this asset. If enforce_white_list() returns
|
/// A set of accounts which maintain whitelists to consult for this asset. If whitelist_authorities
|
||||||
/// true, an account may only send, receive, trade, etc. in this asset if one of these accounts appears in
|
/// is non-empty, then only accounts in whitelist_authorities are allowed to hold, use, or transfer the asset.
|
||||||
/// its account_object::whitelisting_accounts field.
|
|
||||||
flat_set<account_id_type> whitelist_authorities;
|
flat_set<account_id_type> whitelist_authorities;
|
||||||
/// A set of accounts which maintain blacklists to consult for this asset. If enforce_white_list() returns
|
/// A set of accounts which maintain blacklists to consult for this asset. If flags & white_list is set,
|
||||||
/// true, an account may only send, receive, trade, etc. in this asset if none of these accounts appears in
|
/// an account may only send, receive, trade, etc. in this asset if none of these accounts appears in
|
||||||
/// its account_object::blacklisting_accounts field. If the account is blacklisted, it may not transact in
|
/// its account_object::blacklisting_accounts field. If the account is blacklisted, it may not transact in
|
||||||
/// this asset even if it is also whitelisted.
|
/// this asset even if it is also whitelisted.
|
||||||
flat_set<account_id_type> blacklist_authorities;
|
flat_set<account_id_type> blacklist_authorities;
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,16 @@ void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_o
|
||||||
if( _sell_asset->options.blacklist_markets.size() )
|
if( _sell_asset->options.blacklist_markets.size() )
|
||||||
FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) == _sell_asset->options.blacklist_markets.end() );
|
FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) == _sell_asset->options.blacklist_markets.end() );
|
||||||
|
|
||||||
if( _sell_asset->enforce_white_list() ) FC_ASSERT( _seller->is_authorized_asset( *_sell_asset, d ) );
|
if( d.head_block_time() <= HARDFORK_416_TIME )
|
||||||
if( _receive_asset->enforce_white_list() ) FC_ASSERT( _seller->is_authorized_asset( *_receive_asset, d ) );
|
{
|
||||||
|
if( _sell_asset->options.flags & white_list ) FC_ASSERT( _seller->is_authorized_asset( *_sell_asset, d ) );
|
||||||
|
if( _receive_asset->options.flags & white_list ) FC_ASSERT( _seller->is_authorized_asset( *_receive_asset, d ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FC_ASSERT( _seller->is_authorized_asset( *_sell_asset, d ) );
|
||||||
|
FC_ASSERT( _seller->is_authorized_asset( *_receive_asset, d ) );
|
||||||
|
}
|
||||||
|
|
||||||
FC_ASSERT( d.get_balance( *_seller, *_sell_asset ) >= op.amount_to_sell, "insufficient balance",
|
FC_ASSERT( d.get_balance( *_seller, *_sell_asset ) >= op.amount_to_sell, "insufficient balance",
|
||||||
("balance",d.get_balance(*_seller,*_sell_asset))("amount_to_sell",op.amount_to_sell) );
|
("balance",d.get_balance(*_seller,*_sell_asset))("amount_to_sell",op.amount_to_sell) );
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include <graphene/chain/account_object.hpp>
|
#include <graphene/chain/account_object.hpp>
|
||||||
#include <graphene/chain/database.hpp>
|
#include <graphene/chain/database.hpp>
|
||||||
#include <graphene/chain/exceptions.hpp>
|
#include <graphene/chain/exceptions.hpp>
|
||||||
|
#include <graphene/chain/hardfork.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
|
|
@ -65,7 +66,17 @@ void_result withdraw_permission_claim_evaluator::do_evaluate(const withdraw_perm
|
||||||
const asset_object& _asset = op.amount_to_withdraw.asset_id(d);
|
const asset_object& _asset = op.amount_to_withdraw.asset_id(d);
|
||||||
if( _asset.is_transfer_restricted() ) FC_ASSERT( _asset.issuer == permit.authorized_account || _asset.issuer == permit.withdraw_from_account );
|
if( _asset.is_transfer_restricted() ) FC_ASSERT( _asset.issuer == permit.authorized_account || _asset.issuer == permit.withdraw_from_account );
|
||||||
|
|
||||||
if( _asset.enforce_white_list() )
|
if( d.head_block_time() <= HARDFORK_416_TIME )
|
||||||
|
{
|
||||||
|
if( _asset.options.flags & white_list )
|
||||||
|
{
|
||||||
|
const account_object& from = op.withdraw_to_account(d);
|
||||||
|
const account_object& to = permit.authorized_account(d);
|
||||||
|
FC_ASSERT( to.is_authorized_asset( _asset, d ) );
|
||||||
|
FC_ASSERT( from.is_authorized_asset( _asset, d ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
const account_object& from = op.withdraw_to_account(d);
|
const account_object& from = op.withdraw_to_account(d);
|
||||||
const account_object& to = permit.authorized_account(d);
|
const account_object& to = permit.authorized_account(d);
|
||||||
|
|
|
||||||
|
|
@ -687,7 +687,7 @@ BOOST_AUTO_TEST_CASE( create_uia )
|
||||||
const asset_object& test_asset = test_asset_id(db);
|
const asset_object& test_asset = test_asset_id(db);
|
||||||
BOOST_CHECK(test_asset.symbol == "TEST");
|
BOOST_CHECK(test_asset.symbol == "TEST");
|
||||||
BOOST_CHECK(asset(1, test_asset_id) * test_asset.options.core_exchange_rate == asset(2));
|
BOOST_CHECK(asset(1, test_asset_id) * test_asset.options.core_exchange_rate == asset(2));
|
||||||
BOOST_CHECK(!test_asset.enforce_white_list());
|
BOOST_CHECK((test_asset.options.flags & white_list) == 0);
|
||||||
BOOST_CHECK(test_asset.options.max_supply == 100000000);
|
BOOST_CHECK(test_asset.options.max_supply == 100000000);
|
||||||
BOOST_CHECK(!test_asset.bitasset_data_id.valid());
|
BOOST_CHECK(!test_asset.bitasset_data_id.valid());
|
||||||
BOOST_CHECK(test_asset.options.market_fee_percent == GRAPHENE_MAX_MARKET_FEE_PERCENT/100);
|
BOOST_CHECK(test_asset.options.market_fee_percent == GRAPHENE_MAX_MARKET_FEE_PERCENT/100);
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE( create_advanced_uia )
|
||||||
const asset_object& test_asset = test_asset_id(db);
|
const asset_object& test_asset = test_asset_id(db);
|
||||||
BOOST_CHECK(test_asset.symbol == "ADVANCED");
|
BOOST_CHECK(test_asset.symbol == "ADVANCED");
|
||||||
BOOST_CHECK(asset(1, test_asset_id) * test_asset.options.core_exchange_rate == asset(2));
|
BOOST_CHECK(asset(1, test_asset_id) * test_asset.options.core_exchange_rate == asset(2));
|
||||||
BOOST_CHECK(test_asset.enforce_white_list());
|
BOOST_CHECK(test_asset.options.flags & white_list);
|
||||||
BOOST_CHECK(test_asset.options.max_supply == 100000000);
|
BOOST_CHECK(test_asset.options.max_supply == 100000000);
|
||||||
BOOST_CHECK(!test_asset.bitasset_data_id.valid());
|
BOOST_CHECK(!test_asset.bitasset_data_id.valid());
|
||||||
BOOST_CHECK(test_asset.options.market_fee_percent == GRAPHENE_MAX_MARKET_FEE_PERCENT/100);
|
BOOST_CHECK(test_asset.options.market_fee_percent == GRAPHENE_MAX_MARKET_FEE_PERCENT/100);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue