Electroneum
wallet_tools.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2018, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30 
31 #pragma once
32 
33 #include "chaingen.h"
34 #include "wallet/wallet2.h"
35 
36 typedef struct {
39 
40  std::unordered_set<size_t> * selected_idx;
41  std::unordered_set<crypto::key_image> * selected_kis;
42  size_t ntrans;
43  size_t iters;
45  size_t cur_utxo;
47 
48 typedef std::function<bool(const tx_source_info_crate_t &info, bool &abort)> fnc_accept_tx_source_t;
49 
50 // Wallet friend, direct access to required fields and private methods
52 {
53 public:
54  static void set_account(tools::wallet2 * wallet, cryptonote::account_base& account);
55  static tools::wallet2::transfer_container & get_transfers(tools::wallet2 * wallet) { return wallet->m_transfers; }
56  static subaddresses_t & get_subaddresses(tools::wallet2 * wallet) { return wallet->m_subaddresses; }
57  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);
58 };
59 
61 {
62 public:
63  static void gen_tx_src(size_t mixin, uint64_t cur_height, const tools::wallet2::transfer_details & td, cryptonote::tx_source_entry & src, block_tracker &bt);
65  static void compute_subaddresses(std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddresses, cryptonote::account_base & creds, size_t account, size_t minors);
66  static void process_transactions(tools::wallet2 * wallet, const std::vector<test_event_entry>& events, const cryptonote::block& blk_head, block_tracker &bt, const boost::optional<crypto::hash>& blk_tail=boost::none);
67  static void process_transactions(tools::wallet2 * wallet, const std::vector<const cryptonote::block*>& blockchain, const map_hash2tx_t & mtx, block_tracker &bt);
68  static bool 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=0, int step=1, const boost::optional<fnc_accept_tx_source_t>& fnc_accept=boost::none);
69 };
70 
72 
73 bool construct_tx_to_key(cryptonote::transaction& tx, tools::wallet2 * from_wallet, const var_addr_t& to, uint64_t amount,
74  std::vector<cryptonote::tx_source_entry> &sources,
75  uint64_t fee, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version = 0);
76 
77 bool construct_tx_to_key(cryptonote::transaction& tx, tools::wallet2 * sender_wallet, const std::vector<cryptonote::tx_destination_entry>& destinations,
78  std::vector<cryptonote::tx_source_entry> &sources,
79  uint64_t fee, bool rct, rct::RangeProofType range_proof_type, int bp_version = 0);
80 
81 bool construct_tx_rct(tools::wallet2 * sender_wallet,
82  std::vector<cryptonote::tx_source_entry>& sources,
83  const std::vector<cryptonote::tx_destination_entry>& destinations,
84  const boost::optional<cryptonote::account_public_address>& change_addr,
85  std::vector<uint8_t> extra, cryptonote::transaction& tx, uint64_t unlock_time,
86  bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version = 0);
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)
Definition: wallet_tools.h:56
static void set_account(tools::wallet2 *wallet, cryptonote::account_base &account)
std::unordered_map< crypto::public_key, cryptonote::subaddress_index > subaddresses_t
Definition: chaingen.h:359
uint64_t height
Definition: blockchain.cpp:91
bool construct_tx_to_key(cryptonote::transaction &tx, tools::wallet2 *from_wallet, const var_addr_t &to, uint64_t amount, std::vector< cryptonote::tx_source_entry > &sources, uint64_t fee, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)
boost::variant< cryptonote::account_public_address, cryptonote::account_keys, cryptonote::account_base, cryptonote::tx_destination_entry > var_addr_t
Definition: chaingen.h:362
cryptonote::account_public_address get_address(const tools::wallet2 *)
std::vector< transfer_details > transfer_container
Definition: wallet2.h:449
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition: chaingen.h:163
std::function< bool(const tx_source_info_crate_t &info, bool &abort)> fnc_accept_tx_source_t
Definition: wallet_tools.h:48
unsigned __int64 uint64_t
Definition: stdint.h:136
bool construct_tx_rct(tools::wallet2 *sender_wallet, std::vector< cryptonote::tx_source_entry > &sources, const std::vector< cryptonote::tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, std::vector< uint8_t > extra, cryptonote::transaction &tx, uint64_t unlock_time, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)
static void compute_subaddresses(std::unordered_map< crypto::public_key, cryptonote::subaddress_index > &subaddresses, cryptonote::account_base &creds, size_t account, size_t minors)
static void process_transactions(tools::wallet2 *wallet, const std::vector< test_event_entry > &events, const cryptonote::block &blk_head, block_tracker &bt, const boost::optional< crypto::hash > &blk_tail=boost::none)
tools::wallet2::transfer_details * td
Definition: wallet_tools.h:37
cryptonote::tx_source_entry * src
Definition: wallet_tools.h:38
static void gen_block_data(block_tracker &bt, const cryptonote::block *bl, const map_hash2tx_t &mtx, cryptonote::block_complete_entry &bche, tools::wallet2::parsed_block &parsed_block, uint64_t &height)
static void gen_tx_src(size_t mixin, uint64_t cur_height, const tools::wallet2::transfer_details &td, cryptonote::tx_source_entry &src, block_tracker &bt)
std::unordered_set< crypto::key_image > * selected_kis
Definition: wallet_tools.h:41
RangeProofType
Definition: rctTypes.h:235
static tools::wallet2::transfer_container & get_transfers(tools::wallet2 *wallet)
Definition: wallet_tools.h:55
static bool 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=0, int step=1, const boost::optional< fnc_accept_tx_source_t > &fnc_accept=boost::none)
std::unordered_set< size_t > * selected_idx
Definition: wallet_tools.h:40