use address_parse_info instead of address

pull/74/head
moneroexamples 6 years ago
parent d8307fc0e8
commit a40464fd32

@ -110,7 +110,8 @@ set(LIBRARIES
mysqlpp
mysqlclient
readline
easylogging
checkpoints
version
${Boost_LIBRARIES}
pthread
unbound

@ -30,7 +30,7 @@
set(LIBS common;blocks;cryptonote_basic;cryptonote_core;
cryptonote_protocol;daemonizer;mnemonics;epee;lmdb;
blockchain_db;ringct;wallet;cncrypto)
blockchain_db;ringct;wallet;cncrypto;easylogging;version;checkpoints)
set(Xmr_INCLUDE_DIRS "${CPP_MONERO_DIR}")
@ -42,11 +42,11 @@ foreach (l ${LIBS})
string(TOUPPER ${l} L)
find_library(Xmr_${L}_LIBRARY
NAMES ${l}
PATHS ${CMAKE_LIBRARY_PATH}
PATH_SUFFIXES "/src/${l}" "/external/db_drivers/lib${l}" "/lib" "/src/crypto" "/contrib/epee/src"
NO_DEFAULT_PATH
)
NAMES ${l}
PATHS ${CMAKE_LIBRARY_PATH}
PATH_SUFFIXES "/src/${l}" "/src/" "/external/db_drivers/lib${l}" "/lib" "/src/crypto" "/contrib/epee/src" "/external/easylogging++/"
NO_DEFAULT_PATH
)
set(Xmr_${L}_LIBRARIES ${Xmr_${L}_LIBRARY})
@ -57,18 +57,11 @@ foreach (l ${LIBS})
endforeach()
if (EXISTS ${MONERO_BUILD_DIR}/external/unbound/libunbound.a)
add_library(unbound STATIC IMPORTED)
set_property(TARGET unbound PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/external/unbound/libunbound.a)
endif()
if (EXISTS ${MONERO_BUILD_DIR}/external/easylogging++/libeasylogging.a)
add_library(easylogging STATIC IMPORTED)
set_property(TARGET easylogging
PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/external/easylogging++/libeasylogging.a)
endif()
#if (EXISTS ${MONERO_BUILD_DIR}/external/easylogging++/libeasylogging.a)
# add_library(easylogging STATIC IMPORTED)
# set_property(TARGET easylogging
# PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/external/easylogging++/libeasylogging.a)
#endif()
message(STATUS ${MONERO_SOURCE_DIR}/build)
@ -79,4 +72,4 @@ include_directories(
${MONERO_SOURCE_DIR}/build
${MONERO_SOURCE_DIR}/external/easylogging++
${MONERO_SOURCE_DIR}/contrib/epee/include
${MONERO_SOURCE_DIR}/external/db_drivers/liblmdb)
${MONERO_SOURCE_DIR}/external/db_drivers/liblmdb)

@ -35,7 +35,7 @@ vector<pair<uint64_t, transaction>> CurrentBlockchainStatus::mempool_txs;
string CurrentBlockchainStatus::import_payment_address_str;
string CurrentBlockchainStatus::import_payment_viewkey_str;
uint64_t CurrentBlockchainStatus::import_fee {10000000000}; // 0.01 xmr
account_public_address CurrentBlockchainStatus::import_payment_address;
address_parse_info CurrentBlockchainStatus::import_payment_address;
secret_key CurrentBlockchainStatus::import_payment_viewkey;
map<string, unique_ptr<TxSearch>> CurrentBlockchainStatus::searching_threads;
cryptonote::Blockchain* CurrentBlockchainStatus::core_storage;
@ -329,7 +329,7 @@ CurrentBlockchainStatus::get_account_integrated_address_as_str(
crypto::hash8 const& payment_id8)
{
return cryptonote::get_account_integrated_address_as_str(testnet,
import_payment_address, payment_id8);
import_payment_address.address, payment_id8);
}
string
@ -654,7 +654,7 @@ CurrentBlockchainStatus::search_if_payment_made(
derive_public_key(derivation,
output_idx_in_tx,
import_payment_address.m_spend_public_key,
import_payment_address.address.m_spend_public_key,
generated_tx_pubkey);
// check if generated public key matches the current output's key
@ -846,7 +846,7 @@ CurrentBlockchainStatus::search_thread_exist(const string& address)
bool
CurrentBlockchainStatus::get_xmr_address_viewkey(
const string& address_str,
account_public_address& address,
address_parse_info& address,
secret_key& viewkey)
{
std::lock_guard<std::mutex> lck (searching_threads_map_mtx);

@ -59,8 +59,8 @@ struct CurrentBlockchainStatus
static uint64_t spendable_age;
static uint64_t spendable_age_coinbase;
static account_public_address import_payment_address;
static secret_key import_payment_viewkey;
static address_parse_info import_payment_address;
static secret_key import_payment_viewkey;
// vector of mempool transactions that all threads
// can refer to
@ -182,7 +182,7 @@ struct CurrentBlockchainStatus
static bool
get_xmr_address_viewkey(const string& address_str,
account_public_address& address,
address_parse_info& address,
secret_key& viewkey);
static bool
find_txs_in_mempool(const string& address_str,

@ -9,12 +9,12 @@ namespace xmreg
{
OutputInputIdentification::OutputInputIdentification(
const account_public_address* _a,
const address_parse_info* _a,
const secret_key* _v,
const transaction* _tx)
: total_received {0}, mixin_no {0}
{
address = _a;
address_info = _a;
viewkey = _v;
tx = _tx;
@ -61,7 +61,6 @@ OutputInputIdentification::identify_outputs()
outputs = get_ouputs_tuple(*tx);
for (auto& out: outputs)
{
txout_to_key txout_k = std::get<0>(out);
@ -75,7 +74,7 @@ OutputInputIdentification::identify_outputs()
derive_public_key(derivation,
output_idx_in_tx,
address->m_spend_public_key,
address_info->address.m_spend_public_key,
generated_tx_pubkey);
// check if generated public key matches the current output's key

@ -97,7 +97,7 @@ public:
vector<output_info> identified_outputs;
vector<input_info> identified_inputs;
OutputInputIdentification(const account_public_address* _a,
OutputInputIdentification(const address_parse_info* _a,
const secret_key* _v,
const transaction* _tx);
@ -131,7 +131,7 @@ public:
private:
// address and viewkey for this search thread.
const account_public_address* address;
const address_parse_info* address_info;
const secret_key* viewkey;
// transaction that is beeing search

@ -696,7 +696,7 @@ TxSearch::find_txs_in_mempool(
}
pair<account_public_address, secret_key>
pair<address_parse_info, secret_key>
TxSearch::get_xmr_address_viewkey() const
{
return make_pair(address, viewkey);

@ -64,7 +64,7 @@ class TxSearch
shared_ptr<MySqlAccounts> xmr_accounts;
// address and viewkey for this search thread.
account_public_address address;
address_parse_info address;
secret_key viewkey;
public:
@ -125,7 +125,7 @@ public:
json
find_txs_in_mempool(vector<pair<uint64_t, transaction>> mempool_txs);
pair<account_public_address, secret_key>
pair<address_parse_info, secret_key>
get_xmr_address_viewkey() const;
static void

@ -1295,7 +1295,7 @@ YourMoneroRequests::get_tx(const shared_ptr< Session > session, const Bytes & bo
j_response["payment_id"] = string {};
j_response["timestamp"] = default_timestamp;
account_public_address address;
address_parse_info address_info;
secret_key viewkey;
// to get info about recived xmr in this tx, we calculate it from
@ -1305,9 +1305,9 @@ YourMoneroRequests::get_tx(const shared_ptr< Session > session, const Bytes & bo
// it differently than before. Its not great, since we reinvent the wheel
// but its worth double checking the mysql data, and also allows for new
// implementation in the frontend.
if (CurrentBlockchainStatus::get_xmr_address_viewkey(xmr_address, address, viewkey))
if (CurrentBlockchainStatus::get_xmr_address_viewkey(xmr_address, address_info, viewkey))
{
OutputInputIdentification oi_identification {&address, &viewkey, &tx};
OutputInputIdentification oi_identification {&address_info, &viewkey, &tx};
oi_identification.identify_outputs();
@ -1412,7 +1412,7 @@ YourMoneroRequests::get_tx(const shared_ptr< Session > session, const Bytes & bo
// Class that is resposnible for idenficitaction of our outputs
// and inputs in a given tx.
OutputInputIdentification oi_identification
{&address, &viewkey, &tx};
{&address_info, &viewkey, &tx};
// no need mutex here, as this will be exectued only after
// the above. there is no threads here.

@ -13,6 +13,7 @@
#include "CurrentBlockchainStatus.h"
#include "MySqlAccounts.h"
#include "../gen/version.h"
#include "../ext/restbed/source/restbed"

@ -9,14 +9,14 @@
#define BLOCKCHAIN_DB DB_LMDB
#define UNSIGNED_TX_PREFIX "Monero unsigned tx set\002"
#define SIGNED_TX_PREFIX "Monero signed tx set\002"
#define UNSIGNED_TX_PREFIX "Monero unsigned tx set\003"
#define SIGNED_TX_PREFIX "Monero signed tx set\003"
#define KEY_IMAGE_EXPORT_FILE_MAGIC "Monero key image export\002"
#define OUTPUT_EXPORT_FILE_MAGIC "Monero output export\002"
#define OUTPUT_EXPORT_FILE_MAGIC "Monero output export\003"
#define FEE_ESTIMATE_GRACE_BLOCKS 10
#include "release/version/version.h"
#include "version.h"
#include "net/http_client.h"
#include "storages/http_abstract_invoke.h"

@ -74,13 +74,14 @@ get_tx_pub_key_from_str_hash(Blockchain& core_storage, const string& hash_str, t
* Parse monero address in a string form into
* cryptonote::account_public_address object
*/
bool
parse_str_address(const string& address_str,
account_public_address& address,
address_parse_info& address_info,
bool testnet)
{
if (!get_account_address_from_str(address, testnet, address_str))
if (!get_account_address_from_str(address_info, testnet, address_str))
{
cerr << "Error getting address: " << address_str << endl;
return false;
@ -90,13 +91,16 @@ parse_str_address(const string& address_str,
}
/**
* Return string representation of monero address
*/
string
print_address(const account_public_address& address, bool testnet)
print_address(const address_parse_info& address_info, bool testnet)
{
return "<" + get_account_address_as_str(testnet, address) + ">";
return "<" + get_account_address_as_str(
testnet, address_info.is_subaddress, address_info.address)
+ ">";
}
string
@ -183,9 +187,9 @@ timestamp_to_str_local(time_t timestamp, const char* format)
ostream&
operator<< (ostream& os, const account_public_address& addr)
operator<< (ostream& os, const address_parse_info& addr_info)
{
os << get_account_address_as_str(false, addr);
os << get_account_address_as_str(false, addr_info.is_subaddress, addr_info.address);
return os;
}

@ -64,14 +64,14 @@ get_tx_pub_key_from_str_hash(Blockchain& core_storage,
bool
parse_str_address(const string& address_str,
account_public_address& address,
address_parse_info& address_info,
bool testnet = false);
inline bool
is_separator(char c);
string
print_address(const account_public_address& address,
print_address(const address_parse_info& address,
bool testnet = false);
string
@ -88,7 +88,7 @@ string
timestamp_to_str_gm(time_t timestamp, const char* format = "%F %T");
ostream&
operator<< (ostream& os, const account_public_address& addr);
operator<< (ostream& os, const address_parse_info& addr);
string

Loading…
Cancel
Save