mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
tx_details class removed as it is not used
This commit is contained in:
parent
8a731907f5
commit
08e22f4870
7 changed files with 854 additions and 1070 deletions
|
@ -6,13 +6,12 @@ set(SOURCE_HEADERS
|
||||||
MicroCore.h
|
MicroCore.h
|
||||||
tools.h
|
tools.h
|
||||||
monero_headers.h
|
monero_headers.h
|
||||||
tx_details.h)
|
)
|
||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
MicroCore.cpp
|
MicroCore.cpp
|
||||||
tools.cpp
|
tools.cpp
|
||||||
CmdLineOptions.cpp
|
CmdLineOptions.cpp
|
||||||
tx_details.cpp
|
|
||||||
page.h
|
page.h
|
||||||
rpccalls.cpp rpccalls.h version.h.in)
|
rpccalls.cpp rpccalls.h version.h.in)
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "monero_headers.h"
|
#include "monero_headers.h"
|
||||||
#include "tx_details.h"
|
#include "tools.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmreg
|
namespace xmreg
|
||||||
{
|
{
|
||||||
|
|
17
src/page.h
17
src/page.h
|
@ -2210,6 +2210,23 @@ public:
|
||||||
if (it != tx_key_imgs.end())
|
if (it != tx_key_imgs.end())
|
||||||
{
|
{
|
||||||
uint64_t xmr_amount = (*it).amount;
|
uint64_t xmr_amount = (*it).amount;
|
||||||
|
|
||||||
|
// RingCT, i.e., tx version is 2
|
||||||
|
// thus need to decode the amounts
|
||||||
|
// otherwise they all appear to be zero.
|
||||||
|
// so to find the amount, first we need to find
|
||||||
|
// our output in the key images's mixins, and then
|
||||||
|
|
||||||
|
if (tx.version == 2)
|
||||||
|
{
|
||||||
|
// bool r = decode_ringct(tx.rct_signatures,
|
||||||
|
// txd.pk,
|
||||||
|
// prv_view_key,
|
||||||
|
// i,
|
||||||
|
// tx.rct_signatures.ecdhInfo[i].mask,
|
||||||
|
// rct_amount);
|
||||||
|
}
|
||||||
|
|
||||||
key_img_info["amount"] = xmreg::xmr_amount_to_str(xmr_amount);
|
key_img_info["amount"] = xmreg::xmr_amount_to_str(xmr_amount);
|
||||||
total_xmr += xmr_amount;
|
total_xmr += xmr_amount;
|
||||||
}
|
}
|
||||||
|
|
380
src/tools.cpp
380
src/tools.cpp
|
@ -9,15 +9,15 @@
|
||||||
namespace xmreg
|
namespace xmreg
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse key string, e.g., a viewkey in a string
|
* Parse key string, e.g., a viewkey in a string
|
||||||
* into crypto::secret_key or crypto::public_key
|
* into crypto::secret_key or crypto::public_key
|
||||||
* depending on the template argument.
|
* depending on the template argument.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool
|
bool
|
||||||
parse_str_secret_key(const string& key_str, T& secret_key)
|
parse_str_secret_key(const string& key_str, T& secret_key)
|
||||||
{
|
{
|
||||||
|
|
||||||
// hash and keys have same structure, so to parse string of
|
// hash and keys have same structure, so to parse string of
|
||||||
// a key, e.g., a view key, we can first parse it into the hash
|
// a key, e.g., a view key, we can first parse it into the hash
|
||||||
|
@ -38,21 +38,21 @@ namespace xmreg
|
||||||
copy(begin(hash_.data), end(hash_.data), secret_key.data);
|
copy(begin(hash_.data), end(hash_.data), secret_key.data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// explicit instantiations of get template function
|
// explicit instantiations of get template function
|
||||||
template bool parse_str_secret_key<crypto::secret_key>(const string& key_str, crypto::secret_key& secret_key);
|
template bool parse_str_secret_key<crypto::secret_key>(const string& key_str, crypto::secret_key& secret_key);
|
||||||
template bool parse_str_secret_key<crypto::public_key>(const string& key_str, crypto::public_key& secret_key);
|
template bool parse_str_secret_key<crypto::public_key>(const string& key_str, crypto::public_key& secret_key);
|
||||||
template bool parse_str_secret_key<crypto::hash>(const string& key_str, crypto::hash& secret_key);
|
template bool parse_str_secret_key<crypto::hash>(const string& key_str, crypto::hash& secret_key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get transaction tx using given tx hash. Hash is represent as string here,
|
* Get transaction tx using given tx hash. Hash is represent as string here,
|
||||||
* so before we can tap into the blockchain, we need to pare it into
|
* so before we can tap into the blockchain, we need to pare it into
|
||||||
* crypto::hash object.
|
* crypto::hash object.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
get_tx_pub_key_from_str_hash(Blockchain& core_storage, const string& hash_str, transaction& tx)
|
get_tx_pub_key_from_str_hash(Blockchain& core_storage, const string& hash_str, transaction& tx)
|
||||||
{
|
{
|
||||||
crypto::hash tx_hash;
|
crypto::hash tx_hash;
|
||||||
parse_hash256(hash_str, tx_hash);
|
parse_hash256(hash_str, tx_hash);
|
||||||
|
|
||||||
|
@ -68,17 +68,17 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse monero address in a string form into
|
* Parse monero address in a string form into
|
||||||
* cryptonote::account_public_address object
|
* cryptonote::account_public_address object
|
||||||
*/
|
*/
|
||||||
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)
|
bool testnet)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!get_account_address_from_str(address, testnet, address_str))
|
if (!get_account_address_from_str(address, testnet, address_str))
|
||||||
{
|
{
|
||||||
|
@ -87,65 +87,65 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return string representation of monero address
|
* Return string representation of monero address
|
||||||
*/
|
*/
|
||||||
string
|
string
|
||||||
print_address(const account_public_address& address, bool testnet)
|
print_address(const account_public_address& address, bool testnet)
|
||||||
{
|
{
|
||||||
return "<" + get_account_address_as_str(testnet, address) + ">";
|
return "<" + get_account_address_as_str(testnet, address) + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
print_sig (const signature& sig)
|
print_sig (const signature& sig)
|
||||||
{
|
{
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
|
|
||||||
ss << "c: <" << epee::string_tools::pod_to_hex(sig.c) << "> "
|
ss << "c: <" << epee::string_tools::pod_to_hex(sig.c) << "> "
|
||||||
<< "r: <" << epee::string_tools::pod_to_hex(sig.r) << ">";
|
<< "r: <" << epee::string_tools::pod_to_hex(sig.r) << ">";
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a character is a path seprator
|
* Check if a character is a path seprator
|
||||||
*/
|
*/
|
||||||
inline bool
|
inline bool
|
||||||
is_separator(char c)
|
is_separator(char c)
|
||||||
{
|
{
|
||||||
// default linux path separator
|
// default linux path separator
|
||||||
const char separator = PATH_SEPARARTOR;
|
const char separator = PATH_SEPARARTOR;
|
||||||
|
|
||||||
return c == separator;
|
return c == separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove trailinig path separator.
|
* Remove trailinig path separator.
|
||||||
*/
|
*/
|
||||||
string
|
string
|
||||||
remove_trailing_path_separator(const string& in_path)
|
remove_trailing_path_separator(const string& in_path)
|
||||||
{
|
{
|
||||||
string new_string = in_path;
|
string new_string = in_path;
|
||||||
if (!new_string.empty() && is_separator(new_string[new_string.size() - 1]))
|
if (!new_string.empty() && is_separator(new_string[new_string.size() - 1]))
|
||||||
new_string.erase(new_string.size() - 1);
|
new_string.erase(new_string.size() - 1);
|
||||||
return new_string;
|
return new_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
bf::path
|
bf::path
|
||||||
remove_trailing_path_separator(const bf::path& in_path)
|
remove_trailing_path_separator(const bf::path& in_path)
|
||||||
{
|
{
|
||||||
string path_str = in_path.native();
|
string path_str = in_path.native();
|
||||||
return bf::path(remove_trailing_path_separator(path_str));
|
return bf::path(remove_trailing_path_separator(path_str));
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
timestamp_to_str(time_t timestamp, const char* format)
|
timestamp_to_str(time_t timestamp, const char* format)
|
||||||
{
|
{
|
||||||
auto a_time_point = chrono::system_clock::from_time_t(timestamp);
|
auto a_time_point = chrono::system_clock::from_time_t(timestamp);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -163,12 +163,12 @@ namespace xmreg
|
||||||
|
|
||||||
return timestamp_to_str_local(timestamp, format);
|
return timestamp_to_str_local(timestamp, format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
timestamp_to_str_local(time_t timestamp, const char* format)
|
timestamp_to_str_local(time_t timestamp, const char* format)
|
||||||
{
|
{
|
||||||
|
|
||||||
const int TIME_LENGTH = 60;
|
const int TIME_LENGTH = 60;
|
||||||
|
|
||||||
|
@ -182,27 +182,27 @@ namespace xmreg
|
||||||
len = std::strftime(str_buff, TIME_LENGTH, format, tm_ptr);
|
len = std::strftime(str_buff, TIME_LENGTH, format, tm_ptr);
|
||||||
|
|
||||||
return string(str_buff, len);
|
return string(str_buff, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ostream&
|
ostream&
|
||||||
operator<< (ostream& os, const account_public_address& addr)
|
operator<< (ostream& os, const account_public_address& addr)
|
||||||
{
|
{
|
||||||
os << get_account_address_as_str(false, addr);
|
os << get_account_address_as_str(false, addr);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate key_image of foran ith output
|
* Generate key_image of foran ith output
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
generate_key_image(const crypto::key_derivation& derivation,
|
generate_key_image(const crypto::key_derivation& derivation,
|
||||||
const std::size_t i,
|
const std::size_t i,
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
cryptonote::keypair in_ephemeral;
|
cryptonote::keypair in_ephemeral;
|
||||||
|
|
||||||
|
@ -241,12 +241,12 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
get_default_lmdb_folder(bool testnet)
|
get_default_lmdb_folder(bool testnet)
|
||||||
{
|
{
|
||||||
// default path to monero folder
|
// default path to monero folder
|
||||||
// on linux this is /home/<username>/.bitmonero
|
// on linux this is /home/<username>/.bitmonero
|
||||||
string default_monero_dir = tools::get_default_data_dir();
|
string default_monero_dir = tools::get_default_data_dir();
|
||||||
|
@ -258,19 +258,19 @@ namespace xmreg
|
||||||
// the default folder of the lmdb blockchain database
|
// the default folder of the lmdb blockchain database
|
||||||
// is therefore as follows
|
// is therefore as follows
|
||||||
return default_monero_dir + string("/lmdb");
|
return default_monero_dir + string("/lmdb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ge blockchain exception from command line option
|
* Ge blockchain exception from command line option
|
||||||
*
|
*
|
||||||
* If not given, provide default path
|
* If not given, provide default path
|
||||||
*/
|
*/
|
||||||
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)
|
bool testnet)
|
||||||
{
|
{
|
||||||
// the default folder of the lmdb blockchain database
|
// the default folder of the lmdb blockchain database
|
||||||
string default_lmdb_dir = xmreg::get_default_lmdb_folder(testnet);
|
string default_lmdb_dir = xmreg::get_default_lmdb_folder(testnet);
|
||||||
|
|
||||||
|
@ -290,12 +290,12 @@ namespace xmreg
|
||||||
blockchain_path = xmreg::remove_trailing_path_separator(blockchain_path);
|
blockchain_path = xmreg::remove_trailing_path_separator(blockchain_path);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
sum_money_in_outputs(const transaction& tx)
|
sum_money_in_outputs(const transaction& tx)
|
||||||
{
|
{
|
||||||
uint64_t sum_xmr {0};
|
uint64_t sum_xmr {0};
|
||||||
|
|
||||||
for (const tx_out& txout: tx.vout)
|
for (const tx_out& txout: tx.vout)
|
||||||
|
@ -304,13 +304,13 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum_xmr;
|
return sum_xmr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
sum_money_in_inputs(const transaction& tx)
|
sum_money_in_inputs(const transaction& tx)
|
||||||
{
|
{
|
||||||
uint64_t sum_xmr {0};
|
uint64_t sum_xmr {0};
|
||||||
|
|
||||||
size_t input_no = tx.vin.size();
|
size_t input_no = tx.vin.size();
|
||||||
|
@ -331,25 +331,25 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum_xmr;
|
return sum_xmr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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> sum_xmr;
|
array<uint64_t, 2> sum_xmr;
|
||||||
|
|
||||||
sum_xmr[0] = sum_money_in_inputs(tx);
|
sum_xmr[0] = sum_money_in_inputs(tx);
|
||||||
sum_xmr[1] = sum_money_in_outputs(tx);
|
sum_xmr[1] = sum_money_in_outputs(tx);
|
||||||
|
|
||||||
return sum_xmr;
|
return sum_xmr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
array<uint64_t, 2>
|
array<uint64_t, 2>
|
||||||
sum_money_in_txs(const vector<transaction>& txs)
|
sum_money_in_txs(const vector<transaction>& txs)
|
||||||
{
|
{
|
||||||
array<uint64_t, 2> sum_xmr {0,0};
|
array<uint64_t, 2> sum_xmr {0,0};
|
||||||
|
|
||||||
for (const transaction& tx: txs)
|
for (const transaction& tx: txs)
|
||||||
|
@ -359,12 +359,12 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum_xmr;
|
return sum_xmr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
sum_fees_in_txs(const vector<transaction>& txs)
|
sum_fees_in_txs(const vector<transaction>& txs)
|
||||||
{
|
{
|
||||||
uint64_t fees_sum {0};
|
uint64_t fees_sum {0};
|
||||||
|
|
||||||
for (const transaction& tx: txs)
|
for (const transaction& tx: txs)
|
||||||
|
@ -373,13 +373,13 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return fees_sum;
|
return fees_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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<pair<txout_to_key, uint64_t>> outputs;
|
vector<pair<txout_to_key, uint64_t>> outputs;
|
||||||
|
|
||||||
for (const tx_out& txout: tx.vout)
|
for (const tx_out& txout: tx.vout)
|
||||||
|
@ -398,11 +398,11 @@ namespace xmreg
|
||||||
|
|
||||||
return outputs;
|
return outputs;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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<tuple<txout_to_key, uint64_t, uint64_t>> outputs;
|
vector<tuple<txout_to_key, uint64_t, uint64_t>> outputs;
|
||||||
|
|
||||||
for (uint64_t n = 0; n < tx.vout.size(); ++n)
|
for (uint64_t n = 0; n < tx.vout.size(); ++n)
|
||||||
|
@ -421,11 +421,11 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return outputs;
|
return outputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
get_mixin_no(const transaction& tx)
|
get_mixin_no(const transaction& tx)
|
||||||
{
|
{
|
||||||
uint64_t mixin_no {0};
|
uint64_t mixin_no {0};
|
||||||
|
|
||||||
size_t input_no = tx.vin.size();
|
size_t input_no = tx.vin.size();
|
||||||
|
@ -453,11 +453,11 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return mixin_no;
|
return mixin_no;
|
||||||
}
|
}
|
||||||
|
|
||||||
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<uint64_t> mixin_no;
|
vector<uint64_t> mixin_no;
|
||||||
|
|
||||||
for (const transaction& tx: txs)
|
for (const transaction& tx: txs)
|
||||||
|
@ -466,12 +466,12 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return mixin_no;
|
return mixin_no;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<txin_to_key>
|
vector<txin_to_key>
|
||||||
get_key_images(const transaction& tx)
|
get_key_images(const transaction& tx)
|
||||||
{
|
{
|
||||||
vector<txin_to_key> key_images;
|
vector<txin_to_key> key_images;
|
||||||
|
|
||||||
size_t input_no = tx.vin.size();
|
size_t input_no = tx.vin.size();
|
||||||
|
@ -492,14 +492,14 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return key_images;
|
return key_images;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
payment_id = null_hash;
|
payment_id = null_hash;
|
||||||
payment_id8 = null_hash8;
|
payment_id8 = null_hash8;
|
||||||
|
|
||||||
|
@ -526,21 +526,21 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
return get_payment_id(tx.extra, payment_id, payment_id8);
|
return get_payment_id(tx.extra, payment_id, payment_id8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
array<size_t, 5>
|
array<size_t, 5>
|
||||||
timestamp_difference(uint64_t t1, uint64_t t2)
|
timestamp_difference(uint64_t t1, uint64_t t2)
|
||||||
{
|
{
|
||||||
|
|
||||||
uint64_t timestamp_diff = t1 - t2;
|
uint64_t timestamp_diff = t1 - t2;
|
||||||
|
|
||||||
|
@ -572,12 +572,12 @@ namespace xmreg
|
||||||
time_diff_hours, time_diff_minutes,
|
time_diff_hours, time_diff_minutes,
|
||||||
time_diff_seconds};
|
time_diff_seconds};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
read(string filename)
|
read(string filename)
|
||||||
{
|
{
|
||||||
if (!bf::exists(bf::path(filename)))
|
if (!bf::exists(bf::path(filename)))
|
||||||
{
|
{
|
||||||
cerr << "File does not exist: " << filename << endl;
|
cerr << "File does not exist: " << filename << endl;
|
||||||
|
@ -587,14 +587,14 @@ namespace xmreg
|
||||||
std::ifstream t(filename);
|
std::ifstream t(filename);
|
||||||
return string(std::istreambuf_iterator<char>(t),
|
return string(std::istreambuf_iterator<char>(t),
|
||||||
std::istreambuf_iterator<char>());
|
std::istreambuf_iterator<char>());
|
||||||
}
|
}
|
||||||
|
|
||||||
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 timeN,
|
||||||
uint64_t resolution,
|
uint64_t resolution,
|
||||||
uint64_t time0)
|
uint64_t time0)
|
||||||
{
|
{
|
||||||
string empty_time = string(resolution, '_');
|
string empty_time = string(resolution, '_');
|
||||||
|
|
||||||
size_t time_axis_length = empty_time.size();
|
size_t time_axis_length = empty_time.size();
|
||||||
|
@ -619,26 +619,26 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return make_pair(empty_time, scale);
|
return make_pair(empty_time, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// useful reference to get epoch time in correct timezon
|
// useful reference to get epoch time in correct timezon
|
||||||
// http://www.boost.org/doc/libs/1_41_0/doc/html/date_time/examples.html#date_time.examples.seconds_since_epoch
|
// http://www.boost.org/doc/libs/1_41_0/doc/html/date_time/examples.html#date_time.examples.seconds_since_epoch
|
||||||
time_t
|
time_t
|
||||||
ptime_to_time_t(const pt::ptime& in_ptime)
|
ptime_to_time_t(const pt::ptime& in_ptime)
|
||||||
{
|
{
|
||||||
static pt::ptime epoch(gt::date(1970, 1, 1));
|
static pt::ptime epoch(gt::date(1970, 1, 1));
|
||||||
pt::time_duration::sec_type no_seconds = (in_ptime - epoch).total_seconds();
|
pt::time_duration::sec_type no_seconds = (in_ptime - epoch).total_seconds();
|
||||||
return time_t(no_seconds);
|
return time_t(no_seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
crypto::key_derivation derivation;
|
crypto::key_derivation derivation;
|
||||||
|
|
||||||
bool r = crypto::generate_key_derivation(pub, sec, derivation);
|
bool r = crypto::generate_key_derivation(pub, sec, derivation);
|
||||||
|
@ -681,11 +681,11 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
url_decode(const std::string& in, std::string& out)
|
url_decode(const std::string& in, std::string& out)
|
||||||
{
|
{
|
||||||
out.clear();
|
out.clear();
|
||||||
out.reserve(in.size());
|
out.reserve(in.size());
|
||||||
for (std::size_t i = 0; i < in.size(); ++i)
|
for (std::size_t i = 0; i < in.size(); ++i)
|
||||||
|
@ -721,11 +721,11 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
map<std::string, std::string> body;
|
map<std::string, std::string> body;
|
||||||
|
|
||||||
vector<string> vec;
|
vector<string> vec;
|
||||||
|
@ -748,11 +748,11 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
get_dummy_account_keys(account_keys& dummy_keys, bool testnet)
|
get_dummy_account_keys(account_keys& dummy_keys, bool testnet)
|
||||||
{
|
{
|
||||||
secret_key adress_prv_viewkey;
|
secret_key adress_prv_viewkey;
|
||||||
secret_key adress_prv_spendkey;
|
secret_key adress_prv_spendkey;
|
||||||
|
|
||||||
|
@ -784,16 +784,16 @@ namespace xmreg
|
||||||
};
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 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)
|
bool authenticated)
|
||||||
{
|
{
|
||||||
|
|
||||||
const size_t prefix_size = sizeof(chacha8_iv)
|
const size_t prefix_size = sizeof(chacha8_iv)
|
||||||
+ (authenticated ? sizeof(crypto::signature) : 0);
|
+ (authenticated ? sizeof(crypto::signature) : 0);
|
||||||
|
@ -836,13 +836,13 @@ namespace xmreg
|
||||||
key, iv, &plaintext[0]);
|
key, iv, &plaintext[0]);
|
||||||
|
|
||||||
return plaintext;
|
return plaintext;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
std::vector<tx_extra_field> tx_extra_fields;
|
std::vector<tx_extra_field> tx_extra_fields;
|
||||||
|
|
||||||
if(!parse_tx_extra(tx.extra, tx_extra_fields))
|
if(!parse_tx_extra(tx.extra, tx_extra_fields))
|
||||||
|
@ -880,11 +880,11 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
return null_pkey;
|
return null_pkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
date::sys_seconds
|
date::sys_seconds
|
||||||
parse(const std::string& str, string format)
|
parse(const std::string& str, string format)
|
||||||
{
|
{
|
||||||
std::istringstream in(str);
|
std::istringstream in(str);
|
||||||
date::sys_seconds tp;
|
date::sys_seconds tp;
|
||||||
in >> date::parse(format, tp);
|
in >> date::parse(format, tp);
|
||||||
|
@ -895,8 +895,58 @@ namespace xmreg
|
||||||
in >> date::parse(format, tp);
|
in >> date::parse(format, tp);
|
||||||
}
|
}
|
||||||
return tp;
|
return tp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if given output (specified by output_index)
|
||||||
|
* belongs is ours based
|
||||||
|
* on our private view key and public spend key
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
is_output_ours(const size_t& output_index,
|
||||||
|
const transaction& tx,
|
||||||
|
const public_key& pub_tx_key,
|
||||||
|
const secret_key& private_view_key,
|
||||||
|
const public_key& public_spend_key)
|
||||||
|
{
|
||||||
|
// public transaction key is combined with our viewkey
|
||||||
|
// to create, so called, derived key.
|
||||||
|
key_derivation derivation;
|
||||||
|
|
||||||
|
if (!generate_key_derivation(pub_tx_key, private_view_key, derivation))
|
||||||
|
{
|
||||||
|
cerr << "Cant get dervied key for: " << "\n"
|
||||||
|
<< "pub_tx_key: " << pub_tx_key << " and "
|
||||||
|
<< "prv_view_key" << private_view_key << endl;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get the tx output public key
|
||||||
|
// that normally would be generated for us,
|
||||||
|
// if someone had sent us some xmr.
|
||||||
|
public_key pubkey;
|
||||||
|
|
||||||
|
derive_public_key(derivation,
|
||||||
|
output_index,
|
||||||
|
public_spend_key,
|
||||||
|
pubkey);
|
||||||
|
|
||||||
|
//cout << "\n" << tx.vout.size() << " " << output_index << endl;
|
||||||
|
|
||||||
|
// get tx output public key
|
||||||
|
const txout_to_key tx_out_to_key
|
||||||
|
= boost::get<txout_to_key>(tx.vout[output_index].target);
|
||||||
|
|
||||||
|
|
||||||
|
if (tx_out_to_key.key == pubkey)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
a_hash.substr(1, a_hash.size()-2)
|
a_hash.substr(1, a_hash.size()-2)
|
||||||
|
|
||||||
#include "monero_headers.h"
|
#include "monero_headers.h"
|
||||||
#include "tx_details.h"
|
|
||||||
|
|
||||||
#include "../ext/infix_iterator.h"
|
#include "../ext/infix_iterator.h"
|
||||||
#include "../ext/date/tz.h"
|
#include "../ext/date/tz.h"
|
||||||
|
@ -249,6 +248,13 @@ xmr_amount_to_str(const uint64_t& xmr_amount, string format="{:0.12f}")
|
||||||
return fmt::format("{:0.12f}", XMR_AMOUNT(xmr_amount));
|
return fmt::format("{:0.12f}", XMR_AMOUNT(xmr_amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
is_output_ours(const size_t& output_index,
|
||||||
|
const transaction& tx,
|
||||||
|
const public_key& pub_tx_key,
|
||||||
|
const secret_key& private_view_key,
|
||||||
|
const public_key& public_spend_key);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //XMREG01_TOOLS_H
|
#endif //XMREG01_TOOLS_H
|
||||||
|
|
|
@ -1,223 +0,0 @@
|
||||||
//
|
|
||||||
// Created by mwo on 14/11/15.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "tx_details.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace xmreg
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
crypto::hash
|
|
||||||
transfer_details::tx_hash() const
|
|
||||||
{
|
|
||||||
return get_transaction_hash(m_tx);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint64_t
|
|
||||||
transfer_details::amount() const
|
|
||||||
{
|
|
||||||
return m_tx.vout[m_internal_output_index].amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ostream&
|
|
||||||
operator<<(ostream& os, const transfer_details& td)
|
|
||||||
{
|
|
||||||
os << "Block: " << td.m_block_height
|
|
||||||
<< " time: " << timestamp_to_str(td.m_block_timestamp)
|
|
||||||
<< " tx hash: " << td.tx_hash()
|
|
||||||
<< " out idx: " << td.m_internal_output_index
|
|
||||||
<< " amount: " << print_money(td.amount());
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get tx outputs associated with the given private view and public spend keys
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
vector<xmreg::transfer_details>
|
|
||||||
get_belonging_outputs(const block& blk,
|
|
||||||
const transaction& tx,
|
|
||||||
const secret_key& private_view_key,
|
|
||||||
const public_key& public_spend_key,
|
|
||||||
uint64_t block_height)
|
|
||||||
{
|
|
||||||
// vector to be returned
|
|
||||||
vector<xmreg::transfer_details> our_outputs;
|
|
||||||
|
|
||||||
|
|
||||||
// get transaction's public key
|
|
||||||
public_key pub_tx_key = get_tx_pub_key_from_extra(tx);
|
|
||||||
|
|
||||||
// check if transaction has valid public key
|
|
||||||
// if no, then skip
|
|
||||||
if (pub_tx_key == null_pkey)
|
|
||||||
{
|
|
||||||
return our_outputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// get the total number of outputs in a transaction.
|
|
||||||
size_t output_no = tx.vout.size();
|
|
||||||
|
|
||||||
// check if the given transaction has any outputs
|
|
||||||
// if no, then finish
|
|
||||||
if (output_no == 0)
|
|
||||||
{
|
|
||||||
return our_outputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// public transaction key is combined with our viewkey
|
|
||||||
// to create, so called, derived key.
|
|
||||||
key_derivation derivation;
|
|
||||||
|
|
||||||
if (!generate_key_derivation(pub_tx_key, private_view_key, derivation))
|
|
||||||
{
|
|
||||||
cerr << "Cant get dervied key for: " << "\n"
|
|
||||||
<< "pub_tx_key: " << private_view_key << " and "
|
|
||||||
<< "prv_view_key" << private_view_key << endl;
|
|
||||||
return our_outputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// each tx that we (or the address we are checking) received
|
|
||||||
// contains a number of outputs.
|
|
||||||
// some of them are ours, some not. so we need to go through
|
|
||||||
// all of them in a given tx block, to check which outputs are ours.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// sum amount of xmr sent to us
|
|
||||||
// in the given transaction
|
|
||||||
uint64_t money_transfered {0};
|
|
||||||
|
|
||||||
// loop through outputs in the given tx
|
|
||||||
// to check which outputs our ours. we compare outputs'
|
|
||||||
// public keys with the public key that would had been
|
|
||||||
// generated for us if we had gotten the outputs.
|
|
||||||
// not sure this is the case though, but that's my understanding.
|
|
||||||
for (size_t i = 0; i < output_no; ++i)
|
|
||||||
{
|
|
||||||
// get the tx output public key
|
|
||||||
// that normally would be generated for us,
|
|
||||||
// if someone had sent us some xmr.
|
|
||||||
public_key pubkey;
|
|
||||||
|
|
||||||
derive_public_key(derivation,
|
|
||||||
i,
|
|
||||||
public_spend_key,
|
|
||||||
pubkey);
|
|
||||||
|
|
||||||
// get tx output public key
|
|
||||||
const txout_to_key tx_out_to_key
|
|
||||||
= boost::get<txout_to_key>(tx.vout[i].target);
|
|
||||||
|
|
||||||
|
|
||||||
//cout << "Output no: " << i << ", " << tx_out_to_key.key;
|
|
||||||
|
|
||||||
// check if the output's public key is ours
|
|
||||||
if (tx_out_to_key.key == pubkey)
|
|
||||||
{
|
|
||||||
// if so, then add this output to the
|
|
||||||
// returned vector
|
|
||||||
//our_outputs.push_back(tx.vout[i]);
|
|
||||||
our_outputs.push_back(
|
|
||||||
xmreg::transfer_details {block_height,
|
|
||||||
blk.timestamp,
|
|
||||||
tx, i, false}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return our_outputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if given output (specified by output_index)
|
|
||||||
* belongs is ours based
|
|
||||||
* on our private view key and public spend key
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
is_output_ours(const size_t& output_index,
|
|
||||||
const transaction& tx,
|
|
||||||
const secret_key& private_view_key,
|
|
||||||
const public_key& public_spend_key)
|
|
||||||
{
|
|
||||||
// get transaction's public key
|
|
||||||
public_key pub_tx_key = get_tx_pub_key_from_extra(tx);
|
|
||||||
|
|
||||||
// check if transaction has valid public key
|
|
||||||
// if no, then skip
|
|
||||||
if (pub_tx_key == null_pkey)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public transaction key is combined with our viewkey
|
|
||||||
// to create, so called, derived key.
|
|
||||||
key_derivation derivation;
|
|
||||||
|
|
||||||
if (!generate_key_derivation(pub_tx_key, private_view_key, derivation))
|
|
||||||
{
|
|
||||||
cerr << "Cant get dervied key for: " << "\n"
|
|
||||||
<< "pub_tx_key: " << pub_tx_key << " and "
|
|
||||||
<< "prv_view_key" << private_view_key << endl;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// get the tx output public key
|
|
||||||
// that normally would be generated for us,
|
|
||||||
// if someone had sent us some xmr.
|
|
||||||
public_key pubkey;
|
|
||||||
|
|
||||||
derive_public_key(derivation,
|
|
||||||
output_index,
|
|
||||||
public_spend_key,
|
|
||||||
pubkey);
|
|
||||||
|
|
||||||
//cout << "\n" << tx.vout.size() << " " << output_index << endl;
|
|
||||||
|
|
||||||
// get tx output public key
|
|
||||||
const txout_to_key tx_out_to_key
|
|
||||||
= boost::get<txout_to_key>(tx.vout[output_index].target);
|
|
||||||
|
|
||||||
|
|
||||||
if (tx_out_to_key.key == pubkey)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
csv::ofstream&
|
|
||||||
operator<<(csv::ofstream& ostm, const xmreg::transfer_details& td)
|
|
||||||
{
|
|
||||||
|
|
||||||
ostm << xmreg::timestamp_to_str(td.m_block_timestamp, "%F");
|
|
||||||
ostm << xmreg::timestamp_to_str(td.m_block_timestamp, "%T");
|
|
||||||
ostm << td.m_block_height;
|
|
||||||
ostm << td.tx_hash();
|
|
||||||
ostm << td.m_internal_output_index;
|
|
||||||
ostm << cryptonote::print_money(td.amount());
|
|
||||||
|
|
||||||
return ostm;
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
//
|
|
||||||
// Created by mwo on 14/11/15.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef XMR2CSV_TXDATA_H
|
|
||||||
#define XMR2CSV_TXDATA_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "../ext/minicsv.h"
|
|
||||||
|
|
||||||
#include "monero_headers.h"
|
|
||||||
#include "tools.h"
|
|
||||||
|
|
||||||
namespace xmreg
|
|
||||||
{
|
|
||||||
|
|
||||||
using namespace cryptonote;
|
|
||||||
using namespace crypto;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
struct transfer_details
|
|
||||||
{
|
|
||||||
uint64_t m_block_height;
|
|
||||||
uint64_t m_block_timestamp;
|
|
||||||
transaction m_tx;
|
|
||||||
size_t m_internal_output_index;
|
|
||||||
bool m_spent;
|
|
||||||
|
|
||||||
|
|
||||||
crypto::hash tx_hash() const;
|
|
||||||
|
|
||||||
uint64_t amount() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ostream&
|
|
||||||
operator<<(ostream& os, const transfer_details& dt);
|
|
||||||
|
|
||||||
|
|
||||||
vector<xmreg::transfer_details>
|
|
||||||
get_belonging_outputs(const block& blk,
|
|
||||||
const transaction& tx,
|
|
||||||
const secret_key& private_view_key,
|
|
||||||
const public_key& public_spend_key,
|
|
||||||
uint64_t block_height = 0);
|
|
||||||
|
|
||||||
bool
|
|
||||||
is_output_ours(const size_t& output_index,
|
|
||||||
const transaction& tx,
|
|
||||||
const secret_key& private_view_key,
|
|
||||||
const public_key& public_spend_key);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
csv::ostringstream&
|
|
||||||
operator<<(csv::ostringstream& ostm, const xmreg::transfer_details& td);
|
|
||||||
|
|
||||||
|
|
||||||
#endif //XMR2CSV_TXDATA_H
|
|
Loading…
Add table
Add a link
Reference in a new issue