diff --git a/libraries/chain/include/graphene/chain/protocol/witness.hpp b/libraries/chain/include/graphene/chain/protocol/witness.hpp index f1b3eb6e..b096e826 100644 --- a/libraries/chain/include/graphene/chain/protocol/witness.hpp +++ b/libraries/chain/include/graphene/chain/protocol/witness.hpp @@ -68,6 +68,8 @@ namespace graphene { namespace chain { optional< string > new_url; /// The new block signing key. optional< public_key_type > new_signing_key; + /// The new secreat hash. + optional new_initial_secret; account_id_type fee_payer()const { return witness_account; } void validate()const; @@ -81,4 +83,4 @@ FC_REFLECT( graphene::chain::witness_create_operation::fee_parameters_type, (fee FC_REFLECT( graphene::chain::witness_create_operation, (fee)(witness_account)(url)(block_signing_key)(initial_secret) ) FC_REFLECT( graphene::chain::witness_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key) ) +FC_REFLECT( graphene::chain::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key)(new_initial_secret) ) diff --git a/libraries/chain/witness_evaluator.cpp b/libraries/chain/witness_evaluator.cpp index 4d2802d6..1d4bbe2a 100644 --- a/libraries/chain/witness_evaluator.cpp +++ b/libraries/chain/witness_evaluator.cpp @@ -70,6 +70,8 @@ void_result witness_update_evaluator::do_apply( const witness_update_operation& wit.url = *op.new_url; if( op.new_signing_key.valid() ) wit.signing_key = *op.new_signing_key; + if( op.new_initial_secret.valid() ) + wit.next_secret_hash = *op.new_initial_secret; }); return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 456536c6..65d21b9d 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1753,6 +1753,7 @@ public: fc::raw::pack(enc, secret_hash_type()); witness_create_op.initial_secret = secret_hash_type::hash(enc.result()); + if (_remote_db->get_witness_by_account(witness_create_op.witness_account)) FC_THROW("Account ${owner_account} is already a witness", ("owner_account", owner_account)); @@ -1780,8 +1781,10 @@ public: witness_update_op.witness_account = witness_account.id; if( url != "" ) witness_update_op.new_url = url; - if( block_signing_key != "" ) + if( block_signing_key != "" ) { witness_update_op.new_signing_key = public_key_type( block_signing_key ); + witness_update_op.new_initial_secret = secret_hash_type::hash(secret_hash_type()); + } signed_transaction tx; tx.operations.push_back( witness_update_op );