fixed update witness operation - added new_initial_secret

This commit is contained in:
Roman Olearski 2017-05-27 20:11:46 +02:00
parent 74bcc3ed4f
commit e6b58adbd1
3 changed files with 9 additions and 2 deletions

View file

@ -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<secret_hash_type> 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) )

View file

@ -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) ) }

View file

@ -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 );