diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index ef52056c..6ef1c042 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -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 { + if( d.head_block_time() > HARDFORK_416_TIME ) + { + if( !(asset_obj.options.flags & white_list) ) + return true; + } + for( const auto id : blacklisting_accounts ) { 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; } - void account_statistics_object::process_fees(const account_object& a, database& d) const { if( pending_fees > 0 || pending_vested_fees > 0 ) diff --git a/libraries/chain/confidential_evaluator.cpp b/libraries/chain/confidential_evaluator.cpp index 014e6224..065cbe43 100644 --- a/libraries/chain/confidential_evaluator.cpp +++ b/libraries/chain/confidential_evaluator.cpp @@ -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()); FC_ASSERT( atype.allow_confidential() ); 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 ) { diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 4496fe03..1ffe7e95 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -82,8 +82,6 @@ namespace graphene { namespace chain { /// @return true if symbol is a valid ticker symbol; false otherwise. 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. 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 diff --git a/libraries/chain/include/graphene/chain/hardfork.hpp b/libraries/chain/include/graphene/chain/hardfork.hpp index 503e5f0b..da94532d 100644 --- a/libraries/chain/include/graphene/chain/hardfork.hpp +++ b/libraries/chain/include/graphene/chain/hardfork.hpp @@ -23,3 +23,4 @@ #define HARDFORK_357_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_416_TIME (fc::time_point_sec( 1446652800 )) diff --git a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp b/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp index e0cd26eb..afb7b8e2 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp +++ b/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp @@ -53,12 +53,11 @@ namespace graphene { namespace chain { /// the core exchange rate. price core_exchange_rate; - /// A set of accounts which maintain whitelists to consult for this asset. If enforce_white_list() returns - /// true, an account may only send, receive, trade, etc. in this asset if one of these accounts appears in - /// its account_object::whitelisting_accounts field. + /// A set of accounts which maintain whitelists to consult for this asset. If whitelist_authorities + /// is non-empty, then only accounts in whitelist_authorities are allowed to hold, use, or transfer the asset. flat_set whitelist_authorities; - /// A set of accounts which maintain blacklists to consult for this asset. If enforce_white_list() returns - /// true, an account may only send, receive, trade, etc. in this asset if none of these accounts appears in + /// A set of accounts which maintain blacklists to consult for this asset. If flags & white_list is set, + /// 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 /// this asset even if it is also whitelisted. flat_set blacklist_authorities; diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 19f7742f..f357a18e 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -42,8 +42,16 @@ void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_o if( _sell_asset->options.blacklist_markets.size() ) 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( _receive_asset->enforce_white_list() ) FC_ASSERT( _seller->is_authorized_asset( *_receive_asset, d ) ); + if( d.head_block_time() <= HARDFORK_416_TIME ) + { + 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", ("balance",d.get_balance(*_seller,*_sell_asset))("amount_to_sell",op.amount_to_sell) ); diff --git a/libraries/chain/withdraw_permission_evaluator.cpp b/libraries/chain/withdraw_permission_evaluator.cpp index 17e96c45..1c1fb620 100644 --- a/libraries/chain/withdraw_permission_evaluator.cpp +++ b/libraries/chain/withdraw_permission_evaluator.cpp @@ -23,6 +23,7 @@ #include #include #include +#include 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); 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& to = permit.authorized_account(d); diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 001450af..b85b3161 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -687,7 +687,7 @@ BOOST_AUTO_TEST_CASE( create_uia ) const asset_object& test_asset = test_asset_id(db); BOOST_CHECK(test_asset.symbol == "TEST"); 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.bitasset_data_id.valid()); BOOST_CHECK(test_asset.options.market_fee_percent == GRAPHENE_MAX_MARKET_FEE_PERCENT/100); diff --git a/tests/tests/uia_tests.cpp b/tests/tests/uia_tests.cpp index 924a91fd..25b13484 100644 --- a/tests/tests/uia_tests.cpp +++ b/tests/tests/uia_tests.cpp @@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE( create_advanced_uia ) const asset_object& test_asset = test_asset_id(db); BOOST_CHECK(test_asset.symbol == "ADVANCED"); 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.bitasset_data_id.valid()); BOOST_CHECK(test_asset.options.market_fee_percent == GRAPHENE_MAX_MARKET_FEE_PERCENT/100);