mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
some simple reformating
This commit is contained in:
parent
0a415a466c
commit
8b45f9fe49
2 changed files with 3296 additions and 3309 deletions
55
src/page.h
55
src/page.h
|
@ -47,26 +47,26 @@
|
||||||
namespace xmreg {
|
namespace xmreg {
|
||||||
|
|
||||||
|
|
||||||
using namespace cryptonote;
|
using namespace cryptonote;
|
||||||
using namespace crypto;
|
using namespace crypto;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// define a checker to test if a structure has "tx_blob"
|
// define a checker to test if a structure has "tx_blob"
|
||||||
// member variable. I use modified daemon with few extra
|
// member variable. I use modified daemon with few extra
|
||||||
// bits and pieces here and there. One of them is
|
// bits and pieces here and there. One of them is
|
||||||
// tx_blob in cryptonote::tx_info structure
|
// tx_blob in cryptonote::tx_info structure
|
||||||
// thus I check if I run my version, or just
|
// thus I check if I run my version, or just
|
||||||
// generic one
|
// generic one
|
||||||
DEFINE_MEMBER_CHECKER(tx_blob)
|
DEFINE_MEMBER_CHECKER(tx_blob)
|
||||||
|
|
||||||
// define getter to get tx_blob, i.e., get_tx_blob function
|
// define getter to get tx_blob, i.e., get_tx_blob function
|
||||||
// as string if exists. the getter return empty string if
|
// as string if exists. the getter return empty string if
|
||||||
// tx_blob does not exist
|
// tx_blob does not exist
|
||||||
DEFINE_MEMBER_GETTER(tx_blob, string)
|
DEFINE_MEMBER_GETTER(tx_blob, string)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a given header filed contains value string
|
* Check if a given header filed contains value string
|
||||||
*
|
*
|
||||||
* @param req
|
* @param req
|
||||||
|
@ -74,11 +74,11 @@ namespace xmreg {
|
||||||
* @param value
|
* @param value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
string
|
string
|
||||||
does_header_has(const crow::request& req,
|
does_header_has(const crow::request& req,
|
||||||
const string& field = "Accept",
|
const string& field = "Accept",
|
||||||
const string& value = "q=.2, */*; q=.2")
|
const string& value = "q=.2, */*; q=.2")
|
||||||
{
|
{
|
||||||
string accept = req.get_header_value(field);
|
string accept = req.get_header_value(field);
|
||||||
|
|
||||||
if (!accept.empty())
|
if (!accept.empty())
|
||||||
|
@ -90,18 +90,18 @@ namespace xmreg {
|
||||||
}
|
}
|
||||||
|
|
||||||
return string {};
|
return string {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The tx_details struct
|
* @brief The tx_details struct
|
||||||
*
|
*
|
||||||
* Basic information about tx
|
* Basic information about tx
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct tx_details
|
struct tx_details
|
||||||
{
|
{
|
||||||
crypto::hash hash;
|
crypto::hash hash;
|
||||||
crypto::public_key pk;
|
crypto::public_key pk;
|
||||||
uint64_t xmr_inputs;
|
uint64_t xmr_inputs;
|
||||||
|
@ -228,9 +228,9 @@ namespace xmreg {
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class page {
|
class page {
|
||||||
|
|
||||||
// check if we have tx_blob member in tx_info structure
|
// check if we have tx_blob member in tx_info structure
|
||||||
static const bool HAVE_TX_BLOB {
|
static const bool HAVE_TX_BLOB {
|
||||||
|
@ -251,7 +251,7 @@ namespace xmreg {
|
||||||
bool testnet;
|
bool testnet;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
page(MicroCore* _mcore, Blockchain* _core_storage,
|
page(MicroCore* _mcore, Blockchain* _core_storage,
|
||||||
string _deamon_url, string _lmdb2_path, bool _testnet)
|
string _deamon_url, string _lmdb2_path, bool _testnet)
|
||||||
|
@ -2895,7 +2895,7 @@ namespace xmreg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -3638,8 +3638,7 @@ namespace xmreg {
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
214
src/tools.h
214
src/tools.h
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// Created by marcin on 5/11/15.
|
// Created by mwo on 5/11/15.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef XMREG01_TOOLS_H
|
#ifndef XMREG01_TOOLS_H
|
||||||
|
@ -37,18 +37,19 @@
|
||||||
*/
|
*/
|
||||||
namespace xmreg
|
namespace xmreg
|
||||||
{
|
{
|
||||||
using namespace cryptonote;
|
|
||||||
using namespace crypto;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
namespace bf = boost::filesystem;
|
using namespace cryptonote;
|
||||||
namespace pt = boost::posix_time;
|
using namespace crypto;
|
||||||
namespace gt = boost::gregorian;
|
using namespace std;
|
||||||
namespace lt = boost::local_time;
|
|
||||||
|
namespace bf = boost::filesystem;
|
||||||
|
namespace pt = boost::posix_time;
|
||||||
|
namespace gt = boost::gregorian;
|
||||||
|
namespace lt = boost::local_time;
|
||||||
|
|
||||||
|
|
||||||
struct outputs_visitor
|
struct outputs_visitor
|
||||||
{
|
{
|
||||||
std::vector<crypto::public_key >& m_output_keys;
|
std::vector<crypto::public_key >& m_output_keys;
|
||||||
|
|
||||||
const Blockchain& m_bch;
|
const Blockchain& m_bch;
|
||||||
|
@ -60,152 +61,139 @@ namespace xmreg
|
||||||
|
|
||||||
bool handle_output(uint64_t unlock_time, const crypto::public_key &pubkey)
|
bool handle_output(uint64_t unlock_time, const crypto::public_key &pubkey)
|
||||||
{
|
{
|
||||||
//check tx unlock time
|
|
||||||
// if (!m_bch.is_tx_spendtime_unlocked(unlock_time))
|
|
||||||
// {
|
|
||||||
// LOG_PRINT_L1("One of outputs for one of inputs has wrong tx.unlock_time = " << unlock_time);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
m_output_keys.push_back(pubkey);
|
m_output_keys.push_back(pubkey);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool
|
||||||
|
parse_str_secret_key(const string& key_str, T& secret_key);
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
get_tx_pub_key_from_str_hash(Blockchain& core_storage,
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool
|
|
||||||
parse_str_secret_key(const string& key_str, T& secret_key);
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
get_tx_pub_key_from_str_hash(Blockchain& core_storage,
|
|
||||||
const string& hash_str,
|
const string& hash_str,
|
||||||
transaction& tx);
|
transaction& tx);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
parse_str_address(const string& address_str,
|
parse_str_address(const string& address_str,
|
||||||
account_public_address& address,
|
account_public_address& address,
|
||||||
bool testnet = false);
|
bool testnet = false);
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
is_separator(char c);
|
is_separator(char c);
|
||||||
|
|
||||||
string
|
string
|
||||||
print_address(const account_public_address& address,
|
print_address(const account_public_address& address,
|
||||||
bool testnet = false);
|
bool testnet = false);
|
||||||
|
|
||||||
string
|
string
|
||||||
print_sig (const signature& sig);
|
print_sig (const signature& sig);
|
||||||
|
|
||||||
string
|
string
|
||||||
remove_trailing_path_separator(const string& in_path);
|
remove_trailing_path_separator(const string& in_path);
|
||||||
|
|
||||||
bf::path
|
bf::path
|
||||||
remove_trailing_path_separator(const bf::path& in_path);
|
remove_trailing_path_separator(const bf::path& in_path);
|
||||||
|
|
||||||
string
|
string
|
||||||
timestamp_to_str(time_t timestamp, const char* format = "%F %T");
|
timestamp_to_str(time_t timestamp, const char* format = "%F %T");
|
||||||
|
|
||||||
|
|
||||||
ostream&
|
ostream&
|
||||||
operator<< (ostream& os, const account_public_address& addr);
|
operator<< (ostream& os, const account_public_address& addr);
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
get_default_lmdb_folder(bool testnet = false);
|
get_default_lmdb_folder(bool testnet = false);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
generate_key_image(const crypto::key_derivation& derivation,
|
generate_key_image(const crypto::key_derivation& derivation,
|
||||||
const std::size_t output_index,
|
const std::size_t output_index,
|
||||||
const crypto::secret_key& sec_key,
|
const crypto::secret_key& sec_key,
|
||||||
const crypto::public_key& pub_key,
|
const crypto::public_key& pub_key,
|
||||||
crypto::key_image& key_img);
|
crypto::key_image& key_img);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
get_blockchain_path(const boost::optional<string>& bc_path,
|
get_blockchain_path(const boost::optional<string>& bc_path,
|
||||||
bf::path& blockchain_path,
|
bf::path& blockchain_path,
|
||||||
bool testnet = false);
|
bool testnet = false);
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
sum_money_in_outputs(const transaction& tx);
|
sum_money_in_outputs(const transaction& tx);
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
sum_money_in_inputs(const transaction& tx);
|
sum_money_in_inputs(const transaction& tx);
|
||||||
|
|
||||||
array<uint64_t, 2>
|
array<uint64_t, 2>
|
||||||
sum_money_in_tx(const transaction& tx);
|
sum_money_in_tx(const transaction& tx);
|
||||||
|
|
||||||
array<uint64_t, 2>
|
array<uint64_t, 2>
|
||||||
sum_money_in_txs(const vector<transaction>& txs);
|
sum_money_in_txs(const vector<transaction>& txs);
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
sum_fees_in_txs(const vector<transaction>& txs);
|
sum_fees_in_txs(const vector<transaction>& txs);
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
get_mixin_no(const transaction& tx);
|
get_mixin_no(const transaction& tx);
|
||||||
|
|
||||||
vector<uint64_t>
|
vector<uint64_t>
|
||||||
get_mixin_no_in_txs(const vector<transaction>& txs);
|
get_mixin_no_in_txs(const vector<transaction>& txs);
|
||||||
|
|
||||||
vector<pair<txout_to_key, uint64_t>>
|
vector<pair<txout_to_key, uint64_t>>
|
||||||
get_ouputs(const transaction& tx);
|
get_ouputs(const transaction& tx);
|
||||||
|
|
||||||
vector<tuple<txout_to_key, uint64_t, uint64_t>>
|
vector<tuple<txout_to_key, uint64_t, uint64_t>>
|
||||||
get_ouputs_tuple(const transaction& tx);
|
get_ouputs_tuple(const transaction& tx);
|
||||||
|
|
||||||
vector<txin_to_key>
|
vector<txin_to_key>
|
||||||
get_key_images(const transaction& tx);
|
get_key_images(const transaction& tx);
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
get_payment_id(const vector<uint8_t>& extra,
|
get_payment_id(const vector<uint8_t>& extra,
|
||||||
crypto::hash& payment_id,
|
crypto::hash& payment_id,
|
||||||
crypto::hash8& payment_id8);
|
crypto::hash8& payment_id8);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
get_payment_id(const transaction& tx,
|
get_payment_id(const transaction& tx,
|
||||||
crypto::hash& payment_id,
|
crypto::hash& payment_id,
|
||||||
crypto::hash8& payment_id8);
|
crypto::hash8& payment_id8);
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
enable_monero_log() {
|
enable_monero_log() {
|
||||||
uint32_t log_level = 0;
|
uint32_t log_level = 0;
|
||||||
epee::log_space::get_set_log_detalisation_level(true, log_level);
|
epee::log_space::get_set_log_detalisation_level(true, log_level);
|
||||||
epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
|
epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
estimate_bc_height(const string& date, const char* format = "%Y-%m-%d");
|
estimate_bc_height(const string& date, const char* format = "%Y-%m-%d");
|
||||||
|
|
||||||
|
|
||||||
inline double
|
inline double
|
||||||
get_xmr(uint64_t core_amount)
|
get_xmr(uint64_t core_amount)
|
||||||
{
|
{
|
||||||
return static_cast<double>(core_amount) / 1e12;
|
return static_cast<double>(core_amount) / 1e12;
|
||||||
}
|
}
|
||||||
|
|
||||||
array<size_t, 5>
|
array<size_t, 5>
|
||||||
timestamp_difference(uint64_t t1, uint64_t t2);
|
timestamp_difference(uint64_t t1, uint64_t t2);
|
||||||
|
|
||||||
string
|
string
|
||||||
read(string filename);
|
read(string filename);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prints an iterable such as vector
|
* prints an iterable such as vector
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void print_iterable(const T & elems) {
|
void print_iterable(const T & elems) {
|
||||||
|
|
||||||
infix_ostream_iterator<typename T::value_type>
|
infix_ostream_iterator<typename T::value_type>
|
||||||
oiter(std::cout, ",");
|
oiter(std::cout, ",");
|
||||||
|
@ -213,48 +201,48 @@ namespace xmreg
|
||||||
std::cout << "[";
|
std::cout << "[";
|
||||||
std::copy(elems.begin(), elems.end(),oiter);
|
std::copy(elems.begin(), elems.end(),oiter);
|
||||||
std::cout << "]" << std::endl;
|
std::cout << "]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<string, double>
|
pair<string, double>
|
||||||
timestamps_time_scale(const vector<uint64_t>& timestamps,
|
timestamps_time_scale(const vector<uint64_t>& timestamps,
|
||||||
uint64_t timeN, uint64_t resolution = 80,
|
uint64_t timeN, uint64_t resolution = 80,
|
||||||
uint64_t time0 = 1397818193 /* timestamp of the second block */);
|
uint64_t time0 = 1397818193 /* timestamp of the second block */);
|
||||||
|
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
ptime_to_time_t(const pt::ptime& in_ptime);
|
ptime_to_time_t(const pt::ptime& in_ptime);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
decode_ringct(const rct::rctSig & rv,
|
decode_ringct(const rct::rctSig & rv,
|
||||||
const crypto::public_key pub,
|
const crypto::public_key pub,
|
||||||
const crypto::secret_key &sec,
|
const crypto::secret_key &sec,
|
||||||
unsigned int i,
|
unsigned int i,
|
||||||
rct::key & mask,
|
rct::key & mask,
|
||||||
uint64_t & amount);
|
uint64_t & amount);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
url_decode(const std::string& in, std::string& out);
|
url_decode(const std::string& in, std::string& out);
|
||||||
|
|
||||||
map<std::string, std::string>
|
map<std::string, std::string>
|
||||||
parse_crow_post_data(const string& req_body);
|
parse_crow_post_data(const string& req_body);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
get_dummy_account_keys(account_keys& dummy_keys, bool testnet = false);
|
get_dummy_account_keys(account_keys& dummy_keys, bool testnet = false);
|
||||||
|
|
||||||
|
|
||||||
// from wallet2::decrypt
|
// from wallet2::decrypt
|
||||||
string
|
string
|
||||||
decrypt(const std::string &ciphertext,
|
decrypt(const std::string &ciphertext,
|
||||||
const crypto::secret_key &skey,
|
const crypto::secret_key &skey,
|
||||||
bool authenticated = true);
|
bool authenticated = true);
|
||||||
|
|
||||||
// based on
|
// based on
|
||||||
// crypto::public_key wallet2::get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td) const
|
// crypto::public_key wallet2::get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td) const
|
||||||
public_key
|
public_key
|
||||||
get_tx_pub_key_from_received_outs(const transaction &tx);
|
get_tx_pub_key_from_received_outs(const transaction &tx);
|
||||||
|
|
||||||
date::sys_seconds
|
date::sys_seconds
|
||||||
parse(const std::string& str, string format="%Y-%m-%d %H:%M:%S");
|
parse(const std::string& str, string format="%Y-%m-%d %H:%M:%S");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue