Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent an smt from emitting to null or the treasury account #3616

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libraries/protocol/smt_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ void smt_setup_emissions_operation::validate()const
FC_ASSERT( lep_abs_amount > 0 || lep_rel_amount_numerator > 0 || rep_abs_amount > 0 || rep_rel_amount_numerator > 0,
"An emission operation must have positive non-zero emission" );

for ( const auto& e : emissions_unit.token_unit )
{
if ( smt::unit_target::is_account_name_type( e.first ) )
{
std::string name = smt::unit_target::get_unit_target_account( e.first );
FC_ASSERT( name != STEEM_TREASURY_ACCOUNT, "Invalid emission destination, cannot emit to the treasury account ${a}", ("a", STEEM_TREASURY_ACCOUNT) );
FC_ASSERT( name != STEEM_NULL_ACCOUNT, "Invalid emission destination, cannot emit to ${a}", ("a", STEEM_NULL_ACCOUNT) );
}
}

// rel_amount_denom_bits <- any value of unsigned int is OK
}

Expand Down
11 changes: 9 additions & 2 deletions tests/tests/smt_operation_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <fc/macros.hpp>

#if defined IS_TEST_NET

#include <boost/test/unit_test.hpp>

Expand Down Expand Up @@ -2137,6 +2136,15 @@ BOOST_AUTO_TEST_CASE( smt_setup_emissions_validate )
op.emissions_unit.token_unit[ "@@@@" ] = 10;
STEEM_REQUIRE_THROW( op.validate(), fc::exception );
op.emissions_unit.token_unit.clear();

BOOST_TEST_MESSAGE( " -- Invalid emission unit token unit account is the treasury account" );
op.emissions_unit.token_unit[ STEEM_TREASURY_ACCOUNT ] = 10;
STEEM_REQUIRE_THROW( op.validate(), fc::exception );
op.emissions_unit.token_unit.clear();
BOOST_TEST_MESSAGE( " -- Invalid emission unit token unit account is the null account" );
op.emissions_unit.token_unit[ STEEM_NULL_ACCOUNT ] = 10;
STEEM_REQUIRE_THROW( op.validate(), fc::exception );
op.emissions_unit.token_unit.clear();
op.emissions_unit.token_unit[ SMT_DESTINATION_REWARDS ] = 1;
op.emissions_unit.token_unit[ SMT_DESTINATION_MARKET_MAKER ] = 1;
op.emissions_unit.token_unit[ SMT_DESTINATION_VESTING ] = 1;
Expand Down Expand Up @@ -5179,4 +5187,3 @@ BOOST_AUTO_TEST_CASE( smt_setup_ico_tier_apply )
}

BOOST_AUTO_TEST_SUITE_END()
#endif