Monero
Loading...
Searching...
No Matches
wallet_tools.h
Go to the documentation of this file.
1// Copyright (c) 2014-2022, 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
36typedef 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
48typedef 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{
53public:
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{
62public:
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
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
77bool 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
81bool 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,
86 bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version = 0);
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition chaingen.h:163
std::unordered_map< crypto::public_key, cryptonote::subaddress_index > subaddresses_t
Definition chaingen.h:365
boost::variant< cryptonote::account_public_address, cryptonote::account_keys, cryptonote::account_base, cryptonote::tx_destination_entry > var_addr_t
Definition chaingen.h:368
Definition chaingen.h:377
Definition account.h:74
Definition cryptonote_basic.h:205
Definition wallet2.h:232
std::vector< transfer_details > transfer_container
Definition wallet2.h:619
Definition wallet_tools.h:52
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)
Definition wallet_tools.cpp:32
static void set_account(tools::wallet2 *wallet, cryptonote::account_base &account)
Definition wallet_tools.cpp:13
static subaddresses_t & get_subaddresses(tools::wallet2 *wallet)
Definition wallet_tools.h:56
static tools::wallet2::transfer_container & get_transfers(tools::wallet2 *wallet)
Definition wallet_tools.h:55
Definition wallet_tools.h:61
static void compute_subaddresses(std::unordered_map< crypto::public_key, cryptonote::subaddress_index > &subaddresses, cryptonote::account_base &creds, size_t account, size_t minors)
Definition wallet_tools.cpp:239
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)
Definition wallet_tools.cpp:161
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)
Definition wallet_tools.cpp:74
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)
Definition wallet_tools.cpp:37
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)
Definition wallet_tools.cpp:204
static MDB_envinfo info
Definition mdb_load.c:37
Definition blockchain.py:1
Definition blocks.cpp:13
Definition bulletproofs.cc:64
RangeProofType
Definition rctTypes.h:307
@ RangeProofBorromean
Definition rctTypes.h:307
Definition wallet.py:1
unsigned __int64 uint64_t
Definition stdint.h:136
Definition cryptonote_basic.h:512
Definition cryptonote_protocol_defs.h:133
Definition cryptonote_basic.h:475
Definition cryptonote_tx_utils.h:43
Definition wallet2.h:865
Definition wallet2.h:348
Definition wallet_tools.h:36
std::unordered_set< size_t > * selected_idx
Definition wallet_tools.h:40
std::unordered_set< crypto::key_image > * selected_kis
Definition wallet_tools.h:41
tools::wallet2::transfer_details * td
Definition wallet_tools.h:37
cryptonote::tx_source_entry * src
Definition wallet_tools.h:38
size_t iters
Definition wallet_tools.h:43
size_t ntrans
Definition wallet_tools.h:42
size_t cur_utxo
Definition wallet_tools.h:45
uint64_t sum
Definition wallet_tools.h:44
cryptonote::transaction tx
Definition transaction.cpp:40
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)
cryptonote::account_public_address get_address(const tools::wallet2 *)
Definition wallet_tools.cpp:250
std::function< bool(const tx_source_info_crate_t &info, bool &abort)> fnc_accept_tx_source_t
Definition wallet_tools.h:48
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, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)