diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 42ba6942..6474307d 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -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& 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); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 6b0baf21..9c8c9c33 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -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& 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); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 9821567f..f1ab885e 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -403,7 +403,8 @@ namespace tools crypto::hash redeem_tx_id; }; - typedef boost::variant transfer_details_extra_options_v; + + typedef boost::variant transfer_details_extra_options_v; struct transfer_details : public transfer_details_base { diff --git a/tests/core_tests/atomic_tests.cpp b/tests/core_tests/atomic_tests.cpp index 1c3f4fcd..5fd46d84 100644 --- a/tests/core_tests/atomic_tests.cpp +++ b/tests/core_tests/atomic_tests.cpp @@ -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 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& 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); diff --git a/tests/core_tests/atomic_tests.h b/tests/core_tests/atomic_tests.h index a04929ed..c2c8550a 100644 --- a/tests/core_tests/atomic_tests.h +++ b/tests/core_tests/atomic_tests.h @@ -14,6 +14,7 @@ struct atomic_base_test : public wallet_test virtual bool c1(currency::core& c, size_t ev_index, const std::vector& events)=0; bool configure_core(currency::core& c, size_t ev_index, const std::vector& events); protected: + mutable uint64_t m_genesis_timestamp; mutable currency::account_base m_mining_accunt; };