1
0
Fork 0
forked from lthn/blockchain

fixed issues with wallet

This commit is contained in:
cryptozoidberg 2024-01-18 18:27:35 +01:00
parent 36ce7bd00d
commit d8241d1531
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
4 changed files with 20 additions and 3 deletions

View file

@ -2698,6 +2698,7 @@ bool blockchain_storage::get_target_outs_for_amount_prezarcanum(const COMMAND_RP
if (up_index_limit >= decoys_count)
{
std::set<size_t> 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<uint64_t, uint64_t>& amounts_to_up_index_limit_cache) const
{
std::set<uint64_t> used;
used.insert(details.own_global_index);
for (auto offset : details.offsets)
{

View file

@ -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<uint64_t> 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()
};

View file

@ -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_map<crypto::public_key, wallet_public::asse
if (is_transfer_unlocked(td))
e.unlocked += td.amount();
if (td.m_flags & WALLET_TRANSFER_DETAIL_FLAG_MINED_TRANSFER)
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)
{
if (td.m_ptx_wallet_info->m_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::vector<currency
"m_internal_output_index = " << it->m_internal_output_index <<
" is greater or equal to outputs count = " << it->m_ptx_wallet_info->m_tx.vout.size());
rdisttib.own_global_index = it->m_global_output_index;
//check if we have Zarcanum era output of pre-Zarcanum
if (it->is_zc())
{

View file

@ -399,7 +399,9 @@ bool ionic_swap_exact_amounts_test::c1(currency::core& c, size_t ev_index, const
proposal_decoded_info.to_initiator == proposal_details.to_initiator &&
proposal_decoded_info.fee_paid_by_a == proposal_details.fee_paid_by_a &&
proposal_decoded_info.mixins == proposal_details.mixins,
false, "actual and decoded proposal mismatch");
false, "actual and decoded proposal mismatch \nproposal_decoded_info: "
<< epee::serialization::store_t_to_json(proposal_decoded_info) <<
"\nproposal_details" << epee::serialization::store_t_to_json(proposal_details));
currency::transaction tx_is{};
r = bob_wlt->accept_ionic_swap_proposal(proposal, tx_is);