diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index e6e13d35..1e99085e 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3710,6 +3710,8 @@ uint64_t wallet2::balance(uint64_t& unlocked, uint64_t& awaiting_in, uint64_t& a awaiting_in = it->second.awaiting_in; awaiting_out = it->second.awaiting_out; } + if (asset_id != native_coin_asset_id) + mined = 0; return total; } //---------------------------------------------------------------------------------------------------- @@ -5836,8 +5838,10 @@ struct local_transfers_struct END_KV_SERIALIZE_MAP() }; -void wallet2::dump_trunsfers(std::stringstream& ss, bool verbose) const +void wallet2::dump_trunsfers(std::stringstream& ss, bool verbose, const crypto::public_key& asset_id) const { + bool filter_by_asset_id = asset_id != currency::null_pkey; + if (verbose) { @@ -5846,6 +5850,8 @@ void wallet2::dump_trunsfers(std::stringstream& ss, bool verbose) const { uint64_t i = tr.first; const transfer_details& td = tr.second; + if (filter_by_asset_id && td.get_asset_id() != asset_id) + continue; ss << "{ \"i\": " << i << "," << ENDL; ss << "\"entry\": " << epee::serialization::store_t_to_json(td) << "}," << ENDL; } @@ -5858,6 +5864,8 @@ void wallet2::dump_trunsfers(std::stringstream& ss, bool verbose) const { uint64_t i = tr.first; const transfer_details& td = tr.second; + if (filter_by_asset_id && td.get_asset_id() != asset_id) + continue; ss << std::right << std::setw(5) << i << " " << std::setw(21) << print_money(td.amount()) << " " << @@ -5873,10 +5881,10 @@ void wallet2::dump_trunsfers(std::stringstream& ss, bool verbose) const } } //---------------------------------------------------------------------------------------------------- -std::string wallet2::dump_trunsfers(bool verbose) const +std::string wallet2::dump_trunsfers(bool verbose, const crypto::public_key& asset_id) const { std::stringstream ss; - dump_trunsfers(ss, verbose); + dump_trunsfers(ss, verbose, asset_id); return ss.str(); } //---------------------------------------------------------------------------------------------------- diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index cc4d8f53..d5d3602b 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -681,8 +681,9 @@ namespace tools void accept_cancel_contract(const crypto::hash& contract_id, currency::transaction* p_cancellation_acceptance_tx = nullptr); void scan_tx_to_key_inputs(std::vector& found_transfers, const currency::transaction& tx); - void dump_trunsfers(std::stringstream& ss, bool verbose = true) const; - std::string dump_trunsfers(bool verbose = false) const; + // asset_id = null_pkey means no filtering by asset id + void dump_trunsfers(std::stringstream& ss, bool verbose = true, const crypto::public_key& asset_id = currency::null_pkey) const; + std::string dump_trunsfers(bool verbose = false, const crypto::public_key& asset_id = currency::null_pkey) const; void dump_key_images(std::stringstream& ss); void get_multisig_transfers(multisig_transfer_container& ms_transfers); const multisig_transfer_container& get_multisig_transfers() const { return m_multisig_transfers; } diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index 1c206717..a3e24069 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2024 Zano Project +// Copyright (c) 2014-2025 Zano Project // Copyright (c) 2014-2018 The Louisdor Project // Copyright (c) 2012-2013 The Cryptonote developers // Distributed under the MIT/X11 software license, see the accompanying @@ -2153,7 +2153,7 @@ bool check_balance_via_wallet(const tools::wallet2& w, const char* account_name, if (!r) { - LOG_PRINT(account_name << "'s transfers: " << ENDL << w.dump_trunsfers(), LOG_LEVEL_0); + LOG_PRINT(account_name << "'s transfers for asset_id " << asset_id << ": " << ENDL << w.dump_trunsfers(false, asset_id), LOG_LEVEL_0); } return r;