diff --git a/src/currency_core/currency_format_utils_transactions.h b/src/currency_core/currency_format_utils_transactions.h index d678cc38..ce24c2cd 100644 --- a/src/currency_core/currency_format_utils_transactions.h +++ b/src/currency_core/currency_format_utils_transactions.h @@ -76,8 +76,8 @@ namespace currency //if this struct is present, then creating htlc out, expiration -> number of blocks that htlc proposal is active struct destination_option_htlc_out { - uint64_t expiration; - crypto::hash htlc_hash; + uint64_t expiration = 0; + crypto::hash htlc_hash = crypto::null_hash; BEGIN_SERIALIZE_OBJECT() FIELD(expiration) @@ -90,16 +90,17 @@ namespace currency { uint64_t amount; //money std::list addr; //destination address, in case of 1 address - txout_to_key, in case of more - txout_multisig - size_t minimum_sigs; //if txout_multisig: minimum signatures that are required to spend this output (minimum_sigs <= addr.size()) IF txout_to_key - not used - uint64_t amount_to_provide; //amount money that provided by initial creator of tx, used with partially created transactions - uint64_t unlock_time; - destination_option_htlc_out htlc_options; //htlc options + size_t minimum_sigs = 0; //if txout_multisig: minimum signatures that are required to spend this output (minimum_sigs <= addr.size()) IF txout_to_key - not used + uint64_t amount_to_provide = 0; //amount money that provided by initial creator of tx, used with partially created transactions + uint64_t unlock_time = 0; + destination_option_htlc_out htlc_options; //htlc options + crypto::hash asset_id = crypto::null_hash; - tx_destination_entry() : amount(0), minimum_sigs(0), amount_to_provide(0), unlock_time(0), htlc_options(destination_option_htlc_out()){} - tx_destination_entry(uint64_t a, const account_public_address& ad) : amount(a), addr(1, ad), minimum_sigs(0), amount_to_provide(0), unlock_time(0), htlc_options(destination_option_htlc_out()) {} - tx_destination_entry(uint64_t a, const account_public_address& ad, uint64_t ut) : amount(a), addr(1, ad), minimum_sigs(0), amount_to_provide(0), unlock_time(ut), htlc_options(destination_option_htlc_out()) {} - tx_destination_entry(uint64_t a, const std::list& addr) : amount(a), addr(addr), minimum_sigs(addr.size()), amount_to_provide(0), unlock_time(0), htlc_options(destination_option_htlc_out()) {} + tx_destination_entry() = default; + tx_destination_entry(uint64_t a, const account_public_address& ad) : amount(a), addr(1, ad) {} + tx_destination_entry(uint64_t a, const account_public_address& ad, uint64_t ut) : amount(a), addr(1, ad), unlock_time(ut) {} + tx_destination_entry(uint64_t a, const std::list& addr) : amount(a), addr(addr), minimum_sigs(addr.size()) {} BEGIN_SERIALIZE_OBJECT() FIELD(amount) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 83e62a3d..93aedc1e 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -4894,9 +4894,10 @@ bool wallet2::prepare_tx_sources_htlc(crypto::hash htlc_tx_id, const std::string } //---------------------------------------------------------------------------------------------------------------- -uint64_t wallet2::get_needed_money(uint64_t fee, const std::vector& dsts) +std::unordered_map&& wallet2::get_needed_money(uint64_t fee, const std::vector& dsts) { - uint64_t needed_money = fee; + std::unordered_map amounts_map; + amounts_map[currency::null_hash] = fee; BOOST_FOREACH(auto& dt, dsts) { THROW_IF_TRUE_WALLET_EX(0 == dt.amount, error::zero_destination); @@ -4904,10 +4905,10 @@ uint64_t wallet2::get_needed_money(uint64_t fee, const std::vector needed_money_map; + uint64_t needed_money_map = get_needed_money(ctp.fee, ctp.dsts); if (ctp.flags & TX_FLAG_SIGNATURE_MODE_SEPARATE && tx_for_mode_separate.vout.size()) { WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(get_tx_flags(tx_for_mode_separate) & TX_FLAG_SIGNATURE_MODE_SEPARATE, "tx_param.flags differs from tx.flags"); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 277336a2..ffdf536b 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -295,53 +295,6 @@ namespace tools bool perform_packing = false; }; -// struct currency::finalize_tx_param -// { -// uint64_t unlock_time; -// std::vector extra; -// std::vector attachments; -// currency::account_public_address crypt_address; -// uint8_t tx_outs_attr; -// bool shuffle; -// uint8_t flags; -// crypto::hash multisig_id; -// std::vector sources; -// std::vector selected_transfers; -// std::vector prepared_destinations; -// -// crypto::public_key spend_pub_key; // only for validations -// -// BEGIN_SERIALIZE_OBJECT() -// FIELD(unlock_time) -// FIELD(extra) -// FIELD(attachments) -// FIELD(crypt_address) -// FIELD(tx_outs_attr) -// FIELD(shuffle) -// FIELD(flags) -// FIELD(multisig_id) -// FIELD(sources) -// FIELD(selected_transfers) -// FIELD(prepared_destinations) -// FIELD(spend_pub_key) -// END_SERIALIZE() -// }; -// -// struct currency::finalized_tx -// { -// currency::transaction tx; -// crypto::secret_key one_time_key; -// currency::finalize_tx_param ftp; -// std::vector> outs_key_images; // pairs (out_index, key_image) for each change output -// -// BEGIN_SERIALIZE_OBJECT() -// FIELD(tx) -// FIELD(one_time_key) -// FIELD(ftp) -// FIELD(outs_key_images) -// END_SERIALIZE() -// }; - class wallet2: public tools::tor::t_transport_state_notifier { @@ -1002,7 +955,7 @@ private: bool prepare_tx_sources_htlc(crypto::hash htlc_tx_id, const std::string& origin, std::vector& sources, uint64_t& found_money); bool prepare_tx_sources_for_packing(uint64_t items_to_pack, size_t fake_outputs_count, std::vector& sources, std::vector& selected_indicies, uint64_t& found_money); void prefetch_global_indicies_if_needed(std::vector& selected_indicies); - uint64_t get_needed_money(uint64_t fee, const std::vector& dsts); + std::unordered_map&& get_needed_money(uint64_t fee, const std::vector& dsts); void prepare_tx_destinations(uint64_t needed_money, uint64_t found_money, detail::split_strategy_id_t destination_split_strategy_id,