diff --git a/README.md b/README.md index 4b077cb..4e013d7 100644 --- a/README.md +++ b/README.md @@ -1 +1,36 @@ # Onion Monero Blockchain Explorer + +Two Monero blockchain explorer exist in the clearnet. Although useful, +their limitations are that they use JavaScript, have images +([might be used for coockless tracking](http://lucb1e.com/rp/cookielesscookies/)), use +use google analytics, are not open sourced, and are not + available as hidden services. These things are of importance + for privacy-oriented users. + + In this example, these limitations are addressed. Specifically, + an Onion Monero Blockchain Explorer is developed. It is build in C++, + and it not only shows how to use Monero C++ libraries, but also demonstrates how to + use: + + - [crow](https://github.com/ipkn/crow) - C++ micro web framework + - [lmdb++](https://github.com/bendiken/lmdbxx) - C++ wrapper for the LMDB + - [mstch](https://github.com/no1msd/mstch) - C++ {{mustache}} templates + - [rapidjson](https://github.com/miloyip/rapidjson) - C++ JSON parser/generator + + + +# Onion Monero Blockchain Explorer features + + - no javascript, no web analytics trackers, no images, i.e., no user tracking + - open source which allows everyone to check its source code, fork it, contribute + - made fully in C++ allowing for seamless integration with Monero + - does not use RPC calls, except to get mempool data, which improves its performance + + + + + + + + + diff --git a/src/page.h b/src/page.h index b267eb8..7a762a7 100644 --- a/src/page.h +++ b/src/page.h @@ -1241,6 +1241,10 @@ namespace xmreg { tx_hashes["encrypted_payments_id"] = {}; tx_hashes["output_public_keys"] = {}; + cout << "txs.size(): " << txs.size() << endl; + + cout << "search_text: " << search_text << endl; + for (const transaction& tx: txs) { @@ -1264,11 +1268,15 @@ namespace xmreg { // check if tx_public_key matches the search_text + cout << "txd.pk: " << pod_to_hex(txd.pk) << endl; + if (pod_to_hex(txd.pk) == search_text) { tx_hashes["tx_public_keys"].push_back(tx_hash_str); } + cout << "txd.payment_id: " << txd.payment_id << endl; + // check if payments_id matches the search_text if (pod_to_hex(txd.payment_id) == search_text) @@ -1354,22 +1362,55 @@ namespace xmreg { for (const string& tx_hash: found_txs.second) { + crypto::hash tx_hash_pod; + + epee::string_tools::hex_to_pod(tx_hash, tx_hash_pod); + transaction tx; - if (!mcore->get_tx(tx_hash, tx)) + uint64_t blk_height {0}; + + int64_t blk_timestamp; + + // first check in the blockchain + if (mcore->get_tx(tx_hash, tx)) { - return string("Cant get tx of hash (show_search_results): " + tx_hash); + + // get timestamp of the tx's block + blk_height = core_storage + ->get_db().get_tx_block_height(tx_hash_pod); + + blk_timestamp = core_storage + ->get_db().get_block_timestamp(blk_height); + + } + else + { + // check in mempool if tx_hash not found in the + // blockchain + vector> found_txs + = search_mempool(tx_hash_pod); + + if (!found_txs.empty()) + { + // there should be only one tx found + tx = found_txs.at(0).second; + } + else + { + return string("Cant get tx of hash (show_search_results): " + tx_hash); + } + + // tx in mempool have no blk_timestamp + // but can use their recive time + blk_timestamp = found_txs.at(0).first.receive_time; + } tx_details txd = get_tx_details(tx); mstch::map txd_map = txd.get_mstch_map(); - // get timestamp of the tx's block - uint64_t blk_height = core_storage - ->get_db().get_tx_block_height(txd.hash); - uint64_t blk_timestamp = core_storage - ->get_db().get_block_timestamp(blk_height); // add the timestamp to tx mstch map txd_map.insert({"timestamp", xmreg::timestamp_to_str(blk_timestamp)});