14 static std::default_random_engine RND(crypto::rand<unsigned>());
19 wallet->m_account = account;
23 wallet->m_watch_only =
false;
24 wallet->m_multisig =
false;
25 wallet->m_multisig_threshold = 0;
26 wallet->m_multisig_signers.clear();
29 wallet->m_subaddress_lookahead_major = 5;
30 wallet->m_subaddress_lookahead_minor = 20;
32 wallet->setup_new_blockchain();
37 wallet->process_parsed_blocks(start_height,
blocks, parsed_blocks, blocks_added);
43 std::vector<const cryptonote::block*> blockchain;
50 process_transactions(wallet, blockchain, mtx, bt);
55 uint64_t start_height=0, blocks_added=0;
56 std::vector<cryptonote::block_complete_entry> v_bche;
57 std::vector<tools::wallet2::parsed_block> v_parsed_block;
59 v_bche.reserve(blockchain.size());
60 v_parsed_block.reserve(blockchain.size());
63 for(
auto bl : blockchain)
67 v_bche.emplace_back();
68 v_parsed_block.emplace_back();
77 bool wallet_tools::fill_tx_sources(
tools::wallet2 * wallet, std::vector<cryptonote::tx_source_entry>& sources,
size_t mixin,
const boost::optional<size_t>& num_utxo,
const boost::optional<uint64_t>& min_amount,
block_tracker &bt, std::vector<size_t> &selected,
uint64_t cur_height, ssize_t offset,
int step,
const boost::optional<fnc_accept_tx_source_t>& fnc_accept)
83 std::unordered_set<size_t> selected_idx;
84 std::unordered_set<crypto::key_image> selected_kis;
86 size_t roffset = offset >= 0 ? offset : ntrans - offset - 1;
91 unsigned brk_cond = 0;
92 unsigned brk_thresh = num_utxo && min_amount ? 2 : (num_utxo || min_amount ? 1 : 0);
94 #define EVAL_BRK_COND() do { \ 96 if (num_utxo && num_utxo.get() <= cur_utxo) \ 98 if (min_amount && min_amount.get() <= sum) \ 102 for(ssize_t i = roffset; iters < ntrans && !abort; i += step, ++iters)
105 if (brk_cond >= brk_thresh)
108 i = i < 0 ? (i + ntrans) : i % ntrans;
109 auto & td = transfers[i];
114 if (selected_idx.find((
size_t)i) != selected_idx.end()){
115 MERROR(
"Should not happen (selected_idx not found): " << i);
118 if (selected_kis.find(td.m_key_image) != selected_kis.end()){
119 MERROR(
"Should not happen (selected KI): " << i <<
"ki: " <<
dump_keys(td.m_key_image.data));
130 .ntrans=ntrans, .iters=iters, .sum=sum, .cur_utxo=cur_utxo};
132 bool take_it = (fnc_accept.get())(c_info, abort);
139 <<
" ki: " <<
dump_keys(td.m_key_image.data)
140 <<
" amnt: " << td.amount()
141 <<
" rct: " << td.is_rct()
142 <<
" glob: " << td.m_global_output_index);
147 sources.emplace_back(src);
148 selected.push_back((
size_t)i);
149 selected_idx.insert((
size_t)i);
150 selected_kis.insert(td.m_key_image);
152 }
catch(
const std::exception &e){
154 <<
", amnt: " << td.amount() <<
", rct: " << td.is_rct()
155 <<
", glob: " << td.m_global_output_index <<
" is not applicable: " << e.what());
160 return brk_cond >= brk_thresh;
169 std::vector<tools::wallet2::get_outs_entry> outs;
172 for (
size_t n = 0; n < mixin; ++n)
175 oe.first = std::get<0>(outs[n]);
176 oe.second.dest = rct::pk2rct(std::get<1>(outs[n]));
177 oe.second.mask = std::get<2>(outs[n]);
181 size_t real_idx = crypto::rand<size_t>() % mixin;
189 return i0.first < i1.first;
192 for (
size_t i = 0; i < src.
outputs.size(); ++i){
208 vector<const transaction*> vtx;
213 const map_hash2tx_t::const_iterator cit = mtx.find(h);
215 vtx.push_back(cit->second);
221 parsed_block.
error =
false;
223 parsed_block.
block = *bl;
227 o_indices.reserve(bl->
tx_hashes.size() + 1);
232 o_indices.emplace_back();
237 parsed_block.
txes.push_back(*tx);
244 const std::vector<crypto::public_key> pkeys = hwdev.get_subaddress_spend_public_keys(creds.
get_keys(), account, 0, minors);
246 for(
uint32_t c = 0; c < pkeys.size(); ++c){
248 subaddresses[pkeys[c]] = sidx;
254 return (
inp)->get_account().get_keys().m_account_address;
259 std::vector<cryptonote::tx_source_entry> &sources,
262 vector<tx_destination_entry> destinations;
264 return construct_tx_rct(sender_wallet, sources, destinations,
get_address(sender_wallet), std::vector<uint8_t>(), tx, 0,
rct, range_proof_type, bp_version);
269 const std::vector<cryptonote::tx_destination_entry>& destinations,
270 std::vector<cryptonote::tx_source_entry> &sources,
273 vector<tx_destination_entry> all_destinations;
275 return construct_tx_rct(sender_wallet, sources, all_destinations,
get_address(sender_wallet), std::vector<uint8_t>(), tx, 0,
rct, range_proof_type, bp_version);
282 std::vector<crypto::secret_key> additional_tx_keys;
283 std::vector<tx_destination_entry> destinations_copy = destinations;
285 return construct_tx_and_get_tx_key(sender_wallet->
get_account().
get_keys(), subaddresses, sources, destinations_copy, change_addr, extra, tx, unlock_time, tx_key, additional_tx_keys,
rct, rct_config,
nullptr);
virtual device_type get_type() const =0
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
std::vector< crypto::hash > tx_hashes
crypto::public_key real_out_tx_key
void global_indices(const cryptonote::transaction *tx, std::vector< uint64_t > &indices)
static void process_parsed_blocks(tools::wallet2 *wallet, uint64_t start_height, const std::vector< cryptonote::block_complete_entry > &blocks, const std::vector< tools::wallet2::parsed_block > &parsed_blocks, uint64_t &blocks_added)
static subaddresses_t & get_subaddresses(tools::wallet2 *wallet)
static void set_account(tools::wallet2 *wallet, cryptonote::account_base &account)
bool find_block_chain(const std::vector< test_event_entry > &events, std::vector< cryptonote::block > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
key commit(etn_amount amount, const key &mask)
std::unordered_map< crypto::public_key, cryptonote::subaddress_index > subaddresses_t
std::vector< blobdata > txs
void get_fake_outs(size_t num_outs, uint64_t amount, uint64_t global_index, uint64_t cur_height, std::vector< get_outs_entry > &outs)
boost::variant< cryptonote::account_public_address, cryptonote::account_keys, cryptonote::account_base, cryptonote::tx_destination_entry > var_addr_t
const account_keys & get_keys() const
std::vector< tx_out > vout
Holds cryptonote related classes and helpers.
bool trim_block_chain(std::vector< cryptonote::block > &blockchain, const crypto::hash &tail)
std::vector< txin_v > vin
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
hw::device & get_device() const
void fill_tx_destinations(const var_addr_t &from, const std::vector< tx_destination_entry > &dests, uint64_t fee, const std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, bool always_change)
device & get_device(const std::string &device_descriptor)
unsigned __int64 uint64_t
crypto::public_key get_tx_pub_key_from_extra(const std::vector< uint8_t > &tx_extra, size_t pk_index)
rct::multisig_kLRki multisig_kLRki
account_public_address m_account_address
std::vector< crypto::public_key > real_out_additional_tx_keys
std::vector< tx_output_indices > indices
size_t real_output_in_tx_index
tools::wallet2::transfer_details * td
void process(const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
std::vector< output_entry > outputs
crypto::hash get_block_hash(uint64_t height)
std::pair< uint64_t, rct::ctkey > output_entry
std::vector< crypto::public_key > get_additional_tx_pub_keys_from_extra(const std::vector< uint8_t > &tx_extra)
std::string dump_keys(T *buff32)
bool construct_tx_and_get_tx_key(const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys, bool rct, const rct::RCTConfig &rct_config, rct::multisig_out *msout, const uint32_t account_major_offset, const cryptonote::network_type nettype)
static tools::wallet2::transfer_container & get_transfers(tools::wallet2 *wallet)
virtual const std::string get_name() const =0