diff --git a/libraries/chain/asset_object.cpp b/libraries/chain/asset_object.cpp index 288d7db9..f357e541 100644 --- a/libraries/chain/asset_object.cpp +++ b/libraries/chain/asset_object.cpp @@ -197,18 +197,21 @@ vector asset_object::get_ticket_ids( database& db ) const { const auto& stats = bal.owner(db).statistics(db); const account_transaction_history_object* ath = static_cast(&stats.most_recent_op(db)); - for( uint64_t balance = bal.balance.value; balance > 0; --balance) + for( uint64_t balance = bal.balance.value; balance > 0;) { if(ath != nullptr) { const operation_history_object& oho = db.get( ath->operation_id ); - if( oho.op.which() == operation::tag::value ) - ids.push_back( oho.id.instance()); + if( oho.op.which() == operation::tag::value && get_id() == oho.op.get().lottery) + { + uint64_t tickets_count = oho.op.get().tickets_to_buy; + ids.insert(ids.end(), tickets_count, oho.id.instance()); + balance -= tickets_count; + assert(balance >= 0); + } if( ath->next == account_transaction_history_id_type() ) { - if(balance > 1 && oho.op.which() == operation::tag::value) - ids.insert(ids.end(), balance-1, oho.id.instance()); ath = nullptr; break; }