Electroneum
Loading...
Searching...
No Matches
tsx_builder Class Reference

#include <trezor_tests.h>

Collaboration diagram for tsx_builder:

Public Member Functions

 tsx_builder ()
 tsx_builder (gen_trezor_base *tester)
tsx_buildercur_height (uint64_t cur_height)
tsx_buildermixin (size_t mixin=TREZOR_TEST_MIXIN)
tsx_builderfee (uint64_t fee=TREZOR_TEST_FEE)
tsx_builderpayment_id (const std::string &payment_id)
tsx_builderfrom (tools::wallet2 *from, uint32_t account=0)
tsx_buildersources (std::vector< cryptonote::tx_source_entry > &sources, std::vector< size_t > &selected_transfers)
tsx_buildercompute_sources (boost::optional< size_t > num_utxo=boost::none, boost::optional< uint64_t > min_amount=boost::none, ssize_t offset=-1, int step=1, boost::optional< fnc_accept_tx_source_t > fnc_accept=boost::none)
tsx_buildercompute_sources_to_sub (boost::optional< size_t > num_utxo=boost::none, boost::optional< uint64_t > min_amount=boost::none, ssize_t offset=-1, int step=1, boost::optional< fnc_accept_tx_source_t > fnc_accept=boost::none)
tsx_buildercompute_sources_to_sub_acc (boost::optional< size_t > num_utxo=boost::none, boost::optional< uint64_t > min_amount=boost::none, ssize_t offset=-1, int step=1, boost::optional< fnc_accept_tx_source_t > fnc_accept=boost::none)
tsx_builderdestinations (std::vector< cryptonote::tx_destination_entry > &dsts)
tsx_builderadd_destination (const cryptonote::tx_destination_entry &dst)
tsx_builderadd_destination (const tools::wallet2 *wallet, bool is_subaddr=false, uint64_t amount=1000)
tsx_builderadd_destination (const var_addr_t addr, bool is_subaddr=false, uint64_t amount=1000)
tsx_builderset_integrated (size_t idx)
tsx_builderrct_config (const rct::RCTConfig &rct_config)
tsx_builderbuild_tx ()
tsx_builderconstruct_pending_tx (tools::wallet2::pending_tx &ptx, boost::optional< std::vector< uint8_t > > extra=boost::none)
tsx_builderclear_current ()
std::vector< tools::wallet2::pending_txbuild ()
std::vector< cryptonote::address_parse_infodest_info ()

Protected Attributes

gen_trezor_basem_tester
uint64_t m_cur_height
std::vector< tools::wallet2::pending_txm_ptxs
size_t m_mixin
uint64_t m_fee
tools::wallet2m_from
uint32_t m_account
cryptonote::transaction m_tx
std::vector< size_t > m_selected_transfers
std::vector< cryptonote::tx_source_entrym_sources
std::vector< cryptonote::tx_destination_entrym_destinations
std::vector< cryptonote::tx_destination_entrym_destinations_orig
std::vector< cryptonote::address_parse_infom_dsts_info
std::unordered_set< size_t > m_integrated
std::string m_payment_id
rct::RCTConfig m_rct_config

Detailed Description

Definition at line 150 of file trezor_tests.h.

Constructor & Destructor Documentation

◆ tsx_builder() [1/2]

tsx_builder::tsx_builder ( )
inline

Definition at line 152 of file trezor_tests.h.

gen_trezor_base * m_tester
rct::RCTConfig m_rct_config
uint32_t m_account
tools::wallet2 * m_from
uint64_t m_fee
@ RangeProofPaddedBulletproof
Definition rctTypes.h:235
#define TREZOR_TEST_FEE
#define TREZOR_TEST_MIXIN
Here is the caller graph for this function:

◆ tsx_builder() [2/2]

tsx_builder::tsx_builder ( gen_trezor_base * tester)
inline

Definition at line 155 of file trezor_tests.h.

Member Function Documentation

◆ add_destination() [1/3]

tsx_builder * tsx_builder::add_destination ( const cryptonote::tx_destination_entry & dst)

Definition at line 1354 of file trezor_tests.cpp.

1355{
1356 m_destinations_orig.push_back(dst);
1357 return this;
1358}
std::vector< cryptonote::tx_destination_entry > m_destinations_orig
Here is the call graph for this function:

◆ add_destination() [2/3]

tsx_builder * tsx_builder::add_destination ( const tools::wallet2 * wallet,
bool is_subaddr = false,
uint64_t amount = 1000 )

Definition at line 1366 of file trezor_tests.cpp.

1367{
1368 m_destinations_orig.push_back(build_dst(get_address(wallet), is_subaddr, amount));
1369 return this;
1370}
cryptonote::tx_destination_entry build_dst(const var_addr_t &to, bool is_subaddr, uint64_t amount)
Definition chaingen.cpp:804
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition chaingen.cpp:665
Here is the call graph for this function:

◆ add_destination() [3/3]

tsx_builder * tsx_builder::add_destination ( const var_addr_t addr,
bool is_subaddr = false,
uint64_t amount = 1000 )

Definition at line 1360 of file trezor_tests.cpp.

1361{
1362 m_destinations_orig.push_back(build_dst(addr, is_subaddr, amount));
1363 return this;
1364}
Here is the call graph for this function:

◆ build()

std::vector< tools::wallet2::pending_tx > tsx_builder::build ( )

Definition at line 1473 of file trezor_tests.cpp.

1474{
1475 return m_ptxs;
1476}
std::vector< tools::wallet2::pending_tx > m_ptxs

◆ build_tx()

tsx_builder * tsx_builder::build_tx ( )

Definition at line 1391 of file trezor_tests.cpp.

1392{
1393 CHECK_AND_ASSERT_THROW_MES(m_tester, "m_tester wallet empty");
1394 CHECK_AND_ASSERT_THROW_MES(m_from, "m_from wallet empty");
1395
1396 // Amount sanity check input >= fee + outputs
1397 const uint64_t out_amount = sum_amount(m_destinations_orig);
1398 const uint64_t in_amount = sum_amount(m_sources);
1399 CHECK_AND_ASSERT_THROW_MES(in_amount >= out_amount + m_fee, "Not enough input credits for outputs and fees");
1400
1401 // Create new pending transaction, init with sources and destinations
1402 m_ptxs.emplace_back();
1403 auto & ptx = m_ptxs.back();
1404
1405 std::vector<uint8_t> extra = build_payment_id_extra(m_payment_id);
1406 fill_tx_destinations(m_from->get_subaddress({m_account, 0}), m_destinations_orig, m_fee, m_sources, m_destinations, true);
1407 construct_pending_tx(ptx, extra);
1408
1409 ptx.construction_data.subaddr_account = m_account;
1410
1411 // Build destinations parse info
1412 for(size_t i = 0; i < m_destinations_orig.size(); ++i){
1413 auto & cdest = m_destinations_orig[i];
1414 cryptonote::address_parse_info info = init_addr_parse_info(cdest.addr, cdest.is_subaddress);
1415 if (m_integrated.find(i) != m_integrated.end()){
1416 CHECK_AND_ASSERT_THROW_MES(m_payment_id.size() == 8, "Integrated set but payment_id.size() != 8");
1417 info.has_payment_id = true;
1418 info.payment_id = to_short_payment_id(m_payment_id);
1419 }
1420
1421 m_dsts_info.push_back(info);
1422 }
1423
1424 return this;
1425}
uint64_t sum_amount(const std::vector< tx_destination_entry > &destinations)
Definition chaingen.cpp:700
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)
Definition chaingen.cpp:720
std::vector< cryptonote::tx_source_entry > m_sources
tsx_builder * construct_pending_tx(tools::wallet2::pending_tx &ptx, boost::optional< std::vector< uint8_t > > extra=boost::none)
std::vector< cryptonote::address_parse_info > m_dsts_info
std::vector< cryptonote::tx_destination_entry > m_destinations
std::unordered_set< size_t > m_integrated
std::string m_payment_id
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
CXA_THROW_INFO_T * info
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:

◆ clear_current()

tsx_builder * tsx_builder::clear_current ( )

Definition at line 1378 of file trezor_tests.cpp.

1379{
1380 m_account = 0;
1381 m_selected_transfers.clear();
1382 m_sources.clear();
1383 m_destinations.clear();
1384 m_destinations_orig.clear();
1385 m_dsts_info.clear();
1386 m_integrated.clear();
1387 m_payment_id.clear();
1388 return this;
1389}
std::vector< size_t > m_selected_transfers
Here is the call graph for this function:

◆ compute_sources()

tsx_builder * tsx_builder::compute_sources ( boost::optional< size_t > num_utxo = boost::none,
boost::optional< uint64_t > min_amount = boost::none,
ssize_t offset = -1,
int step = 1,
boost::optional< fnc_accept_tx_source_t > fnc_accept = boost::none )

Definition at line 1293 of file trezor_tests.cpp.

1294{
1295 CHECK_AND_ASSERT_THROW_MES(m_tester, "m_tester wallet empty");
1296 CHECK_AND_ASSERT_THROW_MES(m_from, "m_from wallet empty");
1297
1298 // typedef std::function<bool(const tx_source_info_crate_t &info, bool &abort)> fnc_accept_tx_source_t;
1299 boost::optional<fnc_accept_tx_source_t> fnc_accept_to_use = boost::none;
1300
1301 auto c_account = m_account;
1302 fnc_accept_tx_source_t fnc_acc = [c_account, &fnc_accept] (const tx_source_info_crate_t &info, bool &abort) -> bool {
1303 if (info.td->m_subaddr_index.major != c_account){
1304 return false;
1305 }
1306 if (fnc_accept){
1307 return (fnc_accept.get())(info, abort);
1308 }
1309 return true;
1310 };
1311
1312 fnc_accept_to_use = fnc_acc;
1313 bool res = wallet_tools::fill_tx_sources(m_from, m_sources, m_mixin, num_utxo, min_amount, m_tester->m_bt, m_selected_transfers, m_cur_height, offset, step, fnc_accept_to_use);
1314 CHECK_AND_ASSERT_THROW_MES(res, "Tx source fill error");
1315 return this;
1316}
uint64_t m_cur_height
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)
const char * res
std::function< bool(const tx_source_info_crate_t &info, bool &abort)> fnc_accept_tx_source_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_sources_to_sub()

tsx_builder * tsx_builder::compute_sources_to_sub ( boost::optional< size_t > num_utxo = boost::none,
boost::optional< uint64_t > min_amount = boost::none,
ssize_t offset = -1,
int step = 1,
boost::optional< fnc_accept_tx_source_t > fnc_accept = boost::none )

Definition at line 1318 of file trezor_tests.cpp.

1319{
1320 fnc_accept_tx_source_t fnc = [&fnc_accept] (const tx_source_info_crate_t &info, bool &abort) -> bool {
1321 if (info.td->m_subaddr_index.minor == 0){
1322 return false;
1323 }
1324 if (fnc_accept){
1325 return (fnc_accept.get())(info, abort);
1326 }
1327 return true;
1328 };
1329
1330 return compute_sources(num_utxo, min_amount, offset, step, fnc);
1331}
tsx_builder * compute_sources(boost::optional< size_t > num_utxo=boost::none, boost::optional< uint64_t > min_amount=boost::none, ssize_t offset=-1, int step=1, boost::optional< fnc_accept_tx_source_t > fnc_accept=boost::none)
Here is the call graph for this function:

◆ compute_sources_to_sub_acc()

tsx_builder * tsx_builder::compute_sources_to_sub_acc ( boost::optional< size_t > num_utxo = boost::none,
boost::optional< uint64_t > min_amount = boost::none,
ssize_t offset = -1,
int step = 1,
boost::optional< fnc_accept_tx_source_t > fnc_accept = boost::none )

Definition at line 1333 of file trezor_tests.cpp.

1334{
1335 fnc_accept_tx_source_t fnc = [&fnc_accept] (const tx_source_info_crate_t &info, bool &abort) -> bool {
1336 if (info.td->m_subaddr_index.minor == 0 || info.src->real_out_additional_tx_keys.size() == 0){
1337 return false;
1338 }
1339 if (fnc_accept){
1340 return (fnc_accept.get())(info, abort);
1341 }
1342 return true;
1343 };
1344
1345 return compute_sources(num_utxo, min_amount, offset, step, fnc);
1346}
Here is the call graph for this function:

◆ construct_pending_tx()

tsx_builder * tsx_builder::construct_pending_tx ( tools::wallet2::pending_tx & ptx,
boost::optional< std::vector< uint8_t > > extra = boost::none )

Definition at line 1427 of file trezor_tests.cpp.

1428{
1429 CHECK_AND_ASSERT_THROW_MES(m_from, "Wallet not provided");
1430
1431 cryptonote::transaction tx;
1433 crypto::secret_key tx_key;
1434 std::vector<crypto::secret_key> additional_tx_keys;
1435 std::vector<tx_destination_entry> destinations_copy = m_destinations;
1436
1437 auto change_addr = m_from->get_account().get_keys().m_account_address;
1438 bool r = construct_tx_and_get_tx_key(m_from->get_account().get_keys(), subaddresses, m_sources, destinations_copy,
1439 change_addr, extra ? extra.get() : std::vector<uint8_t>(), tx, 0, tx_key,
1440 additional_tx_keys, true, m_rct_config, nullptr);
1441
1442 CHECK_AND_ASSERT_THROW_MES(r, "Transaction construction failed");
1443
1444 ptx.key_images = "";
1445 ptx.fee = TESTS_DEFAULT_FEE;
1446 ptx.dust = 0;
1447 ptx.dust_added_to_fee = false;
1448 ptx.tx = tx;
1449 ptx.change_dts = m_destinations.back();
1451 ptx.tx_key = tx_key;
1452 ptx.additional_tx_keys = additional_tx_keys;
1453 ptx.dests = m_destinations;
1454 ptx.multisig_sigs.clear();
1459 ptx.construction_data.extra = tx.extra;
1461 ptx.construction_data.use_rct = true;
1464
1467 for(uint32_t i = 0; i < 20; ++i)
1468 ptx.construction_data.subaddr_indices.insert(i);
1469
1470 return this;
1471}
std::unordered_map< crypto::public_key, cryptonote::subaddress_index > subaddresses_t
Definition chaingen.h:359
#define TESTS_DEFAULT_FEE
Definition chaingen.h:1061
static subaddresses_t & get_subaddresses(tools::wallet2 *wallet)
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition crypto.h:82
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)
unsigned int uint32_t
Definition stdint.h:126
tx_construction_data construction_data
Definition wallet2.h:477
std::vector< size_t > selected_transfers
Definition wallet2.h:470
crypto::secret_key tx_key
Definition wallet2.h:472
std::vector< cryptonote::tx_destination_entry > dests
Definition wallet2.h:474
std::vector< multisig_sig > multisig_sigs
Definition wallet2.h:475
cryptonote::transaction tx
Definition wallet2.h:466
std::vector< crypto::secret_key > additional_tx_keys
Definition wallet2.h:473
cryptonote::tx_destination_entry change_dts
Definition wallet2.h:469
std::vector< uint8_t > extra
Definition wallet2.h:426
std::vector< cryptonote::tx_source_entry > sources
Definition wallet2.h:422
std::vector< cryptonote::tx_destination_entry > splitted_dsts
Definition wallet2.h:424
std::vector< cryptonote::tx_destination_entry > dests
Definition wallet2.h:430
std::vector< size_t > selected_transfers
Definition wallet2.h:425
std::set< uint32_t > subaddr_indices
Definition wallet2.h:432
cryptonote::tx_destination_entry change_dts
Definition wallet2.h:423
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cur_height()

tsx_builder * tsx_builder::cur_height ( uint64_t cur_height)
inline

Definition at line 159 of file trezor_tests.h.

159{ m_cur_height = cur_height; return this; }
tsx_builder * cur_height(uint64_t cur_height)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dest_info()

std::vector< cryptonote::address_parse_info > tsx_builder::dest_info ( )
inline

Definition at line 180 of file trezor_tests.h.

180{ return m_dsts_info; }

◆ destinations()

tsx_builder * tsx_builder::destinations ( std::vector< cryptonote::tx_destination_entry > & dsts)

Definition at line 1348 of file trezor_tests.cpp.

1349{
1350 m_destinations_orig = dsts;
1351 return this;
1352}
Here is the call graph for this function:

◆ fee()

tsx_builder * tsx_builder::fee ( uint64_t fee = TREZOR_TEST_FEE)
inline

Definition at line 161 of file trezor_tests.h.

161{ m_fee = fee; return this; }
tsx_builder * fee(uint64_t fee=TREZOR_TEST_FEE)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ from()

tsx_builder * tsx_builder::from ( tools::wallet2 * from,
uint32_t account = 0 )
inline

Definition at line 163 of file trezor_tests.h.

163{ m_from = from; m_account=account; return this; }
tsx_builder * from(tools::wallet2 *from, uint32_t account=0)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mixin()

tsx_builder * tsx_builder::mixin ( size_t mixin = TREZOR_TEST_MIXIN)
inline

Definition at line 160 of file trezor_tests.h.

160{ m_mixin = mixin; return this; }
tsx_builder * mixin(size_t mixin=TREZOR_TEST_MIXIN)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ payment_id()

tsx_builder * tsx_builder::payment_id ( const std::string & payment_id)
inline

Definition at line 162 of file trezor_tests.h.

162{ m_payment_id = payment_id; return this; }
tsx_builder * payment_id(const std::string &payment_id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rct_config()

tsx_builder * tsx_builder::rct_config ( const rct::RCTConfig & rct_config)
inline

Definition at line 174 of file trezor_tests.h.

174{m_rct_config = rct_config; return this; };
tsx_builder * rct_config(const rct::RCTConfig &rct_config)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_integrated()

tsx_builder * tsx_builder::set_integrated ( size_t idx)

Definition at line 1372 of file trezor_tests.cpp.

1373{
1374 m_integrated.insert(idx);
1375 return this;
1376}
Here is the call graph for this function:

◆ sources()

tsx_builder * tsx_builder::sources ( std::vector< cryptonote::tx_source_entry > & sources,
std::vector< size_t > & selected_transfers )

Definition at line 1286 of file trezor_tests.cpp.

1287{
1289 m_selected_transfers = selected_transfers;
1290 return this;
1291}
tsx_builder * sources(std::vector< cryptonote::tx_source_entry > &sources, std::vector< size_t > &selected_transfers)
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_account

uint32_t tsx_builder::m_account
protected

Definition at line 191 of file trezor_tests.h.

◆ m_cur_height

uint64_t tsx_builder::m_cur_height
protected

Definition at line 184 of file trezor_tests.h.

◆ m_destinations

std::vector<cryptonote::tx_destination_entry> tsx_builder::m_destinations
protected

Definition at line 195 of file trezor_tests.h.

◆ m_destinations_orig

std::vector<cryptonote::tx_destination_entry> tsx_builder::m_destinations_orig
protected

Definition at line 196 of file trezor_tests.h.

◆ m_dsts_info

std::vector<cryptonote::address_parse_info> tsx_builder::m_dsts_info
protected

Definition at line 197 of file trezor_tests.h.

◆ m_fee

uint64_t tsx_builder::m_fee
protected

Definition at line 189 of file trezor_tests.h.

◆ m_from

tools::wallet2* tsx_builder::m_from
protected

Definition at line 190 of file trezor_tests.h.

◆ m_integrated

std::unordered_set<size_t> tsx_builder::m_integrated
protected

Definition at line 198 of file trezor_tests.h.

◆ m_mixin

size_t tsx_builder::m_mixin
protected

Definition at line 188 of file trezor_tests.h.

◆ m_payment_id

std::string tsx_builder::m_payment_id
protected

Definition at line 199 of file trezor_tests.h.

◆ m_ptxs

std::vector<tools::wallet2::pending_tx> tsx_builder::m_ptxs
protected

Definition at line 185 of file trezor_tests.h.

◆ m_rct_config

rct::RCTConfig tsx_builder::m_rct_config
protected

Definition at line 200 of file trezor_tests.h.

◆ m_selected_transfers

std::vector<size_t> tsx_builder::m_selected_transfers
protected

Definition at line 193 of file trezor_tests.h.

◆ m_sources

std::vector<cryptonote::tx_source_entry> tsx_builder::m_sources
protected

Definition at line 194 of file trezor_tests.h.

◆ m_tester

gen_trezor_base* tsx_builder::m_tester
protected

Definition at line 183 of file trezor_tests.h.

◆ m_tx

cryptonote::transaction tsx_builder::m_tx
protected

Definition at line 192 of file trezor_tests.h.


The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/trezor/trezor_tests.h
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/trezor/trezor_tests.cpp