Changed bitcoin_transaction_send_operation. Fixed bugs.
This commit is contained in:
parent
e1d99702e4
commit
f4afdbe145
7 changed files with 27 additions and 24 deletions
|
|
@ -33,7 +33,7 @@ object_id_type bitcoin_transaction_send_evaluator::do_apply( const bitcoin_trans
|
|||
|
||||
const bitcoin_transaction_object& btc_tx = d.create< bitcoin_transaction_object >( [&]( bitcoin_transaction_object& obj )
|
||||
{
|
||||
obj.pw_vin = mutable_op.pw_vin;
|
||||
obj.pw_vin = mutable_op.pw_vin.identifier;
|
||||
obj.vins = new_vins;
|
||||
obj.vouts = mutable_op.vouts;
|
||||
obj.transaction = mutable_op.transaction;
|
||||
|
|
@ -81,13 +81,8 @@ void bitcoin_transaction_send_evaluator::finalize_bitcoin_transaction( bitcoin_t
|
|||
database& d = db();
|
||||
|
||||
auto vins = op.vins;
|
||||
if( op.pw_vin.str().compare( 0, 24, SIDECHAIN_NULL_VIN_IDENTIFIER ) != 0 ) {
|
||||
const auto& pw_vout = d.pw_vout_manager.get_vout( op.pw_vin );
|
||||
info_for_vin vin;
|
||||
vin.out = pw_vout->vout;
|
||||
vin.address = d.get_latest_PW().address.get_address();
|
||||
vin.identifier = pw_vout->hash_id;
|
||||
vins.insert( vins.begin(), vin );
|
||||
if( op.pw_vin.identifier.str().compare( 0, 48, SIDECHAIN_NULL_VIN_IDENTIFIER ) != 0 ) {
|
||||
vins.insert( vins.begin(), op.pw_vin );
|
||||
}
|
||||
|
||||
std::vector<bytes> redeem_scripts( d.i_w_info.get_redeem_scripts( vins ) );
|
||||
|
|
@ -106,7 +101,7 @@ void bitcoin_transaction_send_evaluator::send_bitcoin_transaction( const bitcoin
|
|||
{
|
||||
database& d = db();
|
||||
uint32_t skip = d.get_node_properties().skip_flags;
|
||||
if( !(skip & graphene::chain::database::skip_btc_tx_sending) ){
|
||||
if( !(skip & graphene::chain::database::skip_btc_tx_sending) && d.send_btc_tx_flag ){
|
||||
d.send_btc_tx( btc_tx.transaction );
|
||||
}
|
||||
}
|
||||
|
|
@ -125,7 +120,13 @@ void_result bitcoin_transaction_sign_evaluator::do_evaluate( const bitcoin_trans
|
|||
|
||||
sidechain::bytes public_key( public_key_data_to_bytes( witness_obj.signing_key.key_data ) );
|
||||
auto btc_send_op = proposal_itr->proposed_transaction.operations[0].get<bitcoin_transaction_send_operation>();
|
||||
FC_ASSERT( check_sigs( public_key, op.signatures, btc_send_op.vins, btc_send_op.transaction ) ); // Add pw_vin
|
||||
|
||||
auto vins = btc_send_op.vins;
|
||||
if( btc_send_op.pw_vin.identifier.str().compare( 0, 48, SIDECHAIN_NULL_VIN_IDENTIFIER ) != 0 ) {
|
||||
vins.insert( vins.begin(), btc_send_op.pw_vin );
|
||||
}
|
||||
|
||||
FC_ASSERT( check_sigs( public_key, op.signatures, vins, btc_send_op.transaction ) ); // Add pw_vin
|
||||
|
||||
// const auto& proposal = sidechain_proposal_itr->proposal_id( d );
|
||||
// FC_ASSERT( d.check_witness( witness_obj, *btc_tx, proposal ), "Can't sign this transaction" );
|
||||
|
|
|
|||
|
|
@ -176,6 +176,9 @@ void database::check_tansaction_for_duplicated_operations(const signed_transacti
|
|||
bool database::push_block(const signed_block& new_block, uint32_t skip)
|
||||
{
|
||||
// idump((new_block.block_num())(new_block.id())(new_block.timestamp)(new_block.previous));
|
||||
|
||||
send_btc_tx_flag = true;
|
||||
|
||||
bool result;
|
||||
detail::with_skip_flags( *this, skip, [&]()
|
||||
{
|
||||
|
|
@ -421,6 +424,8 @@ signed_block database::_generate_block(
|
|||
}
|
||||
}
|
||||
|
||||
send_btc_tx_flag = false;
|
||||
|
||||
uint64_t postponed_tx_count = 0;
|
||||
// pop pending state (reset to head block state)
|
||||
for( const processed_transaction& tx : _pending_tx )
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ full_btc_transaction database::create_btc_transaction( const std::vector<info_fo
|
|||
sidechain_condensing_tx ctx( info_vins, info_vouts );
|
||||
|
||||
|
||||
if( info_pw_vin.identifier.str().compare( 0, 24, SIDECHAIN_NULL_VIN_IDENTIFIER ) == 0 ) {
|
||||
if( info_pw_vin.identifier.str().compare( 0, 48, SIDECHAIN_NULL_VIN_IDENTIFIER ) != 0 ) {
|
||||
ctx.create_pw_vin( info_pw_vin );
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ fc::optional<operation> database::create_send_btc_tx_proposal( const witness_obj
|
|||
|
||||
bitcoin_transaction_send_operation btc_send_op;
|
||||
btc_send_op.payer = get_sidechain_account_id();
|
||||
btc_send_op.pw_vin = info_pw_vin->identifier;
|
||||
btc_send_op.pw_vin = *info_pw_vin;
|
||||
btc_send_op.vins = info_vins;
|
||||
for( auto& out : info_vouts ) {
|
||||
btc_send_op.vouts.push_back( out.get_id() );
|
||||
|
|
@ -228,13 +228,8 @@ operation database::create_sign_btc_tx_operation( const witness_object& current_
|
|||
bytes key(secret.data(), secret.data() + secret.data_size());
|
||||
|
||||
auto vins = op.vins;
|
||||
if( op.pw_vin.str().compare( 0, 24, SIDECHAIN_NULL_VIN_IDENTIFIER ) != 0 ) {
|
||||
const auto& pw_vout = pw_vout_manager.get_vout( op.pw_vin );
|
||||
info_for_vin vin;
|
||||
vin.out = pw_vout->vout;
|
||||
vin.address = get_latest_PW().address.get_address();
|
||||
vin.identifier = pw_vout->hash_id;
|
||||
vins.insert( vins.begin(), vin );
|
||||
if( op.pw_vin.identifier.str().compare( 0, 48, SIDECHAIN_NULL_VIN_IDENTIFIER ) != 0 ) {
|
||||
vins.insert( vins.begin(), op.pw_vin );
|
||||
}
|
||||
|
||||
std::vector<bytes> redeem_scripts( i_w_info.get_redeem_scripts( vins ) );
|
||||
|
|
@ -266,8 +261,8 @@ void database::roll_back_vin_and_vout( const proposal_object& proposal )
|
|||
{
|
||||
bitcoin_transaction_send_operation op = proposal.proposed_transaction.operations.back().get<bitcoin_transaction_send_operation>();
|
||||
|
||||
if( pw_vout_manager.get_vout( op.pw_vin ).valid() ) {
|
||||
pw_vout_manager.mark_as_unused_vout( op.pw_vin );
|
||||
if( pw_vout_manager.get_vout( op.pw_vin.identifier ).valid() ) {
|
||||
pw_vout_manager.mark_as_unused_vout( op.pw_vin.identifier );
|
||||
}
|
||||
|
||||
for( const auto& vin : op.vins ) {
|
||||
|
|
|
|||
|
|
@ -558,6 +558,8 @@ namespace graphene { namespace chain {
|
|||
|
||||
secp256k1_context_t* context_verify;
|
||||
|
||||
bool send_btc_tx_flag = true;
|
||||
|
||||
private:
|
||||
|
||||
vector< processed_transaction > _pending_tx;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace graphene { namespace chain {
|
|||
asset fee;
|
||||
account_id_type payer;
|
||||
|
||||
fc::sha256 pw_vin;
|
||||
sidechain::info_for_vin pw_vin;
|
||||
std::vector< sidechain::info_for_vin > vins;
|
||||
std::vector< info_for_vout_id_type > vouts;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ namespace graphene { namespace chain {
|
|||
|
||||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT( graphene::chain::bitcoin_issue_operation::fee_parameters_type, (fee)(price_per_kbyte) )
|
||||
FC_REFLECT( graphene::chain::bitcoin_issue_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT( graphene::chain::bitcoin_issue_operation, (fee)(payer)(transaction_id) )
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ void sidechain_hardfork_visitor::operator()( const bitcoin_transaction_send_oper
|
|||
db.i_w_info.mark_as_used_vout( *obj );
|
||||
}
|
||||
|
||||
db.pw_vout_manager.mark_as_used_vout( v.pw_vin );
|
||||
db.pw_vout_manager.mark_as_used_vout( v.pw_vin.identifier );
|
||||
}
|
||||
|
||||
void_result proposal_create_evaluator::do_evaluate(const proposal_create_operation& o)
|
||||
|
|
|
|||
Loading…
Reference in a new issue