diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index abe217ab..26f6554d 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -609,6 +609,25 @@ namespace currency } } //--------------------------------------------------------------- + template + void create_and_add_tx_receiver_to_container_from_address(container_t& container, const account_public_address& addr, uint64_t top_block_height, const core_runtime_config& crc) + { + if (top_block_height > crc.hard_fork_02_starts_after_height) + { + // after hardfork 2 + tx_receiver result = AUTO_VAL_INIT(result); + result.acc_addr = addr; + container.push_back(result); + } + else + { + // before hardfork 2 + tx_receiver_old result = AUTO_VAL_INIT(result); + result.acc_addr = addr.to_old(); + container.push_back(result); + } + } + //--------------------------------------------------------------- //--------------------------------------------------------------- std::ostream& operator <<(std::ostream& o, const ref_by_id& r); //--------------------------------------------------------------- diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 9033d590..757d862f 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -480,9 +480,15 @@ void wallet2::prepare_wti_decrypted_attachments(wallet_public::wallet_transfer_i else { //TODO: actually recipients could be more then one, handle it in future - tx_receiver tr = AUTO_VAL_INIT(tr); - if (!wti.remote_addresses.size() && get_type_in_variant_container(decrypted_att, tr)) - wti.remote_addresses.push_back(currency::get_account_address_as_str(tr.acc_addr)); + //tx_receiver tr = AUTO_VAL_INIT(tr); + //if (!wti.remote_addresses.size() && get_type_in_variant_container(decrypted_att, tr)) + // wti.remote_addresses.push_back(currency::get_account_address_as_str(tr.acc_addr)); + + account_public_address receiver_address = AUTO_VAL_INIT(receiver_address); + handle_2_alternative_types_in_variant_container(decrypted_att, [&](const tx_payer& p) { + wti.remote_addresses.push_back(currency::get_account_address_as_str(p.acc_addr)); + return true; // continue iterating through the container + }); } currency::tx_comment cm; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index a90ae5a7..70dfd113 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -294,16 +294,13 @@ namespace tools { currency::create_and_add_tx_payer_to_container_from_address(extra, m_wallet.get_account().get_keys().account_address, m_wallet.get_top_block_height(), m_wallet.get_core_runtime_config()); } + if (!req.hide_receiver) { for (auto& d : dsts) { for (auto& a : d.addr) - { - currency::tx_receiver txr = AUTO_VAL_INIT(txr); - txr.acc_addr = a; - extra.push_back(txr); - } + currency::create_and_add_tx_receiver_to_container_from_address(extra, a, m_wallet.get_top_block_height(), m_wallet.get_core_runtime_config()); } } diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 21f06c89..4e6c92e3 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1207,11 +1207,7 @@ std::string wallets_manager::transfer(size_t wallet_id, const view::transfer_par for (auto& d : dsts) { for (auto& a : d.addr) - { - currency::tx_receiver txr = AUTO_VAL_INIT(txr); - txr.acc_addr = a; - extra.push_back(txr); - } + currency::create_and_add_tx_receiver_to_container_from_address(extra, a, w->get()->get_top_block_height(), w->get()->get_core_runtime_config()); } } w->get()->transfer(dsts, tp.mixin_count, unlock_time ? unlock_time + 1 : 0, fee, extra, attachments, res_tx);