Merge branch 'master' into devel

master
moneroexamples 2 years ago committed by GitHub
commit 296836b639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,6 +2,7 @@
FROM ubuntu:20.04 as builder FROM ubuntu:20.04 as builder
# Set Monero branch/tag to be used for monerod compilation # Set Monero branch/tag to be used for monerod compilation
ARG MONERO_BRANCH=release-v18 ARG MONERO_BRANCH=release-v18
# Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation # Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation

@ -24,26 +24,27 @@ Monero C++ libraries, but also demonstrates how to use:
## Explorer hosts ## Explorer hosts
Clearnet versions: Clearnet versions:
- [https://xmrchain.net/](https://xmrchain.net/) - https enabled, most popular and very stable. - [https://xmrchain.net/](https://xmrchain.net/) - HTTPS enabled, most popular, and very stable.
- [https://monerohash.com/explorer/](https://monerohash.com/explorer/) - nice looking one, https enabled. - [https://monerohash.com/explorer/](https://monerohash.com/explorer/) - nice looking one, HTTPS enabled.
- [http://monerochain.com/](http://monerochain.com/) - JSON API based, multiple nodes. - [http://monerochain.com/](http://monerochain.com/) - JSON API based, multiple nodes.
- [https://blox.minexmr.com/](https://blox.minexmr.com/) - - https enabled. - [https://blox.minexmr.com/](https://blox.minexmr.com/) - HTTPS enabled.
- [https://community.xmr.to/explorer/mainnet/](https://community.xmr.to/explorer/mainnet/)
Testnet version: Testnet version:
- [https://testnet.xmrchain.com/](https://testnet.xmrchain.com/) - https enabled. - [https://testnet.xmrchain.com/](https://testnet.xmrchain.com/) - https enabled.
- [https://community.xmr.to/explorer/testnet/](https://community.xmr.to/explorer/testnet/)
Stagenet version: Stagenet version:
- [https://stagenet.xmrchain.net/](https://stagenet.xmrchain.net/) - [https://stagenet.xmrchain.net/](https://stagenet.xmrchain.net/)
- [https://community.xmr.to/explorer/stagenet/](https://community.xmr.to/explorer/stagenet/)
i2p users (main Monero network): i2p users (main Monero network):
- [http://7o4gezpkye6ekibhgpkg7v626ze4idsirapufzrefkdysa6zxhha.b32.i2p/](http://7o4gezpkye6ekibhgpkg7v626ze4idsirapufzrefkdysa6zxhha.b32.i2p/) - [http://7o4gezpkye6ekibhgpkg7v626ze4idsirapufzrefkdysa6zxhha.b32.i2p/](http://7o4gezpkye6ekibhgpkg7v626ze4idsirapufzrefkdysa6zxhha.b32.i2p/)
Tor versions:
- [http://exploredv42tq2nowrll6f27nuymenndwupueqvyugaqzbrvmjhhceqd.onion/](http://exploredv42tq2nowrll6f27nuymenndwupueqvyugaqzbrvmjhhceqd.onion/) - Native v3 Onion, JSON API enabled, emission enabled, rawtx enabled.
Alternative block explorers: Alternative block explorers:
- [https://localmonero.co/blocks](https://localmonero.co/blocks) - [https://localmonero.co/blocks](https://localmonero.co/blocks)
@ -235,16 +236,6 @@ docker-compose up -d
When running via Docker, please use something like [Traefik](https://doc.traefik.io/traefik/) or [enable SSL](#enable-ssl-https) to secure communications. When running via Docker, please use something like [Traefik](https://doc.traefik.io/traefik/) or [enable SSL](#enable-ssl-https) to secure communications.
## The explorer's command line options ## The explorer's command line options
``` ```
@ -297,7 +288,7 @@ xmrblocks, Onion Monero Blockchain Explorer:
functionality functionality
--ssl-key-file arg path to key file for ssl (https) --ssl-key-file arg path to key file for ssl (https)
functionality functionality
-d [ --deamon-url ] arg (=127.0.0.1:18081) -d [ --daemon-url ] arg (=http:://127.0.0.1:18081)
Monero daemon url Monero daemon url
--daemon-login arg Specify username[:password] for daemon --daemon-login arg Specify username[:password] for daemon
RPC client RPC client
@ -326,7 +317,6 @@ docker run -it -d -v <path-to-monero-blockchain-on-the-host>:/home/monero/.bitmo
Make sure to always start the portion of command line flags with `./xmrblocks` and set any flags you would like after that, as shown above. Make sure to always start the portion of command line flags with `./xmrblocks` and set any flags you would like after that, as shown above.
## Enable Monero emission ## Enable Monero emission
Obtaining current Monero emission amount is not straight forward. Thus, by default it is Obtaining current Monero emission amount is not straight forward. Thus, by default it is

@ -56,7 +56,7 @@ main(int ac, const char* av[])
auto port_opt = opts.get_option<string>("port"); auto port_opt = opts.get_option<string>("port");
auto bindaddr_opt = opts.get_option<string>("bindaddr"); auto bindaddr_opt = opts.get_option<string>("bindaddr");
auto bc_path_opt = opts.get_option<string>("bc-path"); auto bc_path_opt = opts.get_option<string>("bc-path");
auto deamon_url_opt = opts.get_option<string>("deamon-url"); auto daemon_url_opt = opts.get_option<string>("daemon-url");
auto ssl_crt_file_opt = opts.get_option<string>("ssl-crt-file"); auto ssl_crt_file_opt = opts.get_option<string>("ssl-crt-file");
auto ssl_key_file_opt = opts.get_option<string>("ssl-key-file"); auto ssl_key_file_opt = opts.get_option<string>("ssl-key-file");
auto no_blocks_on_index_opt = opts.get_option<string>("no-blocks-on-index"); auto no_blocks_on_index_opt = opts.get_option<string>("no-blocks-on-index");
@ -206,13 +206,13 @@ main(int ac, const char* av[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
string deamon_url {*deamon_url_opt}; string daemon_url {*daemon_url_opt};
if (testnet && deamon_url == "127.0.0.1:18081") if (testnet && deamon_url == "127.0.0.1:18081")
deamon_url = "127.0.0.1:28081"; deamon_url = "127.0.0.1:28081";
if (stagenet && deamon_url == "127.0.0.1:18081") if (stagenet && deamon_url == "127.0.0.1:18081")
deamon_url = "127.0.0.1:38081"; deamon_url = "127.0.0.1:38081";
uint64_t mempool_info_timeout {5000}; uint64_t mempool_info_timeout {5000};
try try
@ -248,8 +248,8 @@ main(int ac, const char* av[])
= blockchain_path; = blockchain_path;
xmreg::CurrentBlockchainStatus::nettype xmreg::CurrentBlockchainStatus::nettype
= nettype; = nettype;
xmreg::CurrentBlockchainStatus::deamon_url xmreg::CurrentBlockchainStatus::daemon_url
= deamon_url; = daemon_url;
xmreg::CurrentBlockchainStatus::set_blockchain_variables( xmreg::CurrentBlockchainStatus::set_blockchain_variables(
&mcore, core_storage); &mcore, core_storage);
@ -265,8 +265,8 @@ main(int ac, const char* av[])
= blockchain_path; = blockchain_path;
xmreg::MempoolStatus::nettype xmreg::MempoolStatus::nettype
= nettype; = nettype;
xmreg::MempoolStatus::deamon_url xmreg::MempoolStatus::daemon_url
= deamon_url; = daemon_url;
xmreg::MempoolStatus::login xmreg::MempoolStatus::login
= daemon_rpc_login; = daemon_rpc_login;
xmreg::MempoolStatus::set_blockchain_variables( xmreg::MempoolStatus::set_blockchain_variables(
@ -300,7 +300,7 @@ main(int ac, const char* av[])
// contains logic for the website // contains logic for the website
xmreg::page xmrblocks(&mcore, xmreg::page xmrblocks(&mcore,
core_storage, core_storage,
deamon_url, daemon_url,
nettype, nettype,
enable_pusher, enable_pusher,
enable_randomx, enable_randomx,

@ -71,7 +71,7 @@ namespace xmreg
"path to key file for ssl (https) functionality") "path to key file for ssl (https) functionality")
("daemon-login", value<string>(), ("daemon-login", value<string>(),
"Specify username[:password] for daemon RPC client") "Specify username[:password] for daemon RPC client")
("deamon-url,d", value<string>()->default_value("127.0.0.1:18081"), ("daemon-url,d", value<string>()->default_value("127.0.0.1:18081"),
"Monero daemon url") "Monero daemon url")
("enable-mixin-guess", value<bool>()->default_value(false)->implicit_value(true), ("enable-mixin-guess", value<bool>()->default_value(false)->implicit_value(true),
"enable guessing real outputs in key images based on viewkey"); "enable guessing real outputs in key images based on viewkey");

@ -303,7 +303,7 @@ cryptonote::network_type CurrentBlockchainStatus::nettype {cryptonote::network_t
string CurrentBlockchainStatus::output_file {"emission_amount.txt"}; string CurrentBlockchainStatus::output_file {"emission_amount.txt"};
string CurrentBlockchainStatus::deamon_url {"http:://127.0.0.1:18081"}; string CurrentBlockchainStatus::daemon_url {"http:://127.0.0.1:18081"};
uint64_t CurrentBlockchainStatus::blockchain_chunk_size {10000}; uint64_t CurrentBlockchainStatus::blockchain_chunk_size {10000};

@ -51,7 +51,7 @@ struct CurrentBlockchainStatus
static string output_file; static string output_file;
static string deamon_url; static string daemon_url;
// how many blocks to read before thread goes to sleep // how many blocks to read before thread goes to sleep
static uint64_t blockchain_chunk_size; static uint64_t blockchain_chunk_size;

@ -96,7 +96,7 @@ MempoolStatus::start_mempool_status_thread()
bool bool
MempoolStatus::read_mempool() MempoolStatus::read_mempool()
{ {
rpccalls rpc {deamon_url, login}; rpccalls rpc {daemon_url, login};
string error_msg; string error_msg;
@ -222,7 +222,7 @@ MempoolStatus::read_mempool()
bool bool
MempoolStatus::read_network_info() MempoolStatus::read_network_info()
{ {
rpccalls rpc {deamon_url, login}; rpccalls rpc {daemon_url, login};
COMMAND_RPC_GET_INFO::response rpc_network_info; COMMAND_RPC_GET_INFO::response rpc_network_info;
@ -329,7 +329,7 @@ MempoolStatus::is_thread_running()
} }
bf::path MempoolStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"}; bf::path MempoolStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"};
string MempoolStatus::deamon_url {"http:://127.0.0.1:18081"}; string MempoolStatus::daemon_url {"http:://127.0.0.1:18081"};
cryptonote::network_type MempoolStatus::nettype {cryptonote::network_type::MAINNET}; cryptonote::network_type MempoolStatus::nettype {cryptonote::network_type::MAINNET};
atomic<bool> MempoolStatus::is_running {false}; atomic<bool> MempoolStatus::is_running {false};
boost::thread MempoolStatus::m_thread; boost::thread MempoolStatus::m_thread;

@ -125,7 +125,7 @@ struct MempoolStatus
static atomic<uint64_t> mempool_size; // size in bytes. static atomic<uint64_t> mempool_size; // size in bytes.
static bf::path blockchain_path; static bf::path blockchain_path;
static string deamon_url; static string daemon_url;
static cryptonote::network_type nettype; static cryptonote::network_type nettype;
static rpccalls::login_opt login; static rpccalls::login_opt login;

@ -499,7 +499,7 @@ public:
page(MicroCore* _mcore, page(MicroCore* _mcore,
Blockchain* _core_storage, Blockchain* _core_storage,
string _deamon_url, string _daemon_url,
cryptonote::network_type _nettype, cryptonote::network_type _nettype,
bool _enable_pusher, bool _enable_pusher,
bool _enable_randomx, bool _enable_randomx,
@ -517,7 +517,7 @@ page(MicroCore* _mcore,
rpccalls::login_opt _daemon_rpc_login) rpccalls::login_opt _daemon_rpc_login)
: mcore {_mcore}, : mcore {_mcore},
core_storage {_core_storage}, core_storage {_core_storage},
rpc {_deamon_url, _daemon_rpc_login}, rpc {_daemon_url, _daemon_rpc_login},
server_timestamp {std::time(nullptr)}, server_timestamp {std::time(nullptr)},
nettype {_nettype}, nettype {_nettype},
enable_pusher {_enable_pusher}, enable_pusher {_enable_pusher},
@ -1436,6 +1436,7 @@ show_block_hex(size_t block_height, bool complete_blk)
epee::byte_slice complete_block_data_slice; epee::byte_slice complete_block_data_slice;
if(!epee::serialization::store_t_to_binary( if(!epee::serialization::store_t_to_binary(
complete_block_data, complete_block_data_slice)) complete_block_data, complete_block_data_slice))
{ {
@ -1447,6 +1448,7 @@ show_block_hex(size_t block_height, bool complete_blk)
complete_block_data_slice.begin(), complete_block_data_slice.begin(),
complete_block_data_slice.end()); complete_block_data_slice.end());
return epee::string_tools return epee::string_tools
::buff_to_hex_nodelimer(block_data_str); ::buff_to_hex_nodelimer(block_data_str);
} }
@ -2203,6 +2205,8 @@ show_my_outputs(string tx_hash_str,
// check if generated public key matches the current output's key // check if generated public key matches the current output's key
bool mine_output = (std::get<0>(outp) == tx_pubkey); bool mine_output = (std::get<0>(outp) == tx_pubkey);
bool with_additional = false; bool with_additional = false;
if (!mine_output && txd.additional_pks.size() if (!mine_output && txd.additional_pks.size()

@ -9,13 +9,13 @@ namespace xmreg
rpccalls::rpccalls( rpccalls::rpccalls(
string _deamon_url, string _daemon_url,
login_opt login, login_opt login,
uint64_t _timeout) uint64_t _timeout)
: deamon_url {_deamon_url}, : daemon_url {_daemon_url},
timeout_time {_timeout} timeout_time {_timeout}
{ {
epee::net_utils::parse_url(deamon_url, url); epee::net_utils::parse_url(daemon_url, url);
port = std::to_string(url.port); port = std::to_string(url.port);
@ -23,12 +23,13 @@ rpccalls::rpccalls(
m_http_client.set_server( m_http_client.set_server(
deamon_url, deamon_url,
login, login,
epee::net_utils::ssl_support_t::e_ssl_support_disabled); epee::net_utils::ssl_support_t::e_ssl_support_disabled);
} }
bool bool
rpccalls::connect_to_monero_deamon() rpccalls::connect_to_monero_daemon()
{ {
//std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex); //std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
@ -48,9 +49,9 @@ rpccalls::get_current_height()
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex); std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
if (!connect_to_monero_deamon()) if (!connect_to_monero_daemon())
{ {
cerr << "get_current_height: not connected to deamon" << endl; cerr << "get_current_height: not connected to daemon" << endl;
return false; return false;
} }
@ -60,8 +61,8 @@ rpccalls::get_current_height()
if (!r) if (!r)
{ {
cerr << "Error connecting to Monero deamon at " cerr << "Error connecting to Monero daemon at "
<< deamon_url << endl; << daemon_url << endl;
return 0; return 0;
} }
@ -80,9 +81,9 @@ rpccalls::get_mempool(vector<tx_info>& mempool_txs)
{ {
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex); std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
if (!connect_to_monero_deamon()) if (!connect_to_monero_daemon())
{ {
cerr << "get_mempool: not connected to deamon" << endl; cerr << "get_mempool: not connected to daemon" << endl;
return false; return false;
} }
@ -93,8 +94,8 @@ rpccalls::get_mempool(vector<tx_info>& mempool_txs)
if (!r || res.status != CORE_RPC_STATUS_OK) if (!r || res.status != CORE_RPC_STATUS_OK)
{ {
cerr << "Error connecting to Monero deamon at " cerr << "Error connecting to Monero daemon at "
<< deamon_url << endl; << daemon_url << endl;
return false; return false;
} }
@ -127,9 +128,9 @@ rpccalls::commit_tx(tools::wallet2::pending_tx& ptx, string& error_msg)
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex); std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
if (!connect_to_monero_deamon()) if (!connect_to_monero_daemon())
{ {
cerr << "commit_tx: not connected to deamon" << endl; cerr << "commit_tx: not connected to daemon" << endl;
return false; return false;
} }
@ -166,9 +167,9 @@ rpccalls::get_network_info(COMMAND_RPC_GET_INFO::response& response)
{ {
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex); std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
if (!connect_to_monero_deamon()) if (!connect_to_monero_daemon())
{ {
cerr << "get_network_info: not connected to deamon" << endl; cerr << "get_network_info: not connected to daemon" << endl;
return false; return false;
} }
@ -192,15 +193,15 @@ rpccalls::get_network_info(COMMAND_RPC_GET_INFO::response& response)
if (!err.empty()) if (!err.empty())
{ {
cerr << "Error connecting to Monero deamon due to " cerr << "Error connecting to Monero daemon due to "
<< err << endl; << err << endl;
return false; return false;
} }
} }
else else
{ {
cerr << "Error connecting to Monero deamon at " cerr << "Error connecting to Monero daemon at "
<< deamon_url << endl; << daemon_url << endl;
return false; return false;
} }
@ -226,9 +227,9 @@ rpccalls::get_hardfork_info(COMMAND_RPC_HARD_FORK_INFO::response& response)
{ {
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex); std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
if (!connect_to_monero_deamon()) if (!connect_to_monero_daemon())
{ {
cerr << "get_hardfork_info: not connected to deamon" << endl; cerr << "get_hardfork_info: not connected to daemon" << endl;
return false; return false;
} }
@ -253,15 +254,15 @@ rpccalls::get_hardfork_info(COMMAND_RPC_HARD_FORK_INFO::response& response)
if (!err.empty()) if (!err.empty())
{ {
cerr << "Error connecting to Monero deamon due to " cerr << "Error connecting to Monero daemon due to "
<< err << endl; << err << endl;
return false; return false;
} }
} }
else else
{ {
cerr << "Error connecting to Monero deamon at " cerr << "Error connecting to Monero daemon at "
<< deamon_url << endl; << daemon_url << endl;
return false; return false;
} }
@ -294,9 +295,9 @@ rpccalls::get_dynamic_per_kb_fee_estimate(
{ {
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex); std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
if (!connect_to_monero_deamon()) if (!connect_to_monero_daemon())
{ {
cerr << "get_dynamic_per_kb_fee_estimate: not connected to deamon" << endl; cerr << "get_dynamic_per_kb_fee_estimate: not connected to daemon" << endl;
return false; return false;
} }
@ -321,15 +322,15 @@ rpccalls::get_dynamic_per_kb_fee_estimate(
if (!err.empty()) if (!err.empty())
{ {
cerr << "Error connecting to Monero deamon due to " cerr << "Error connecting to Monero daemon due to "
<< err << endl; << err << endl;
return false; return false;
} }
} }
else else
{ {
cerr << "Error connecting to Monero deamon at " cerr << "Error connecting to Monero daemon at "
<< deamon_url << endl; << daemon_url << endl;
return false; return false;
} }
@ -357,9 +358,9 @@ rpccalls::get_block(string const& blk_hash, block& blk, string& error_msg)
{ {
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex); std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
if (!connect_to_monero_deamon()) if (!connect_to_monero_daemon())
{ {
cerr << "get_block: not connected to deamon" << endl; cerr << "get_block: not connected to daemon" << endl;
return false; return false;
} }
@ -384,15 +385,15 @@ rpccalls::get_block(string const& blk_hash, block& blk, string& error_msg)
if (!err.empty()) if (!err.empty())
{ {
cerr << "Error connecting to Monero deamon due to " cerr << "Error connecting to Monero daemon due to "
<< err << endl; << err << endl;
return false; return false;
} }
} }
else else
{ {
cerr << "get_block: error connecting to Monero deamon at " cerr << "get_block: error connecting to Monero daemon at "
<< deamon_url << endl; << daemon_url << endl;
return false; return false;
} }

@ -69,7 +69,7 @@ using namespace std;
class rpccalls class rpccalls
{ {
string deamon_url ; string daemon_url ;
uint64_t timeout_time; uint64_t timeout_time;
std::chrono::milliseconds timeout_time_ms; std::chrono::milliseconds timeout_time_ms;
@ -86,12 +86,12 @@ public:
using login_opt = boost::optional<epee::net_utils::http::login>; using login_opt = boost::optional<epee::net_utils::http::login>;
rpccalls(string _deamon_url = "http:://127.0.0.1:18081", rpccalls(string _daemon_url = "http:://127.0.0.1:18081",
login_opt _login = login_opt {}, login_opt _login = login_opt {},
uint64_t _timeout = 200000); uint64_t _timeout = 200000);
bool bool
connect_to_monero_deamon(); connect_to_monero_daemon();
uint64_t uint64_t
get_current_height(); get_current_height();
@ -136,9 +136,9 @@ public:
{ {
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex); std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
if (!connect_to_monero_deamon()) if (!connect_to_monero_daemon())
{ {
cerr << "get_alt_blocks: not connected to deamon" << endl; cerr << "get_alt_blocks: not connected to daemon" << endl;
return false; return false;
} }
@ -162,15 +162,15 @@ public:
if (!err.empty()) if (!err.empty())
{ {
cerr << "Error connecting to Monero deamon due to " cerr << "Error connecting to Monero daemon due to "
<< err << endl; << err << endl;
return false; return false;
} }
} }
else else
{ {
cerr << "Error connecting to Monero deamon at " cerr << "Error connecting to Monero daemon at "
<< deamon_url << endl; << daemon_url << endl;
return false; return false;
} }

Loading…
Cancel
Save