Fixed fee bug and bug with info_for_vout
This commit is contained in:
parent
40e13800f2
commit
f6c2e8c92d
7 changed files with 18 additions and 15 deletions
|
|
@ -39,7 +39,6 @@ object_id_type bitcoin_transaction_send_evaluator::do_apply( const bitcoin_trans
|
|||
obj.transaction = mutable_op.transaction;
|
||||
obj.transaction_id = mutable_op.transaction.get_txid();
|
||||
obj.fee_for_size = mutable_op.fee_for_size;
|
||||
obj.confirm = false;
|
||||
});
|
||||
|
||||
sidechain::prev_out new_pw_vout = { "", 0, 0 };
|
||||
|
|
|
|||
|
|
@ -296,7 +296,6 @@ void database::roll_back_vin_and_vout( const proposal_object& proposal )
|
|||
fc::optional<operation> database::create_bitcoin_issue_proposals( const witness_object& current_witness )
|
||||
{
|
||||
std::vector<fc::sha256> trx_ids;
|
||||
|
||||
bitcoin_confirmations.safe_for<by_confirmed_and_not_used>([&]( btc_tx_confirmations_index::index<by_confirmed_and_not_used>::type::iterator itr_b, btc_tx_confirmations_index::index<by_confirmed_and_not_used>::type::iterator itr_e ){
|
||||
for(auto iter = itr_b; iter != itr_e; iter++) {
|
||||
if( !iter->is_confirmed_and_not_used() ) return;
|
||||
|
|
@ -304,7 +303,6 @@ fc::optional<operation> database::create_bitcoin_issue_proposals( const witness_
|
|||
const auto& btc_trx_idx = get_index_type<bitcoin_transaction_index>().indices().get<by_transaction_id>();
|
||||
const auto& btc_tx = btc_trx_idx.find( iter->transaction_id );
|
||||
if( btc_tx == btc_trx_idx.end() ) continue;
|
||||
|
||||
trx_ids.push_back( iter->transaction_id );
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ class bitcoin_transaction_object : public abstract_object<bitcoin_transaction_ob
|
|||
fc::sha256 transaction_id;
|
||||
|
||||
uint64_t fee_for_size;
|
||||
|
||||
bool confirm = false;
|
||||
};
|
||||
|
||||
struct by_transaction_id;
|
||||
|
|
@ -40,4 +38,4 @@ typedef generic_index<bitcoin_transaction_object, bitcoin_transaction_multi_inde
|
|||
|
||||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT_DERIVED( graphene::chain::bitcoin_transaction_object, (graphene::chain::object), (pw_vin)(vins)(vouts)(transaction)(transaction_id)(fee_for_size)(confirm) )
|
||||
FC_REFLECT_DERIVED( graphene::chain::bitcoin_transaction_object, (graphene::chain::object), (pw_vin)(vins)(vouts)(transaction)(transaction_id)(fee_for_size) )
|
||||
|
|
|
|||
|
|
@ -543,7 +543,6 @@ namespace graphene { namespace chain {
|
|||
|
||||
void roll_back_vin_and_vout( const proposal_object& proposal );
|
||||
|
||||
|
||||
fc::optional<operation> create_bitcoin_issue_proposals( const witness_object& current_witness );
|
||||
|
||||
fc::signal<void( const bitcoin_transaction& )> send_btc_tx;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,18 @@ struct bitcoin_transaction_confirmations
|
|||
{
|
||||
bitcoin_transaction_confirmations() = default;
|
||||
|
||||
bitcoin_transaction_confirmations( fc::sha256 trx_id ) : transaction_id( trx_id ) {}
|
||||
bitcoin_transaction_confirmations( fc::sha256 trx_id ) : id( count_id_tx_conf++ ), transaction_id( trx_id ) {}
|
||||
|
||||
struct comparer {
|
||||
bool operator()( const bitcoin_transaction_confirmations& lhs, const bitcoin_transaction_confirmations& rhs ) const {
|
||||
if( lhs.is_confirmed_and_not_used() != rhs.is_confirmed_and_not_used() )
|
||||
return lhs.is_confirmed_and_not_used() < rhs.is_confirmed_and_not_used();
|
||||
return lhs.id < rhs.id;
|
||||
}
|
||||
};
|
||||
|
||||
static uint64_t count_id_tx_conf;
|
||||
uint64_t id;
|
||||
|
||||
bool is_confirmed_and_not_used() const { return !used && confirmed; }
|
||||
|
||||
|
|
@ -37,7 +48,7 @@ struct by_confirmed_and_not_used;
|
|||
|
||||
using btc_tx_confirmations_index = boost::multi_index_container<bitcoin_transaction_confirmations,
|
||||
indexed_by<
|
||||
ordered_unique<tag<by_hash>, member<bitcoin_transaction_confirmations, fc::sha256, &bitcoin_transaction_confirmations::transaction_id>>,
|
||||
ordered_unique<tag<by_hash>, member<bitcoin_transaction_confirmations, fc::sha256, &bitcoin_transaction_confirmations::transaction_id>>,
|
||||
ordered_non_unique<tag<by_confirmed_and_not_used>, const_mem_fun< bitcoin_transaction_confirmations, bool, &bitcoin_transaction_confirmations::is_confirmed_and_not_used >>
|
||||
>
|
||||
>;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@
|
|||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/primary_wallet_vout_object.hpp>
|
||||
#include <graphene/chain/bitcoin_address_object.hpp>
|
||||
#include <sidechain/bitcoin_transaction_confirmations.hpp>
|
||||
|
||||
namespace sidechain {
|
||||
|
||||
uint64_t info_for_vin::count_id_info_for_vin = 0;
|
||||
uint64_t bitcoin_transaction_confirmations::count_id_tx_conf = 0;
|
||||
|
||||
bool info_for_vin::comparer::operator() ( const info_for_vin& lhs, const info_for_vin& rhs ) const
|
||||
{
|
||||
|
|
@ -173,12 +175,8 @@ std::vector<info_for_vout> input_withdrawal_info::get_info_for_vouts()
|
|||
const auto& info_for_vout_idx = db.get_index_type<graphene::chain::info_for_vout_index>().indices().get< graphene::chain::by_id_and_not_used >();
|
||||
auto itr = info_for_vout_idx.begin();
|
||||
for(size_t i = 0; i < 5 && itr != info_for_vout_idx.end() && !itr->used; i++) {
|
||||
info_for_vout vout;
|
||||
vout.payer = itr->payer;
|
||||
vout.address = itr->address;
|
||||
vout.amount = itr->amount;
|
||||
|
||||
result.push_back( vout );
|
||||
result.push_back( *itr );
|
||||
++itr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ void sidechain_condensing_tx::subtract_fee( const uint64_t& fee, const double& w
|
|||
size_t limit = is_pw_vin ? 1 + count_witness_vout : count_witness_vout;
|
||||
size_t offset = is_pw_vin ? 1 : 0;
|
||||
FC_ASSERT( fee_witness > 0 );
|
||||
for( offset = 0; offset < limit; offset++ ) {
|
||||
for( ; offset < limit; offset++ ) {
|
||||
tx.vout[offset].value += fee_witness;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue