diff --git a/libraries/chain/include/graphene/chain/protocol/son.hpp b/libraries/chain/include/graphene/chain/protocol/son.hpp index 10a75412..42ead5b6 100644 --- a/libraries/chain/include/graphene/chain/protocol/son.hpp +++ b/libraries/chain/include/graphene/chain/protocol/son.hpp @@ -1,6 +1,7 @@ #pragma once #include #include +#include namespace graphene { namespace chain { @@ -32,6 +33,7 @@ namespace graphene { namespace chain { optional new_signing_key; optional> new_sidechain_public_keys; optional new_pay_vb; + optional new_status; account_id_type fee_payer()const { return owner_account; } share_type calculate_fee(const fee_parameters_type& k)const { return 0; } @@ -103,7 +105,7 @@ FC_REFLECT(graphene::chain::son_create_operation, (fee)(owner_account)(url)(depo FC_REFLECT(graphene::chain::son_update_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_update_operation, (fee)(son_id)(owner_account)(new_url)(new_deposit) - (new_signing_key)(new_sidechain_public_keys)(new_pay_vb) ) + (new_signing_key)(new_sidechain_public_keys)(new_pay_vb)(new_status) ) FC_REFLECT(graphene::chain::son_deregister_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_deregister_operation, (fee)(son_id)(payer) ) diff --git a/libraries/chain/son_evaluator.cpp b/libraries/chain/son_evaluator.cpp index bf92b709..e732c145 100644 --- a/libraries/chain/son_evaluator.cpp +++ b/libraries/chain/son_evaluator.cpp @@ -79,6 +79,9 @@ void_result update_son_evaluator::do_evaluate(const son_update_operation& op) FC_ASSERT(vbo.policy.which() == vesting_policy::tag::value, "Payment balance must have linear vesting policy"); } + if(op.new_status.valid()) { + FC_ASSERT(db().get(op.son_id).status == son_status::deregistered, "SON must be in deregistered state"); + } return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } @@ -94,6 +97,7 @@ object_id_type update_son_evaluator::do_apply(const son_update_operation& op) if(op.new_signing_key.valid()) so.signing_key = *op.new_signing_key; if(op.new_sidechain_public_keys.valid()) so.sidechain_public_keys = *op.new_sidechain_public_keys; if(op.new_pay_vb.valid()) so.pay_vb = *op.new_pay_vb; + if(op.new_status.valid()) so.status = son_status::inactive; }); } return op.son_id; diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index a7921b1f..ff32ac10 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -1425,6 +1425,16 @@ class wallet_api flat_map sidechain_public_keys, bool broadcast = false); + /** + * Activate deregistered SON object owned by the given account. + * + * @param owner_account The name of the SON's owner account. Also accepts the ID of the owner account or the ID of the SON. + * @param broadcast true if you wish to broadcast the transaction. + */ + signed_transaction activate_deregistered_son(const string & owner_account, + bool broadcast /* = false */); + + /** * Updates vesting balances of the SON object owned by the given account. * @@ -2622,6 +2632,7 @@ FC_API( graphene::wallet::wallet_api, (try_create_son) (update_son) (update_son_vesting_balances) + (activate_deregistered_son) (list_sons) (list_active_sons) (get_son_network_status) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index e876924e..cc013736 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2114,6 +2114,23 @@ public: return sign_transaction( tx, broadcast ); } FC_CAPTURE_AND_RETHROW( (owner_account)(url)(block_signing_key)(broadcast) ) } + signed_transaction activate_deregistered_son(const string & owner_account, + bool broadcast /* = false */) + { try { + son_object son = get_son(owner_account); + + son_update_operation son_update_op; + son_update_op.son_id = son.id; + son_update_op.owner_account = son.son_account; + son_update_op.new_status = son_status::inactive; + signed_transaction tx; + tx.operations.push_back( son_update_op ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + tx.validate(); + + return sign_transaction( tx, broadcast ); + } FC_CAPTURE_AND_RETHROW( (owner_account)(broadcast) ) } + signed_transaction update_son_vesting_balances(string owner_account, optional new_deposit, optional new_pay_vb, @@ -5053,6 +5070,11 @@ signed_transaction wallet_api::update_son(string owner_account, return my->update_son(owner_account, url, block_signing_key, sidechain_public_keys, broadcast); } +signed_transaction wallet_api::activate_deregistered_son(const string & owner_account, bool broadcast) { + return my->activate_deregistered_son(owner_account, broadcast); +} + + signed_transaction wallet_api::update_son_vesting_balances(string owner_account, optional new_deposit, optional new_pay_vb,