1
0
Fork 0
forked from lthn/blockchain

fixed counterparty_address load from transaction details

This commit is contained in:
cryptozoidberg 2021-03-26 00:43:50 +03:00
parent 18ef9b12ec
commit ffd1ecdcff
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
5 changed files with 34 additions and 2 deletions

View file

@ -285,6 +285,7 @@ namespace currency
std::string short_hash_str(const crypto::hash& h);
bool is_mixattr_applicable_for_fake_outs_counter(uint8_t mix_attr, uint64_t fake_attr_count);
bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t current_blockchain_size, uint64_t current_time);
crypto::key_derivation get_encryption_key_derivation(bool is_income, const transaction& tx, const account_keys& acc_keys);
bool decrypt_payload_items(bool is_income, const transaction& tx, const account_keys& acc_keys, std::vector<payload_items_v>& decrypted_items);
void encrypt_attachments(transaction& tx, const account_keys& sender_keys, const account_public_address& destination_addr, const keypair& tx_random_key);
bool is_derivation_used_to_encrypt(const transaction& tx, const crypto::key_derivation& derivation);

View file

@ -595,6 +595,23 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t
auto amount_gindex_pair = std::make_pair(amount, td.m_global_output_index);
m_active_htlcs[amount_gindex_pair] = transfer_index;
m_active_htlcs_txid[get_transaction_hash(tx)] = transfer_index;
//add payer to extra options
currency::tx_payer payer = AUTO_VAL_INIT(payer);
if (het.is_wallet_owns_redeem)
{
if (currency::get_type_in_variant_container(tx.extra, payer))
{
crypto::chacha_crypt(payer.acc_addr, derivation);
td.varian_options.push_back(payer);
}
}
else
{
//since this is refund-mode htlc out, then sender is this wallet itself
payer.acc_addr = m_account.get_public_address();
td.varian_options.push_back(payer);
}
}
if (td.m_key_image != currency::null_ki)
m_key_images[td.m_key_image] = transfer_index;
@ -4144,7 +4161,7 @@ void wallet2::get_list_of_active_htlc(std::list<wallet_public::htlc_entry_info>&
entry.sha256_hash = htlc.htlc_hash;
currency::tx_payer payer = AUTO_VAL_INIT(payer);
if (currency::get_type_in_variant_container(td.m_ptx_wallet_info->m_tx.extra, payer))
if (currency::get_type_in_variant_container(td.varian_options, payer))
entry.counterparty_address = payer.acc_addr;
entry.is_redeem = td.m_flags&WALLET_TRANSFER_DETAIL_FLAG_HTLC_REDEEM ? true : false;
@ -5260,6 +5277,11 @@ void wallet2::transfer(construct_tx_param& ctp,
check_and_throw_if_self_directed_tx_with_payment_id_requested(ctp);
if (ctp.crypt_address.spend_public_key == currency::null_pkey)
{
ctp.crypt_address = currency::get_crypt_address_from_destinations(m_account.get_keys(), ctp.dsts);
}
TIME_MEASURE_START(prepare_transaction_time);
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
prepare_transaction(ctp, ftp);

View file

@ -403,7 +403,8 @@ namespace tools
crypto::hash redeem_tx_id;
};
typedef boost::variant<transfer_details_extra_option_htlc_info> transfer_details_extra_options_v;
typedef boost::variant<transfer_details_extra_option_htlc_info, currency::tx_payer> transfer_details_extra_options_v;
struct transfer_details : public transfer_details_base
{

View file

@ -15,6 +15,7 @@ using namespace currency;
#define INIT_RUNTIME_WALLET(instance_name) \
currency::account_base instance_name##acc_base; \
instance_name##acc_base.generate(); \
instance_name##acc_base.set_createtime(m_genesis_timestamp); \
LOG_PRINT_MAGENTA(": " << currency::get_account_address_as_str(instance_name##acc_base.get_public_address()), LOG_LEVEL_0); \
std::shared_ptr<tools::wallet2> instance_name = init_playtime_test_wallet(events, c, instance_name##acc_base);
@ -42,11 +43,17 @@ atomic_base_test::atomic_base_test()
bool atomic_base_test::generate(std::vector<test_event_entry>& events) const
{
random_state_test_restorer::reset_random(0); // to make the test deterministic
m_genesis_timestamp = 1450000000;
test_core_time::adjust(m_genesis_timestamp);
epee::debug::get_set_enable_assert(true, true);
currency::account_base genesis_acc;
genesis_acc.generate();
m_mining_accunt.generate();
m_mining_accunt.set_createtime(m_genesis_timestamp);
block blk_0 = AUTO_VAL_INIT(blk_0);

View file

@ -14,6 +14,7 @@ struct atomic_base_test : public wallet_test
virtual bool c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)=0;
bool configure_core(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
protected:
mutable uint64_t m_genesis_timestamp;
mutable currency::account_base m_mining_accunt;
};