diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 18d97672..6dadd4cf 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -2698,6 +2698,7 @@ bool blockchain_storage::get_target_outs_for_amount_prezarcanum(const COMMAND_RP if (up_index_limit >= decoys_count) { std::set used; + used.insert(details.own_global_index); size_t try_count = 0; for (uint64_t j = 0; j != decoys_count && try_count < up_index_limit;) { @@ -2729,6 +2730,7 @@ bool blockchain_storage::get_target_outs_for_amount_prezarcanum(const COMMAND_RP bool blockchain_storage::get_target_outs_for_postzarcanum(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS2::request& req, const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS2::offsets_distribution& details, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount& result_outs, std::map& amounts_to_up_index_limit_cache) const { std::set used; + used.insert(details.own_global_index); for (auto offset : details.offsets) { diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 99995bbd..6cca2e5c 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -430,10 +430,12 @@ namespace currency { uint64_t amount; //if amount is 0 then lookup in post-zarcanum zone only, if not 0 then pre-zarcanum only std::vector offsets; //[i] = height, estimated location where to pickup output of transaction + uint64_t own_global_index; //index to exclude from selection BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(amount) KV_SERIALIZE(offsets) + KV_SERIALIZE(own_global_index) END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 2a1ce542..ec20b07b 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -708,7 +708,8 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t if (ptc.coin_base_tx) { //last out in coinbase tx supposed to be change from coinstake - if (!(o == tx.vout.size() - 1 && !ptc.is_derived_from_coinbase)) // TODO: @#@# reconsider this condition + //for genesis block we'll count every input as WALLET_TRANSFER_DETAIL_FLAG_MINED_TRANSFER + if (td.m_ptx_wallet_info->m_block_height == 0 || !(o == tx.vout.size() - 1 && !ptc.is_derived_from_coinbase)) // TODO: @#@# reconsider this condition { td.m_flags |= WALLET_TRANSFER_DETAIL_FLAG_MINED_TRANSFER; } @@ -3348,7 +3349,16 @@ bool wallet2::balance(std::unordered_mapm_block_height == 0) + { + //for genesis block we add actual amounts + mined += td.amount(); + } + else { + mined += CURRENCY_BLOCK_REWARD; //this code would work only for cases where block reward is full. For reduced block rewards might need more flexible code (TODO) + } + } } } @@ -5905,6 +5915,7 @@ bool wallet2::prepare_tx_sources(size_t fake_outputs_count, std::vectoraccept_ionic_swap_proposal(proposal, tx_is);