本文整理汇总了C++中transaction_evaluation_state::check_signature方法的典型用法代码示例。如果您正苦于以下问题:C++ transaction_evaluation_state::check_signature方法的具体用法?C++ transaction_evaluation_state::check_signature怎么用?C++ transaction_evaluation_state::check_signature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transaction_evaluation_state
的用法示例。
在下文中一共展示了transaction_evaluation_state::check_signature方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evaluate
void ad_operation::evaluate( transaction_evaluation_state& eval_state )const
{ try {
if( this->amount.amount <= 0 )
FC_CAPTURE_AND_THROW( negative_deposit, (amount) );
FC_ASSERT( !message.empty() );
FC_ASSERT( amount.asset_id == 0 );
const size_t message_kb = (message.size() / 1024) + 1;
const share_type required_fee = message_kb * BTS_BLOCKCHAIN_MIN_AD_FEE;
FC_ASSERT( amount.amount >= required_fee, "Message of size ${s} KiB requires at least ${a} satoshis to be pay!",
("s",message_kb)("a",required_fee) );
// half of the note fees goto collected fees(delegate pay), other go to ad owner
eval_state.min_fees[amount.asset_id] += required_fee;
FC_ASSERT( owner_account_id != 0 );
const oaccount_record owner_account_rec = eval_state.pending_state()->get_account_record( abs( this->owner_account_id ) );
FC_ASSERT( owner_account_rec.valid() );
auto owner_address = owner_account_rec->active_address();
auto ad_income_balance = eval_state.pending_state()->get_balance_record(withdraw_condition( withdraw_with_signature(owner_address), 0 ).get_address());
if( !ad_income_balance )
ad_income_balance = balance_record( owner_address, asset(0, 0), 0 );
auto ad_pay = amount.amount - required_fee;
ad_income_balance->balance += ad_pay;
ad_income_balance->last_update = eval_state.pending_state()->now();
ad_income_balance->deposit_date = eval_state.pending_state()->now();
eval_state.pending_state()->store_balance_record( *ad_income_balance );
eval_state.sub_balance( asset(ad_pay, amount.asset_id) );
// checking the signature of the publisher.
FC_ASSERT( publisher_account_id != 0 );
const oaccount_record publisher_account_rec = eval_state.pending_state()->get_account_record( abs( this->publisher_account_id ) );
FC_ASSERT( publisher_account_rec.valid() );
eval_state.check_signature( publisher_account_rec->active_key() );
ad_record record;
record.index.account_id = owner_account_id;
record.index.transaction_id = eval_state.trx.id();
record.publisher_id = publisher_account_id;
record.amount = amount;
record.message = message;
record.signer = message_signature;
// the message must be signed by the claimed publisher account
FC_ASSERT( publisher_account_rec->active_key() == record.signer_key() );
FC_ASSERT( !eval_state.pending_state()->get_ad_record( record.index ).valid() );
eval_state.pending_state()->store_ad_record( std::move( record ) );
} FC_CAPTURE_AND_RETHROW( (*this) ) }
示例2: evaluate
void domain_update_signin_operation::evaluate( transaction_evaluation_state& eval_state )
{
auto odomain_rec = eval_state._current_state->get_domain_record( this->domain_name );
auto now = eval_state._current_state->now().sec_since_epoch();
FC_ASSERT( odomain_rec.valid(), "Trying to update domain which does not exist" );
FC_ASSERT( odomain_rec->get_true_state(now) == domain_record::owned,
"Attempting to update a domain which is not in 'owned' state");
FC_ASSERT( eval_state.check_signature( odomain_rec->owner ), "Update not signed by owner" );
odomain_rec->signin_key = this->signin_key;
odomain_rec->last_update = eval_state._current_state->now().sec_since_epoch();
eval_state._current_state->store_domain_record( *odomain_rec );
}
示例3: evaluate
void release_escrow_operation::evaluate( transaction_evaluation_state& eval_state )
{ try {
FC_ASSERT( !"This operation is not enabled yet!" );
auto escrow_balance_record = eval_state._current_state->get_balance_record( this->escrow_id );
FC_ASSERT( escrow_balance_record.valid() );
if( !eval_state.check_signature( this->released_by ) )
FC_ASSERT( !"transaction not signed by releasor" );
auto escrow_condition = escrow_balance_record->condition.as<withdraw_with_escrow>();
auto total_released = amount_to_sender + amount_to_receiver;
FC_ASSERT( total_released <= escrow_balance_record->balance );
FC_ASSERT( total_released >= amount_to_sender ); // check for addition overflow
escrow_balance_record->balance -= total_released;
auto asset_rec = eval_state._current_state->get_asset_record( escrow_balance_record->condition.asset_id );
if( asset_rec->is_restricted() )
{
FC_ASSERT( eval_state._current_state->get_authorization( escrow_balance_record->condition.asset_id, escrow_condition.receiver ) );
}
if( asset_rec->is_retractable() )
{
if( eval_state.verify_authority( asset_rec->authority ) )
{
//
}
}
if( escrow_condition.sender == this->released_by )
{
FC_ASSERT( amount_to_sender == 0 );
FC_ASSERT( amount_to_receiver <= escrow_balance_record->balance );
if( !eval_state.check_signature( escrow_condition.sender ) )
FC_CAPTURE_AND_THROW( missing_signature, (escrow_condition.sender) );
balance_record new_balance_record( escrow_condition.receiver,
asset( amount_to_receiver, escrow_balance_record->asset_id() ),
escrow_balance_record->slate_id() );
auto current_receiver_balance = eval_state._current_state->get_balance_record( new_balance_record.id());
if( current_receiver_balance )
current_receiver_balance->balance += amount_to_receiver;
else
current_receiver_balance = new_balance_record;
eval_state._current_state->store_balance_record( *current_receiver_balance );
}
else if( escrow_condition.receiver == this->released_by )
{
FC_ASSERT( amount_to_receiver == 0 );
FC_ASSERT( amount_to_sender <= escrow_balance_record->balance );
if( !eval_state.check_signature( escrow_condition.receiver ) )
FC_CAPTURE_AND_THROW( missing_signature, (escrow_condition.receiver) );
balance_record new_balance_record( escrow_condition.sender,
asset( amount_to_sender, escrow_balance_record->asset_id() ),
escrow_balance_record->slate_id() );
auto current_sender_balance = eval_state._current_state->get_balance_record( new_balance_record.id());
if( current_sender_balance )
current_sender_balance->balance += amount_to_sender;
else
current_sender_balance = new_balance_record;
eval_state._current_state->store_balance_record( *current_sender_balance );
}
else if( escrow_condition.escrow == this->released_by )
{
if( !eval_state.check_signature( escrow_condition.escrow ) )
FC_CAPTURE_AND_THROW( missing_signature, (escrow_condition.escrow) );
// get a balance record for the receiver, create it if necessary and deposit funds
{
balance_record new_balance_record( escrow_condition.receiver,
asset( amount_to_receiver, escrow_balance_record->asset_id() ),
escrow_balance_record->slate_id() );
auto current_receiver_balance = eval_state._current_state->get_balance_record( new_balance_record.id());
if( current_receiver_balance )
current_receiver_balance->balance += amount_to_receiver;
else
current_receiver_balance = new_balance_record;
eval_state._current_state->store_balance_record( *current_receiver_balance );
}
// get a balance record for the sender, create it if necessary and deposit funds
{
balance_record new_balance_record( escrow_condition.sender,
asset( amount_to_sender, escrow_balance_record->asset_id() ),
escrow_balance_record->slate_id() );
auto current_sender_balance = eval_state._current_state->get_balance_record( new_balance_record.id());
if( current_sender_balance )
current_sender_balance->balance += amount_to_sender;
else
current_sender_balance = new_balance_record;
eval_state._current_state->store_balance_record( *current_sender_balance );
}
//.........这里部分代码省略.........
示例4: switch
void withdraw_operation::evaluate_v3( transaction_evaluation_state& eval_state )
{ try {
if( eval_state._current_state->get_head_block_num() < BTS_V0_4_15_FORK_BLOCK_NUM )
return evaluate_v2( eval_state );
if( this->amount <= 0 )
FC_CAPTURE_AND_THROW( negative_deposit, (amount) );
obalance_record current_balance_record = eval_state._current_state->get_balance_record( this->balance_id );
if( !current_balance_record )
FC_CAPTURE_AND_THROW( unknown_balance_record, (balance_id) );
if( this->amount > current_balance_record->balance ) // Some withdraw conditions require extra checks (e.g. vesting condition)
FC_CAPTURE_AND_THROW( insufficient_funds,
(current_balance_record)
(amount)
(current_balance_record->balance - amount) );
switch( (withdraw_condition_types)current_balance_record->condition.type )
{
case withdraw_signature_type:
{
auto owner = current_balance_record->condition.as<withdraw_with_signature>().owner;
if( !eval_state.check_signature( owner ) )
FC_CAPTURE_AND_THROW( missing_signature, (owner) );
break;
}
default:
FC_CAPTURE_AND_THROW( invalid_withdraw_condition, (current_balance_record->condition) );
}
// update delegate vote on withdrawn account..
if( current_balance_record->condition.asset_id == 0 && current_balance_record->condition.delegate_slate_id )
eval_state.adjust_vote( current_balance_record->condition.delegate_slate_id, -this->amount );
auto asset_rec = eval_state._current_state->get_asset_record( current_balance_record->condition.asset_id );
FC_ASSERT( asset_rec.valid() );
if( asset_rec->is_market_issued() )
{
auto yield = current_balance_record->calculate_yield_v1( eval_state._current_state->now(),
current_balance_record->balance,
asset_rec->collected_fees,
asset_rec->current_share_supply );
if( yield.amount > 0 )
{
asset_rec->collected_fees -= yield.amount;
current_balance_record->balance += yield.amount;
current_balance_record->deposit_date = eval_state._current_state->now();
eval_state.yield[current_balance_record->condition.asset_id] += yield.amount;
eval_state._current_state->store_asset_record( *asset_rec );
}
}
current_balance_record->balance -= this->amount;
current_balance_record->last_update = eval_state._current_state->now();
eval_state._current_state->store_balance_record( *current_balance_record );
eval_state.add_balance( asset(this->amount, current_balance_record->condition.asset_id) );
} FC_CAPTURE_AND_RETHROW( (*this) ) }