1
0
Fork 0
forked from lthn/blockchain

tx_receiver/tx_receiver_old proper handling

This commit is contained in:
sowle 2020-04-28 16:41:04 +03:00
parent d3ce73e7ac
commit 1afab184c8
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
4 changed files with 31 additions and 13 deletions

View file

@ -609,6 +609,25 @@ namespace currency
}
}
//---------------------------------------------------------------
template <typename container_t>
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);
//---------------------------------------------------------------

View file

@ -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<tx_receiver, tx_receiver_old>(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;

View file

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

View file

@ -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);