├── ext ├── mstch │ ├── cmake │ │ └── mstch-config.cmake │ ├── src │ │ ├── state │ │ │ ├── outside_section.hpp │ │ │ ├── render_state.hpp │ │ │ ├── in_section.hpp │ │ │ ├── outside_section.cpp │ │ │ └── in_section.cpp │ │ ├── mstch.cpp │ │ ├── utils.hpp │ │ ├── visitor │ │ │ ├── has_token.hpp │ │ │ ├── get_token.hpp │ │ │ ├── is_node_empty.hpp │ │ │ ├── render_section.hpp │ │ │ └── render_node.hpp │ │ ├── template_type.hpp │ │ ├── token.hpp │ │ ├── utils.cpp │ │ ├── render_context.hpp │ │ ├── token.cpp │ │ ├── CMakeLists.txt │ │ ├── render_context.cpp │ │ └── template_type.cpp │ ├── CMakeLists.txt │ ├── LICENSE │ └── include │ │ └── mstch │ │ └── mstch.hpp ├── CMakeLists.txt ├── crow │ ├── crow.h │ └── crow │ │ ├── settings.h │ │ ├── ci_map.h │ │ ├── http_request.h │ │ ├── dumb_timer_queue.h │ │ ├── middleware_context.h │ │ ├── socket_adaptors.h │ │ ├── http_response.h │ │ ├── common.h │ │ ├── logging.h │ │ ├── middleware.h │ │ ├── parser.h │ │ └── TinySHA1.hpp ├── fmt │ ├── ostream.cc │ └── ostream.h └── vpetrigocaches │ ├── fifo_cache_policy.hpp │ ├── lru_cache_policy.hpp │ ├── cache_policy.hpp │ ├── lfu_cache_policy.hpp │ └── cache.hpp ├── src ├── templates │ ├── imgs │ │ ├── etn-header-logo.png │ │ └── tx-icon.svg │ ├── partials │ │ ├── tx_table_header.html │ │ └── tx_table_row.html │ ├── tx.html │ ├── mempool_error.html │ ├── altblocks.html │ ├── pushrawtx.html │ ├── footer.html │ ├── rawkeyimgs.html │ ├── rawoutputkeys.html │ ├── js │ │ ├── config.js │ │ ├── crc32.js │ │ └── base58.js │ ├── rawtx.html │ ├── checkrawkeyimgs.html │ ├── index.html │ ├── checkrawoutputkeys.html │ ├── mempool.html │ ├── search_results.html │ ├── checkrawtx.html │ ├── header.html │ ├── my_outputs.html │ └── index2.html ├── version.h.in ├── CMakeLists.txt ├── CmdLineOptions.h ├── electroneum_headers.h ├── MicroCore.h ├── CurrentBlockchainStatus.h ├── MempoolStatus.h ├── rpccalls.h └── CmdLineOptions.cpp ├── .gitignore ├── LICENSE ├── cmake ├── FindUBSan.cmake ├── FindHIDAPI.cmake ├── asan-wrapper ├── FindASan.cmake ├── MyUtils.cmake ├── FindMSan.cmake ├── FindTSan.cmake ├── FindElectroneum.cmake ├── FindSanitizers.cmake └── sanitize-helpers.cmake ├── Dockerfile └── CMakeLists.txt /ext/mstch/cmake/mstch-config.cmake: -------------------------------------------------------------------------------- 1 | include("${CMAKE_CURRENT_LIST_DIR}/mstch-targets.cmake") -------------------------------------------------------------------------------- /src/templates/imgs/etn-header-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electroneum/electroneum-blockchain-explorer/HEAD/src/templates/imgs/etn-header-logo.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .sass-cache 3 | *.*~ 4 | *.user 5 | .idea/ 6 | *.log 7 | *.orig 8 | tests/ 9 | build/ 10 | cmake-build-debug/ 11 | .ycm_extra_conf.py 12 | .vscode/ 13 | -------------------------------------------------------------------------------- /src/templates/partials/tx_table_header.html: -------------------------------------------------------------------------------- 1 | 2 | timestamp 3 | tx hash 4 | outputs 5 | fee 6 | ring size 7 | in/out 8 | size [kB] 9 | 10 | -------------------------------------------------------------------------------- /ext/mstch/src/state/outside_section.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "render_state.hpp" 4 | 5 | namespace mstch { 6 | 7 | class outside_section: public render_state { 8 | public: 9 | std::string render(render_context& context, const token& token) override; 10 | }; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/templates/partials/tx_table_row.html: -------------------------------------------------------------------------------- 1 | 2 | {{timestamp}} 3 | {{hash}} 4 | {{sum_outputs}} 5 | {{tx_fee}} 6 | {{mixin}} 7 | {{no_inputs}}/{{no_outputs}} 8 | {{tx_size}} 9 | 10 | -------------------------------------------------------------------------------- /ext/mstch/src/state/render_state.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "token.hpp" 6 | 7 | namespace mstch { 8 | 9 | class render_context; 10 | 11 | class render_state { 12 | public: 13 | virtual ~render_state() {} 14 | virtual std::string render(render_context& context, const token& token) = 0; 15 | }; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/version.h.in: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mwo on 23/11/16. 3 | // 4 | 5 | #ifndef ETNBLOCKS_VERSION_H_IN_H 6 | #define ETNBLOCKS_VERSION_H_IN_H 7 | 8 | #define GIT_BRANCH "@GIT_BRANCH@" 9 | #define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" 10 | #define GIT_COMMIT_DATETIME "@GIT_COMMIT_DATETIME@" 11 | #define GIT_BRANCH_NAME "@GIT_BRANCH_NAME@" 12 | 13 | 14 | #endif //ETNBLOCKS_VERSION_H_IN_H 15 | -------------------------------------------------------------------------------- /ext/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # first build mstch template library 2 | add_subdirectory("mstch") 3 | 4 | 5 | # now build myext library from other files 6 | project(myext) 7 | 8 | set(SOURCE_HEADERS 9 | minicsv.h 10 | fmt/format.h) 11 | 12 | set(SOURCE_FILES 13 | fmt/format.cc 14 | fmt/ostream.cc) 15 | 16 | # make static library called libmyxrm 17 | # that we are going to link to 18 | # in the root CMakeLists.txt file 19 | add_library(myext 20 | STATIC 21 | ${SOURCE_FILES}) 22 | 23 | 24 | -------------------------------------------------------------------------------- /ext/mstch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | project(mstch) 3 | 4 | option(WITH_UNIT_TESTS "enable building unit test executable" OFF) 5 | option(WITH_BENCHMARK "enable building benchmark executable" OFF) 6 | 7 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 8 | set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) 9 | set(CMAKE_BUILD_TYPE Debug) 10 | 11 | set(mstch_VERSION 1.0.1) 12 | 13 | if(NOT MSVC) 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -O3") 15 | endif() 16 | 17 | add_subdirectory(src) 18 | -------------------------------------------------------------------------------- /src/templates/tx.html: -------------------------------------------------------------------------------- 1 | {{#has_error}} 2 |

Attempt failed

3 | {{#error_tx_not_found}} 4 |

Tx {{tx_hash}} not found.

5 |
6 |

If this is newly made tx, it can take some time (up to minute) 7 | for it to get propagated to all nodes' txpools. 8 |

9 | Please refresh in 10-20 seconds to check if its here then. 10 |

11 |
12 | {{/error_tx_not_found}} 13 | {{/has_error}} 14 | {{^has_error}} 15 | {{#txs}} 16 | {{>tx_details}} 17 | {{/txs}} 18 | {{/has_error}} -------------------------------------------------------------------------------- /ext/mstch/src/state/in_section.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "render_state.hpp" 7 | #include "template_type.hpp" 8 | 9 | namespace mstch { 10 | 11 | class in_section: public render_state { 12 | public: 13 | enum class type { inverted, normal }; 14 | in_section(type type, const token& start_token); 15 | std::string render(render_context& context, const token& token) override; 16 | 17 | private: 18 | const type m_type; 19 | const token& m_start_token; 20 | template_type m_section; 21 | int m_skipped_openings; 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project(myxrm) 4 | 5 | set(SOURCE_HEADERS 6 | MicroCore.h 7 | tools.h 8 | electroneum_headers.h 9 | CurrentBlockchainStatus.h) 10 | 11 | set(SOURCE_FILES 12 | MicroCore.cpp 13 | tools.cpp 14 | CmdLineOptions.cpp 15 | page.h 16 | rpccalls.cpp rpccalls.h 17 | version.h.in CurrentBlockchainStatus.cpp MempoolStatus.cpp MempoolStatus.h) 18 | 19 | # make static library called libmyxrm 20 | # that we are going to link to 21 | # in the root CMakeLists.txt file 22 | add_library(myxrm 23 | STATIC 24 | ${SOURCE_FILES}) 25 | -------------------------------------------------------------------------------- /ext/mstch/src/mstch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "mstch/mstch.hpp" 4 | #include "render_context.hpp" 5 | 6 | using namespace mstch; 7 | 8 | std::function mstch::config::escape; 9 | 10 | std::string mstch::render( 11 | const std::string& tmplt, 12 | const node& root, 13 | const std::map& partials) 14 | { 15 | std::map partial_templates; 16 | for (auto& partial: partials) 17 | partial_templates.insert({partial.first, {partial.second}}); 18 | 19 | return render_context(root, partial_templates).render(tmplt); 20 | } 21 | -------------------------------------------------------------------------------- /src/templates/mempool_error.html: -------------------------------------------------------------------------------- 1 |

2 | Transaction pool 3 |

4 |

5 |
6 | 7 |

Txpool data preparation for the front page failed. 8 | Its processing 9 | {{#network_info}}{{^is_pool_size_zero}}({{tx_pool_size}} txs){{/is_pool_size_zero}}{{/network_info}} 10 | took longer than expected and it timed out. 11 | To view the txpool without time constrain, 12 | go to dedicated txpool page: memory pool 13 |

14 | 15 | 16 | 17 |
18 | -------------------------------------------------------------------------------- /ext/mstch/src/utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace mstch { 7 | 8 | using citer = std::string::const_iterator; 9 | using criter = std::string::const_reverse_iterator; 10 | 11 | citer first_not_ws(citer begin, citer end); 12 | citer first_not_ws(criter begin, criter end); 13 | std::string html_escape(const std::string& str); 14 | criter reverse(citer it); 15 | 16 | template 17 | auto visit(Args&&... args) -> decltype(boost::apply_visitor( 18 | std::forward(args)...)) 19 | { 20 | return boost::apply_visitor(std::forward(args)...); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /ext/mstch/src/visitor/has_token.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "mstch/mstch.hpp" 6 | 7 | namespace mstch { 8 | 9 | class has_token: public boost::static_visitor { 10 | public: 11 | has_token(const std::string& token): m_token(token) { 12 | } 13 | 14 | template 15 | bool operator()(const T&) const { 16 | return m_token == "."; 17 | } 18 | 19 | bool operator()(const map& map) const { 20 | return map.count(m_token) == 1; 21 | } 22 | 23 | bool operator()(const std::shared_ptr& object) const { 24 | return object->has(m_token); 25 | } 26 | 27 | private: 28 | const std::string& m_token; 29 | }; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /ext/crow/crow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "crow/query_string.h" 3 | #include "crow/http_parser_merged.h" 4 | #include "crow/ci_map.h" 5 | #include "crow/TinySHA1.hpp" 6 | #include "crow/settings.h" 7 | #include "crow/socket_adaptors.h" 8 | #include "crow/json.h" 9 | #include "crow/mustache.h" 10 | #include "crow/logging.h" 11 | #include "crow/dumb_timer_queue.h" 12 | #include "crow/utility.h" 13 | #include "crow/common.h" 14 | #include "crow/http_request.h" 15 | #include "crow/websocket.h" 16 | #include "crow/parser.h" 17 | #include "crow/http_response.h" 18 | #include "crow/middleware.h" 19 | #include "crow/routing.h" 20 | #include "crow/middleware_context.h" 21 | #include "crow/http_connection.h" 22 | #include "crow/http_server.h" 23 | #include "crow/app.h" 24 | -------------------------------------------------------------------------------- /src/templates/altblocks.html: -------------------------------------------------------------------------------- 1 |

2 | Alternative blocks 3 |

4 |

(no of alt blocks: {{no_alt_blocks}})

5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {{#blocks}} 15 | 16 | 17 | 18 | 19 | 20 | 21 | {{/blocks}} 22 |
heightagehashtxs no
{{height}}{{age}}{{hash}}{{no_of_txs}}
23 | 24 | 25 |
26 | -------------------------------------------------------------------------------- /ext/crow/crow/settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // settings for crow 3 | // TODO - replace with runtime config. libucl? 4 | 5 | /* #ifdef - enables debug mode */ 6 | //#define CROW_ENABLE_DEBUG 7 | 8 | /* #ifdef - enables logging */ 9 | #define CROW_ENABLE_LOGGING 10 | 11 | /* #ifdef - enables ssl */ 12 | //#define CROW_ENABLE_SSL 13 | 14 | /* #define - specifies log level */ 15 | /* 16 | Debug = 0 17 | Info = 1 18 | Warning = 2 19 | Error = 3 20 | Critical = 4 21 | 22 | default to INFO 23 | */ 24 | #define CROW_LOG_LEVEL 1 25 | 26 | 27 | // compiler flags 28 | #if __cplusplus >= 201402L 29 | #define CROW_CAN_USE_CPP14 30 | #endif 31 | 32 | #if defined(_MSC_VER) 33 | #if _MSC_VER < 1900 34 | #define CROW_MSVC_WORKAROUND 35 | #define constexpr const 36 | #define noexcept throw() 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /ext/mstch/src/visitor/get_token.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "mstch/mstch.hpp" 6 | #include "has_token.hpp" 7 | 8 | namespace mstch { 9 | 10 | class get_token: public boost::static_visitor { 11 | public: 12 | get_token(const std::string& token, const mstch::node& node): 13 | m_token(token), m_node(node) 14 | { 15 | } 16 | 17 | template 18 | const mstch::node& operator()(const T&) const { 19 | return m_node; 20 | } 21 | 22 | const mstch::node& operator()(const map& map) const { 23 | return map.at(m_token); 24 | } 25 | 26 | const mstch::node& operator()(const std::shared_ptr& object) const { 27 | return object->at(m_token); 28 | } 29 | 30 | private: 31 | const std::string& m_token; 32 | const mstch::node& m_node; 33 | }; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/CmdLineOptions.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mwo on 6/11/15. 3 | // 4 | 5 | #ifndef ETNEG01_CMDLINEOPTIONS_H 6 | #define ETNEG01_CMDLINEOPTIONS_H 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace electroneumeg 15 | { 16 | 17 | using namespace std; 18 | using namespace boost::program_options; 19 | 20 | /** 21 | * Manages program options of this example program. 22 | * 23 | * Basically a wrapper for boost::program_options 24 | */ 25 | class CmdLineOptions { 26 | variables_map vm; 27 | 28 | public: 29 | CmdLineOptions(int acc, const char *avv[]); 30 | 31 | template 32 | boost::optional get_option(const string & opt_name) const; 33 | }; 34 | } 35 | 36 | 37 | #endif //ETNEG01_CMDLINEOPTIONS_H 38 | -------------------------------------------------------------------------------- /ext/crow/crow/ci_map.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace crow 8 | { 9 | struct ci_hash 10 | { 11 | size_t operator()(const std::string& key) const 12 | { 13 | std::size_t seed = 0; 14 | std::locale locale; 15 | 16 | for(auto c : key) 17 | { 18 | boost::hash_combine(seed, std::toupper(c, locale)); 19 | } 20 | 21 | return seed; 22 | } 23 | }; 24 | 25 | struct ci_key_eq 26 | { 27 | bool operator()(const std::string& l, const std::string& r) const 28 | { 29 | return boost::iequals(l, r); 30 | } 31 | }; 32 | 33 | using ci_map = std::unordered_multimap; 34 | } 35 | -------------------------------------------------------------------------------- /src/templates/imgs/tx-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | exchange 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/templates/pushrawtx.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 |

Transaction Pusher

6 |
7 | 8 |
9 | 10 | {{#txs}} 11 |

Attempting to push tx: {{tx_hash}}

12 | {{/txs}} 13 | 14 | {{#has_error}} 15 |

Attempt failed

16 |

{{error_msg}}

17 | {{/has_error}} 18 | {{^has_error}} 19 |

Success

20 |

21 | Your tx should be already in the txpool waiting to be included 22 | in an upcoming block. 23 |

24 | 25 | {{#txs}} 26 |

Go to tx: {{tx_hash}}

27 | {{/txs}} 28 | 29 | {{/has_error}} 30 | 31 |
32 |
33 |
-------------------------------------------------------------------------------- /ext/mstch/src/template_type.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "token.hpp" 7 | #include "utils.hpp" 8 | 9 | namespace mstch { 10 | 11 | class template_type { 12 | public: 13 | template_type() = default; 14 | template_type(const std::string& str); 15 | template_type(const std::string& str, const delim_type& delims); 16 | std::vector::const_iterator begin() const { return m_tokens.begin(); } 17 | std::vector::const_iterator end() const { return m_tokens.end(); } 18 | void operator<<(const token& token) { m_tokens.push_back(token); } 19 | 20 | private: 21 | std::vector m_tokens; 22 | std::string m_open; 23 | std::string m_close; 24 | void strip_whitespace(); 25 | void process_text(citer beg, citer end); 26 | void tokenize(const std::string& tmp); 27 | void store_prefixes(std::vector::iterator beg); 28 | }; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /ext/mstch/src/visitor/is_node_empty.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "mstch/mstch.hpp" 6 | 7 | namespace mstch { 8 | 9 | class is_node_empty: public boost::static_visitor { 10 | public: 11 | template 12 | bool operator()(const T&) const { 13 | return false; 14 | } 15 | 16 | bool operator()(const std::nullptr_t&) const { 17 | return true; 18 | } 19 | 20 | bool operator()(const int& value) const { 21 | return value == 0; 22 | } 23 | 24 | bool operator()(const double& value) const { 25 | return value == 0; 26 | } 27 | 28 | bool operator()(const bool& value) const { 29 | return !value; 30 | } 31 | 32 | bool operator()(const std::string& value) const { 33 | return value == ""; 34 | } 35 | 36 | bool operator()(const array& array) const { 37 | return array.size() == 0; 38 | } 39 | }; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /ext/fmt/ostream.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Formatting library for C++ - std::ostream support 3 | 4 | Copyright (c) 2012 - 2016, Victor Zverovich 5 | All rights reserved. 6 | 7 | For the license information refer to format.h. 8 | */ 9 | 10 | #include "ostream.h" 11 | 12 | namespace fmt { 13 | 14 | namespace internal { 15 | FMT_FUNC void write(std::ostream &os, Writer &w) { 16 | const char *data = w.data(); 17 | typedef internal::MakeUnsigned::Type UnsignedStreamSize; 18 | UnsignedStreamSize size = w.size(); 19 | UnsignedStreamSize max_size = 20 | internal::to_unsigned((std::numeric_limits::max)()); 21 | do { 22 | UnsignedStreamSize n = size <= max_size ? size : max_size; 23 | os.write(data, static_cast(n)); 24 | data += n; 25 | size -= n; 26 | } while (size != 0); 27 | } 28 | } 29 | 30 | FMT_FUNC void print(std::ostream &os, CStringRef format_str, ArgList args) { 31 | MemoryWriter w; 32 | w.write(format_str, args); 33 | internal::write(os, w); 34 | } 35 | } // namespace fmt 36 | -------------------------------------------------------------------------------- /ext/mstch/src/state/outside_section.cpp: -------------------------------------------------------------------------------- 1 | #include "outside_section.hpp" 2 | 3 | #include "visitor/render_node.hpp" 4 | #include "in_section.hpp" 5 | #include "render_context.hpp" 6 | 7 | using namespace mstch; 8 | 9 | std::string outside_section::render( 10 | render_context& ctx, const token& token) 11 | { 12 | using flag = render_node::flag; 13 | switch (token.token_type()) { 14 | case token::type::section_open: 15 | ctx.set_state(in_section::type::normal, token); 16 | break; 17 | case token::type::inverted_section_open: 18 | ctx.set_state(in_section::type::inverted, token); 19 | break; 20 | case token::type::variable: 21 | return visit(render_node(ctx, flag::escape_html), ctx.get_node(token.name())); 22 | case token::type::unescaped_variable: 23 | return visit(render_node(ctx, flag::none), ctx.get_node(token.name())); 24 | case token::type::text: 25 | return token.raw(); 26 | case token::type::partial: 27 | return ctx.render_partial(token.name(), token.partial_prefix()); 28 | default: 29 | break; 30 | } 31 | return ""; 32 | } 33 | -------------------------------------------------------------------------------- /src/templates/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 13 | 16 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /ext/mstch/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Daniel Sipka 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /ext/vpetrigocaches/fifo_cache_policy.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FIFO_CACHE_POLICY_HPP 2 | #define FIFO_CACHE_POLICY_HPP 3 | 4 | #include 5 | #include "cache_policy.hpp" 6 | 7 | namespace caches 8 | { 9 | 10 | template 11 | class FIFOCachePolicy : public ICachePolicy 12 | { 13 | public: 14 | 15 | FIFOCachePolicy() = default; 16 | ~FIFOCachePolicy() = default; 17 | 18 | void Insert(const Key& key) override 19 | { 20 | fifo_queue.emplace_front(key); 21 | } 22 | 23 | // handle request to the key-element in a cache 24 | void Touch(const Key& key) override 25 | { 26 | // nothing to do here in the FIFO strategy 27 | } 28 | 29 | // handle element deletion from a cache 30 | void Erase(const Key& key) override 31 | { 32 | fifo_queue.pop_back(); 33 | } 34 | 35 | // return a key of a replacement candidate 36 | const Key& ReplCandidate() const override 37 | { 38 | return fifo_queue.back(); 39 | } 40 | 41 | // return a key of a displacement candidate 42 | void Clear() override 43 | { 44 | fifo_queue.clear(); 45 | } 46 | 47 | private: 48 | 49 | std::list fifo_queue; 50 | }; 51 | } // namespace caches 52 | 53 | #endif // FIFO_CACHE_POLICY_HPP 54 | -------------------------------------------------------------------------------- /src/templates/rawkeyimgs.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 |

Signed Key Images Checker

6 |
7 | 8 | 9 |
10 |
11 | Paste base64 encoded, signed key images data here
12 | (In Linux, can get base64 signed raw tx data: base64 your_key_images_file | xclip -selection clipboard)
13 | (In Windows, can get base64 signed raw tx data: certutil.exe -encode -f your_key_images_file encoded.txt & type "encoded.txt" | clip)
14 |

15 | Viewkey (key image file data is encoded using your viewkey. Thus is needed for decryption) 16 |
17 | Note: data and viewkey are sent to the server, as the calculations are done on the server side 18 |
19 | 20 |
21 | 22 |
23 |
24 | 25 | 26 |
-------------------------------------------------------------------------------- /ext/mstch/src/token.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mstch { 6 | 7 | using delim_type = std::pair; 8 | 9 | class token { 10 | public: 11 | enum class type { 12 | text, variable, section_open, section_close, inverted_section_open, 13 | unescaped_variable, comment, partial, delimiter_change 14 | }; 15 | token(const std::string& str, std::size_t left = 0, std::size_t right = 0); 16 | type token_type() const { return m_type; }; 17 | const std::string& raw() const { return m_raw; }; 18 | const std::string& name() const { return m_name; }; 19 | const std::string& partial_prefix() const { return m_partial_prefix; }; 20 | const delim_type& delims() const { return m_delims; }; 21 | void partial_prefix(const std::string& p_partial_prefix) { 22 | m_partial_prefix = p_partial_prefix; 23 | }; 24 | bool eol() const { return m_eol; } 25 | void eol(bool eol) { m_eol = eol; } 26 | bool ws_only() const { return m_ws_only; } 27 | 28 | private: 29 | type m_type; 30 | std::string m_name; 31 | std::string m_raw; 32 | std::string m_partial_prefix; 33 | delim_type m_delims; 34 | bool m_eol; 35 | bool m_ws_only; 36 | type token_info(char c); 37 | }; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/electroneum_headers.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mwo on 5/11/15. 3 | // 4 | 5 | #ifndef ETNEG01_ELECTRONEUM_HEADERS_H_H 6 | #define ETNEG01_ELECTRONEUM_HEADERS_H_H 7 | 8 | #define DB_LMDB 2 9 | #define BLOCKCHAIN_DB DB_LMDB 10 | 11 | 12 | #define UNSIGNED_TX_PREFIX "Electroneum unsigned tx set\003" 13 | #define SIGNED_TX_PREFIX "Electroneum signed tx set\003" 14 | #define KEY_IMAGE_EXPORT_FILE_MAGIC "Electroneum key image export\002" 15 | #define OUTPUT_EXPORT_FILE_MAGIC "Electroneum output export\003" 16 | 17 | #define FEE_ESTIMATE_GRACE_BLOCKS 10 // estimate fee valid for that many blocks 18 | 19 | #include "version.h" 20 | 21 | #include "net/http_client.h" 22 | #include "storages/http_abstract_invoke.h" 23 | 24 | #include "cryptonote_core/tx_pool.h" 25 | #include "cryptonote_core/blockchain.h" 26 | #include "blockchain_db/lmdb/db_lmdb.h" 27 | #include "device/device_default.hpp" 28 | 29 | #include "wallet/wallet2.h" 30 | 31 | #include "serialization/binary_utils.h" 32 | 33 | #include "ringct/rctTypes.h" 34 | #include "ringct/rctOps.h" 35 | #include "ringct/rctSigs.h" 36 | 37 | #include "easylogging++.h" 38 | 39 | #include "common/base58.h" 40 | 41 | #include "string_coding.h" 42 | 43 | 44 | #endif //ETNEG01_ELECTRONEUM_HEADERS_H_H 45 | 46 | -------------------------------------------------------------------------------- /src/templates/rawoutputkeys.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

Signed Outputs Public Keys Checker

5 |
6 | 7 | 8 |
9 |
10 | Paste base64 encoded, signed output keys data here
11 | (In Linux, can get base64 signed raw tx data: base64 your_output_keys_filename | xclip -selection clipboard)
12 | (In Windows, can get base64 signed raw tx data: certutil.exe -encode -f your_output_keys_filename encoded.txt & type "encoded.txt" | clip)
13 |

14 | Viewkey (output keys file data is encoded using your viewkey. Thus is needed for decryption) 15 |
16 | Note: data and viewkey are sent to the server, as the calculations are done on the server side 17 |
18 | 19 |
20 | 21 |
22 |
23 | 24 | 25 |
-------------------------------------------------------------------------------- /ext/mstch/src/state/in_section.cpp: -------------------------------------------------------------------------------- 1 | #include "in_section.hpp" 2 | #include "outside_section.hpp" 3 | #include "visitor/is_node_empty.hpp" 4 | #include "visitor/render_section.hpp" 5 | 6 | using namespace mstch; 7 | 8 | in_section::in_section(type type, const token& start_token): 9 | m_type(type), m_start_token(start_token), m_skipped_openings(0) 10 | { 11 | } 12 | 13 | std::string in_section::render(render_context& ctx, const token& token) { 14 | if (token.token_type() == token::type::section_close) 15 | if (token.name() == m_start_token.name() && m_skipped_openings == 0) { 16 | auto& node = ctx.get_node(m_start_token.name()); 17 | std::string out; 18 | 19 | if (m_type == type::normal && !visit(is_node_empty(), node)) 20 | out = visit(render_section(ctx, m_section, m_start_token.delims()), node); 21 | else if (m_type == type::inverted && visit(is_node_empty(), node)) 22 | out = render_context::push(ctx).render(m_section); 23 | 24 | ctx.set_state(); 25 | return out; 26 | } else 27 | m_skipped_openings--; 28 | else if (token.token_type() == token::type::inverted_section_open || 29 | token.token_type() == token::type::section_open) 30 | m_skipped_openings++; 31 | 32 | m_section << token; 33 | return ""; 34 | } 35 | -------------------------------------------------------------------------------- /src/templates/js/config.js: -------------------------------------------------------------------------------- 1 | var config = { 2 | testnet: false, // this is adjusted page.h if needed. dont need to change manually 3 | stagenet: false, // this is adjusted page.h if needed. dont need to change manually 4 | coinUnitPlaces: 12, 5 | txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Electroneum 6 | txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Electroneum 7 | coinSymbol: 'ETN', 8 | openAliasPrefix: "etn", 9 | coinName: 'Electroneum', 10 | coinUriPrefix: 'electroneum:', 11 | addressPrefix: 18, 12 | integratedAddressPrefix: 19, 13 | subAddressPrefix: 42, 14 | addressPrefixTestnet: 53, 15 | integratedAddressPrefixTestnet: 54, 16 | subAddressPrefixTestnet: 63, 17 | addressPrefixStagenet: 24, 18 | integratedAddressPrefixStagenet: 25, 19 | subAddressPrefixStagenet: 36, 20 | feePerKB: new JSBigInt('2000000000'),//20^10 - for testnet its not used, as fee is dynamic. 21 | dustThreshold: new JSBigInt('1000000000'),//10^10 used for choosing outputs/change - we decompose all the way down if the receiver wants now regardless of threshold 22 | txChargeRatio: 0.5, 23 | defaultMixin: 4, // minimum mixin for hardfork v5 24 | txChargeAddress: '', 25 | idleTimeout: 30, 26 | idleWarningDuration: 20, 27 | maxBlockNumber: 500000000, 28 | avgBlockTime: 120, 29 | debugMode: false 30 | }; 31 | -------------------------------------------------------------------------------- /ext/mstch/src/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.hpp" 2 | #include "mstch/mstch.hpp" 3 | 4 | mstch::citer mstch::first_not_ws(mstch::citer begin, mstch::citer end) { 5 | for (auto it = begin; it != end; ++it) 6 | if (*it != ' ') return it; 7 | return end; 8 | } 9 | 10 | mstch::citer mstch::first_not_ws(mstch::criter begin, mstch::criter end) { 11 | for (auto rit = begin; rit != end; ++rit) 12 | if (*rit != ' ') return --(rit.base()); 13 | return --(end.base()); 14 | } 15 | 16 | mstch::criter mstch::reverse(mstch::citer it) { 17 | return std::reverse_iterator(it); 18 | } 19 | 20 | std::string mstch::html_escape(const std::string& str) { 21 | if (mstch::config::escape) 22 | return mstch::config::escape(str); 23 | 24 | std::string out; 25 | citer start = str.begin(); 26 | 27 | auto add_escape = [&out, &start](const std::string& escaped, citer& it) { 28 | out += std::string{start, it} + escaped; 29 | start = it + 1; 30 | }; 31 | 32 | for (auto it = str.begin(); it != str.end(); ++it) 33 | switch (*it) { 34 | case '&': add_escape("&", it); break; 35 | case '\'': add_escape("'", it); break; 36 | case '"': add_escape(""", it); break; 37 | case '<': add_escape("<", it); break; 38 | case '>': add_escape(">", it); break; 39 | case '/': add_escape("/", it); break; 40 | default: break; 41 | } 42 | 43 | return out + std::string{start, str.end()}; 44 | } 45 | -------------------------------------------------------------------------------- /ext/vpetrigocaches/lru_cache_policy.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LRU_CACHE_POLICY_HPP 2 | #define LRU_CACHE_POLICY_HPP 3 | 4 | #include 5 | #include 6 | #include "cache_policy.hpp" 7 | 8 | namespace caches 9 | { 10 | template 11 | class LRUCachePolicy : public ICachePolicy 12 | { 13 | 14 | public: 15 | 16 | using lru_iterator = typename std::list::const_iterator; 17 | 18 | LRUCachePolicy() = default; 19 | ~LRUCachePolicy() = default; 20 | 21 | void Insert(const Key& key) override 22 | { 23 | lru_queue.emplace_front(key); 24 | key_finder[key] = lru_queue.cbegin(); 25 | } 26 | 27 | void Touch(const Key& key) override 28 | { 29 | // move the touched element at the beginning of the lru_queue 30 | lru_queue.splice(lru_queue.cbegin(), lru_queue, key_finder[key]); 31 | } 32 | 33 | void Erase(const Key& key) override 34 | { 35 | // remove the least recently used element 36 | key_finder.erase(lru_queue.back()); 37 | 38 | lru_queue.pop_back(); 39 | } 40 | 41 | // return a key of a displacement candidate 42 | const Key& ReplCandidate() const override 43 | { 44 | return lru_queue.back(); 45 | } 46 | 47 | // return a key of a displacement candidate 48 | void Clear() override 49 | { 50 | lru_queue.clear(); 51 | key_finder.clear(); 52 | } 53 | 54 | private: 55 | 56 | std::list lru_queue; 57 | 58 | std::unordered_map key_finder; 59 | }; 60 | 61 | } // namespace caches 62 | 63 | #endif // LRU_CACHE_POLICY_HPP 64 | -------------------------------------------------------------------------------- /ext/mstch/src/render_context.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "mstch/mstch.hpp" 10 | #include "state/render_state.hpp" 11 | #include "template_type.hpp" 12 | 13 | namespace mstch { 14 | 15 | class render_context { 16 | public: 17 | class push { 18 | public: 19 | push(render_context& context, const mstch::node& node = {}); 20 | ~push(); 21 | std::string render(const template_type& templt); 22 | private: 23 | render_context& m_context; 24 | }; 25 | 26 | render_context( 27 | const mstch::node& node, 28 | const std::map& partials); 29 | const mstch::node& get_node(const std::string& token); 30 | std::string render( 31 | const template_type& templt, const std::string& prefix = ""); 32 | std::string render_partial( 33 | const std::string& partial_name, const std::string& prefix); 34 | template 35 | void set_state(Args&& ... args) { 36 | m_state.top() = std::unique_ptr( 37 | new T(std::forward(args)...)); 38 | } 39 | 40 | private: 41 | static const mstch::node null_node; 42 | const mstch::node& find_node( 43 | const std::string& token, 44 | std::list current_nodes); 45 | std::map m_partials; 46 | std::deque m_nodes; 47 | std::list m_node_ptrs; 48 | std::stack> m_state; 49 | }; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, moneroexamples 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its contributors 16 | may be used to endorse or promote products derived from this software without 17 | specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /src/templates/rawtx.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 |

Transaction Pusher

6 |
7 | 8 | 9 |
10 |
11 | Paste here either a hex string of raw transaction
12 | (the tx_blob response in the wallet RPC, or the raw_electroneum_tx 13 | file saved by the wallet CLI with --do-not-relay option specified),
14 | or base64 encoded, unsigned or signed transaction data
15 |
16 | (In Linux, can get the raw tx data: cat raw_electroneum_tx | xclip -selection clipboard)
17 | (In Windows, can get the raw tx data: certutil.exe -encode -f raw_electroneum_tx encoded.txt & type "encoded.txt" | clip)
18 | 19 | 20 |
21 | Note: data is sent to the server, as the calculations are done on the server side 22 |
23 | Note: "check" does not work for the hex string of raw transaction 24 |
25 | 26 |                     27 |                     28 | 29 |
30 |
31 | 32 |
33 |
34 | -------------------------------------------------------------------------------- /ext/mstch/src/token.cpp: -------------------------------------------------------------------------------- 1 | #include "token.hpp" 2 | #include "utils.hpp" 3 | 4 | using namespace mstch; 5 | 6 | token::type token::token_info(char c) { 7 | switch (c) { 8 | case '>': return type::partial; 9 | case '^': return type::inverted_section_open; 10 | case '/': return type::section_close; 11 | case '&': return type::unescaped_variable; 12 | case '#': return type::section_open; 13 | case '!': return type::comment; 14 | default: return type::variable; 15 | } 16 | } 17 | 18 | token::token(const std::string& str, std::size_t left, std::size_t right): 19 | m_raw(str), m_eol(false), m_ws_only(false) 20 | { 21 | if (left != 0 && right != 0) { 22 | if (str[left] == '=' && str[str.size() - right - 1] == '=') { 23 | m_type = type::delimiter_change; 24 | } else if (str[left] == '{' && str[str.size() - right - 1] == '}') { 25 | m_type = type::unescaped_variable; 26 | m_name = {first_not_ws(str.begin() + left + 1, str.end() - right), 27 | first_not_ws(str.rbegin() + 1 + right, str.rend() - left) + 1}; 28 | } else { 29 | auto c = first_not_ws(str.begin() + left, str.end() - right); 30 | m_type = token_info(*c); 31 | if (m_type != type::variable) 32 | c = first_not_ws(c + 1, str.end() - right); 33 | m_name = {c, first_not_ws(str.rbegin() + right, str.rend() - left) + 1}; 34 | m_delims = {{str.begin(), str.begin() + left}, 35 | {str.end() - right, str.end()}}; 36 | } 37 | } else { 38 | m_type = type::text; 39 | m_eol = (str.size() > 0 && str[str.size() - 1] == '\n'); 40 | m_ws_only = (str.find_first_not_of(" \r\n\t") == std::string::npos); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ext/vpetrigocaches/cache_policy.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CACHE_POLICY_HPP 2 | #define CACHE_POLICY_HPP 3 | 4 | #include 5 | 6 | namespace caches 7 | { 8 | 9 | template 10 | 11 | class ICachePolicy 12 | { 13 | public: 14 | 15 | virtual ~ICachePolicy() {} 16 | 17 | // handle element insertion in a cache 18 | virtual void Insert(const Key& key) = 0; 19 | 20 | // handle request to the key-element in a cache 21 | virtual void Touch(const Key& key) = 0; 22 | 23 | // handle element deletion from a cache 24 | virtual void Erase(const Key& key) = 0; 25 | 26 | // return a key of a replacement candidate 27 | virtual const Key& ReplCandidate() const = 0; 28 | 29 | // clear the cache 30 | virtual void Clear() = 0; 31 | 32 | }; 33 | 34 | template 35 | class NoCachePolicy : public ICachePolicy 36 | { 37 | public: 38 | 39 | NoCachePolicy() = default; 40 | 41 | ~NoCachePolicy() override = default; 42 | 43 | void Insert(const Key& key) override 44 | { 45 | key_storage.emplace(key); 46 | } 47 | 48 | void Touch(const Key& key) override 49 | { 50 | // do not do anything 51 | } 52 | 53 | void Erase(const Key& key) override 54 | { 55 | key_storage.erase(key); 56 | } 57 | 58 | // return a key of a displacement candidate 59 | const Key& ReplCandidate() const override 60 | { 61 | return *key_storage.crbegin(); 62 | } 63 | 64 | // return a key of a displacement candidate 65 | void Clear() override 66 | { 67 | key_storage.clear(); 68 | } 69 | 70 | private: 71 | 72 | std::unordered_set key_storage; 73 | }; 74 | 75 | } // namespace caches 76 | 77 | #endif // CACHE_POLICY_HPP 78 | -------------------------------------------------------------------------------- /ext/mstch/src/visitor/render_section.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "render_context.hpp" 6 | #include "mstch/mstch.hpp" 7 | #include "utils.hpp" 8 | #include "render_node.hpp" 9 | 10 | namespace mstch { 11 | 12 | class render_section: public boost::static_visitor { 13 | public: 14 | enum class flag { none, keep_array }; 15 | render_section( 16 | render_context& ctx, 17 | const template_type& section, 18 | const delim_type& delims, 19 | flag p_flag = flag::none): 20 | m_ctx(ctx), m_section(section), m_delims(delims), m_flag(p_flag) 21 | { 22 | } 23 | 24 | template 25 | std::string operator()(const T& t) const { 26 | return render_context::push(m_ctx, t).render(m_section); 27 | } 28 | 29 | std::string operator()(const lambda& fun) const { 30 | std::string section_str; 31 | for (auto& token: m_section) 32 | section_str += token.raw(); 33 | template_type interpreted{fun([this](const mstch::node& n) { 34 | return visit(render_node(m_ctx), n); 35 | }, section_str), m_delims}; 36 | return render_context::push(m_ctx).render(interpreted); 37 | } 38 | 39 | std::string operator()(const array& array) const { 40 | std::string out; 41 | if (m_flag == flag::keep_array) 42 | return render_context::push(m_ctx, array).render(m_section); 43 | else 44 | for (auto& item: array) 45 | out += visit(render_section( 46 | m_ctx, m_section, m_delims, flag::keep_array), item); 47 | return out; 48 | } 49 | 50 | private: 51 | render_context& m_ctx; 52 | const template_type& m_section; 53 | const delim_type& m_delims; 54 | flag m_flag; 55 | }; 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/templates/checkrawkeyimgs.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 |
6 |

Signed Key Images Checker

7 |
8 | 9 | 10 |

Data file prefix: {{data_prefix}}

11 | 12 | {{#has_error}} 13 |

Attempt failed

14 |

{{error_msg}}

15 | {{/has_error}} 16 | {{^has_error}} 17 |

Key images for address: {{address}}

18 |

Viewkey: {{viewkey}}

19 | 20 |
21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | {{#key_imgs}} 30 | 31 | 32 | 33 | 34 | 42 | 43 | {{/key_imgs}} 44 |
Key no.Key imageIs spent?
{{key_no}}{{key_image}} 35 | {{#is_spent}} 36 | {{is_spent}} 37 | {{/is_spent}} 38 | {{^is_spent}} 39 | {{is_spent}} 40 | {{/is_spent}} 41 |
45 |
46 |
47 | 48 |
49 | 50 | {{/has_error}} 51 | 52 |
-------------------------------------------------------------------------------- /cmake/FindUBSan.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | option(SANITIZE_UNDEFINED 26 | "Enable UndefinedBehaviorSanitizer for sanitized targets." Off) 27 | 28 | set(FLAG_CANDIDATES 29 | "-g -fsanitize=undefined" 30 | ) 31 | 32 | 33 | include(sanitize-helpers) 34 | 35 | if (SANITIZE_UNDEFINED) 36 | sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" 37 | "UndefinedBehaviorSanitizer" "UBSan") 38 | endif () 39 | 40 | function (add_sanitize_undefined TARGET) 41 | if (NOT SANITIZE_UNDEFINED) 42 | return() 43 | endif () 44 | 45 | sanitizer_add_flags(${TARGET} "UndefinedBehaviorSanitizer" "UBSan") 46 | endfunction () 47 | -------------------------------------------------------------------------------- /ext/mstch/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Boost 1.54 REQUIRED) 2 | 3 | set(mstch_INCLUDE_DIR 4 | ${PROJECT_SOURCE_DIR}/include CACHE STRING "mstch include directory") 5 | 6 | # /home/mwo/crow-electroneum-test/ext/mstch 7 | message(${PROJECT_SOURCE_DIR}) 8 | # 9 | include_directories( 10 | ${Boost_INCLUDE_DIR}) 11 | 12 | set(SRC 13 | state/in_section.cpp 14 | state/outside_section.cpp 15 | state/render_state.hpp 16 | visitor/get_token.hpp 17 | visitor/has_token.hpp 18 | visitor/is_node_empty.hpp 19 | visitor/render_node.hpp 20 | visitor/render_section.hpp 21 | mstch.cpp 22 | render_context.cpp 23 | template_type.cpp 24 | token.cpp 25 | utils.cpp) 26 | 27 | add_library(mstch STATIC ${SRC}) 28 | # 29 | set_property(TARGET mstch PROPERTY VERSION ${mstch_VERSION}) 30 | # 31 | #install( 32 | # TARGETS mstch EXPORT mstchTargets 33 | # LIBRARY DESTINATION lib 34 | # ARCHIVE DESTINATION lib) 35 | # 36 | #install( 37 | # FILES "${PROJECT_SOURCE_DIR}/include/mstch/mstch.hpp" 38 | # DESTINATION include/mstch 39 | # COMPONENT Devel) 40 | # 41 | #include(CMakePackageConfigHelpers) 42 | #write_basic_package_version_file( 43 | # "${CMAKE_CURRENT_BINARY_DIR}/mstch/mstch-config-version.cmake" 44 | # VERSION ${mstch_VERSION} 45 | # COMPATIBILITY AnyNewerVersion) 46 | # 47 | #export( 48 | # EXPORT mstchTargets 49 | # FILE "${CMAKE_CURRENT_BINARY_DIR}/mstch/mstch-targets.cmake" 50 | # NAMESPACE mstch::) 51 | # 52 | #configure_file( 53 | # "${PROJECT_SOURCE_DIR}/cmake/mstch-config.cmake" 54 | # "${CMAKE_CURRENT_BINARY_DIR}/mstch/mstch-config.cmake") 55 | # 56 | #install( 57 | # EXPORT mstchTargets 58 | # FILE mstch-targets.cmake 59 | # NAMESPACE mstch:: 60 | # DESTINATION lib/cmake/mstch) 61 | # 62 | #install(FILES 63 | # "${PROJECT_SOURCE_DIR}/cmake/mstch-config.cmake" 64 | # "${CMAKE_CURRENT_BINARY_DIR}/mstch/mstch-config-version.cmake" 65 | # DESTINATION lib/cmake/mstch 66 | # COMPONENT Devel) 67 | -------------------------------------------------------------------------------- /ext/mstch/src/visitor/render_node.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "render_context.hpp" 7 | #include "mstch/mstch.hpp" 8 | #include "utils.hpp" 9 | 10 | namespace mstch { 11 | 12 | class render_node: public boost::static_visitor { 13 | public: 14 | enum class flag { none, escape_html }; 15 | render_node(render_context& ctx, flag p_flag = flag::none): 16 | m_ctx(ctx), m_flag(p_flag) 17 | { 18 | } 19 | 20 | template 21 | std::string operator()(const T&) const { 22 | return ""; 23 | } 24 | 25 | std::string operator()(const int& value) const { 26 | return std::to_string(value); 27 | } 28 | 29 | std::string operator()(const double& value) const { 30 | std::stringstream ss; 31 | ss << value; 32 | return ss.str(); 33 | } 34 | 35 | std::string operator()(const uint64_t& value) const { 36 | std::stringstream ss; 37 | ss << value; 38 | return ss.str(); 39 | } 40 | 41 | std::string operator()(const int64_t& value) const { 42 | std::stringstream ss; 43 | ss << value; 44 | return ss.str(); 45 | } 46 | 47 | std::string operator()(const uint32_t& value) const { 48 | std::stringstream ss; 49 | ss << value; 50 | return ss.str(); 51 | } 52 | 53 | std::string operator()(const bool& value) const { 54 | return value ? "true" : "false"; 55 | } 56 | 57 | std::string operator()(const lambda& value) const { 58 | template_type interpreted{value([this](const mstch::node& n) { 59 | return visit(render_node(m_ctx), n); 60 | })}; 61 | auto rendered = render_context::push(m_ctx).render(interpreted); 62 | return (m_flag == flag::escape_html) ? html_escape(rendered) : rendered; 63 | } 64 | 65 | std::string operator()(const std::string& value) const { 66 | return (m_flag == flag::escape_html) ? html_escape(value) : value; 67 | } 68 | 69 | private: 70 | render_context& m_ctx; 71 | flag m_flag; 72 | }; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /ext/crow/crow/http_request.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "crow/common.h" 6 | #include "crow/ci_map.h" 7 | #include "crow/query_string.h" 8 | 9 | namespace crow 10 | { 11 | template 12 | inline const std::string& get_header_value(const T& headers, const std::string& key) 13 | { 14 | if (headers.count(key)) 15 | { 16 | return headers.find(key)->second; 17 | } 18 | static std::string empty; 19 | return empty; 20 | } 21 | 22 | struct DetachHelper; 23 | 24 | struct request 25 | { 26 | HTTPMethod method; 27 | std::string raw_url; 28 | std::string url; 29 | query_string url_params; 30 | ci_map headers; 31 | std::string body; 32 | 33 | void* middleware_context{}; 34 | boost::asio::io_service* io_service{}; 35 | 36 | request() 37 | : method(HTTPMethod::Get) 38 | { 39 | } 40 | 41 | request(HTTPMethod method, std::string raw_url, std::string url, query_string url_params, ci_map headers, std::string body) 42 | : method(method), raw_url(std::move(raw_url)), url(std::move(url)), url_params(std::move(url_params)), headers(std::move(headers)), body(std::move(body)) 43 | { 44 | } 45 | 46 | void add_header(std::string key, std::string value) 47 | { 48 | headers.emplace(std::move(key), std::move(value)); 49 | } 50 | 51 | const std::string& get_header_value(const std::string& key) const 52 | { 53 | return crow::get_header_value(headers, key); 54 | } 55 | 56 | template 57 | void post(CompletionHandler handler) 58 | { 59 | io_service->post(handler); 60 | } 61 | 62 | template 63 | void dispatch(CompletionHandler handler) 64 | { 65 | io_service->dispatch(handler); 66 | } 67 | 68 | }; 69 | } 70 | -------------------------------------------------------------------------------- /cmake/FindHIDAPI.cmake: -------------------------------------------------------------------------------- 1 | # - try to find HIDAPI library 2 | # from http://www.signal11.us/oss/hidapi/ 3 | # 4 | # Cache Variables: (probably not for direct use in your scripts) 5 | # HIDAPI_INCLUDE_DIR 6 | # HIDAPI_LIBRARY 7 | # 8 | # Non-cache variables you might use in your CMakeLists.txt: 9 | # HIDAPI_FOUND 10 | # HIDAPI_INCLUDE_DIRS 11 | # HIDAPI_LIBRARIES 12 | # 13 | # Requires these CMake modules: 14 | # FindPackageHandleStandardArgs (known included with CMake >=2.6.2) 15 | # 16 | # Original Author: 17 | # 2009-2010 Ryan Pavlik 18 | # http://academic.cleardefinition.com 19 | # Iowa State University HCI Graduate Program/VRAC 20 | # 21 | # Copyright Iowa State University 2009-2010. 22 | # Distributed under the Boost Software License, Version 1.0. 23 | # (See accompanying file LICENSE_1_0.txt or copy at 24 | # http://www.boost.org/LICENSE_1_0.txt) 25 | 26 | find_library(HIDAPI_LIBRARY 27 | NAMES hidapi hidapi-libusb) 28 | 29 | find_path(HIDAPI_INCLUDE_DIR 30 | NAMES hidapi.h 31 | PATH_SUFFIXES 32 | hidapi) 33 | 34 | include(FindPackageHandleStandardArgs) 35 | find_package_handle_standard_args(HIDAPI 36 | DEFAULT_MSG 37 | HIDAPI_LIBRARY 38 | HIDAPI_INCLUDE_DIR) 39 | 40 | if(HIDAPI_FOUND) 41 | set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARY}") 42 | if((STATIC AND UNIX AND NOT APPLE) OR (DEPENDS AND CMAKE_SYSTEM_NAME STREQUAL "Linux")) 43 | find_library(LIBUSB-1.0_LIBRARY usb-1.0) 44 | find_library(LIBUDEV_LIBRARY udev) 45 | if(LIBUSB-1.0_LIBRARY) 46 | set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARIES};${LIBUSB-1.0_LIBRARY}") 47 | if(LIBUDEV_LIBRARY) 48 | set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARIES};${LIBUDEV_LIBRARY}") 49 | else() 50 | message(WARNING "libudev library not found, binaries may fail to link.") 51 | endif() 52 | else() 53 | message(WARNING "libusb-1.0 library not found, binaries may fail to link.") 54 | endif() 55 | endif() 56 | 57 | set(HIDAPI_INCLUDE_DIRS "${HIDAPI_INCLUDE_DIR}") 58 | endif() 59 | 60 | mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBRARY) 61 | -------------------------------------------------------------------------------- /ext/vpetrigocaches/lfu_cache_policy.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LFU_CACHE_POLICY_HPP 2 | #define LFU_CACHE_POLICY_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "cache_policy.hpp" 9 | 10 | namespace caches 11 | { 12 | template 13 | class LFUCachePolicy : public ICachePolicy 14 | { 15 | public: 16 | 17 | using lfu_iterator = typename std::multimap::iterator; 18 | 19 | LFUCachePolicy() = default; 20 | 21 | ~LFUCachePolicy() override = default; 22 | 23 | void Insert(const Key& key) override 24 | { 25 | constexpr std::size_t INIT_VAL = 1; 26 | 27 | // all new value initialized with the frequency 1 28 | lfu_storage[key] = frequency_storage.emplace_hint( 29 | frequency_storage.cbegin(), INIT_VAL, key); 30 | } 31 | 32 | void Touch(const Key& key) override 33 | { 34 | // get the previous frequency value of a key 35 | auto elem_for_update = lfu_storage[key]; 36 | 37 | auto updated_elem = std::make_pair( 38 | elem_for_update->first + 1, elem_for_update->second); 39 | 40 | // update the previous value 41 | frequency_storage.erase(elem_for_update); 42 | 43 | lfu_storage[key] = frequency_storage.emplace_hint( 44 | frequency_storage.cend(), std::move(updated_elem)); 45 | } 46 | 47 | void Erase(const Key& key) override 48 | { 49 | frequency_storage.erase(lfu_storage[key]); 50 | lfu_storage.erase(key); 51 | } 52 | 53 | const Key& ReplCandidate() const override 54 | { 55 | // at the beginning of the frequency_storage we have the 56 | // least frequency used value 57 | return frequency_storage.cbegin()->second; 58 | } 59 | 60 | // return a key of a displacement candidate 61 | void Clear() override 62 | { 63 | frequency_storage.clear(); 64 | lfu_storage.clear(); 65 | } 66 | 67 | 68 | private: 69 | 70 | std::multimap frequency_storage; 71 | 72 | std::unordered_map lfu_storage; 73 | }; 74 | } // namespace caches 75 | 76 | #endif // LFU_CACHE_POLICY_HPP 77 | -------------------------------------------------------------------------------- /src/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

4 | 5 | Server time: {{server_timestamp}} | 6 | 7 | {{#refresh}} 8 | Autorefresh is ON (10 s) 9 | {{/refresh}} 10 | {{^refresh}} 11 | Autorefresh is OFF 12 | {{/refresh}} 13 |

14 |
15 | 16 | {{{mempool_info}}} 17 | 18 | {{#is_page_zero}} 19 |

100 recent blocks

20 | {{/is_page_zero}} 21 | {{^is_page_zero}} 22 |

older blocks

23 | {{/is_page_zero}} 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | {{#blocks}} 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | {{/blocks}} 50 |
heightage {{age_format}} (Δm)block hashtxsfeesoutputsring sizesize [kB]
{{height}}{{age}} ({{time_delta}}){{hash}}{{notx}}{{fees}}{{etn_outputs}}{{mixin_range}}{{blksize}}
51 | 52 |
53 | {{^is_page_zero}} 54 | previous page | 55 | first page | 56 | {{/is_page_zero}} 57 | current page: {{page_no}}/{{total_page_no}} 58 | | next page 59 |
60 | 61 |
62 | -------------------------------------------------------------------------------- /cmake/asan-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # The MIT License (MIT) 4 | # 5 | # Copyright (c) 6 | # 2013 Matthew Arsenault 7 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # This script is a wrapper for AddressSanitizer. In some special cases you need 28 | # to preload AddressSanitizer to avoid error messages - e.g. if you're 29 | # preloading another library to your application. At the moment this script will 30 | # only do something, if we're running on a Linux platform. OSX might not be 31 | # affected. 32 | 33 | 34 | # Exit immediately, if platform is not Linux. 35 | if [ "$(uname)" != "Linux" ] 36 | then 37 | exec $@ 38 | fi 39 | 40 | 41 | # Get the used libasan of the application ($1). If a libasan was found, it will 42 | # be prepended to LD_PRELOAD. 43 | libasan=$(ldd $1 | grep libasan | sed "s/^[[:space:]]//" | cut -d' ' -f1) 44 | if [ -n "$libasan" ] 45 | then 46 | if [ -n "$LD_PRELOAD" ] 47 | then 48 | export LD_PRELOAD="$libasan:$LD_PRELOAD" 49 | else 50 | export LD_PRELOAD="$libasan" 51 | fi 52 | fi 53 | 54 | # Execute the application. 55 | exec $@ 56 | -------------------------------------------------------------------------------- /cmake/FindASan.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | option(SANITIZE_ADDRESS "Enable AddressSanitizer for sanitized targets." Off) 26 | 27 | set(FLAG_CANDIDATES 28 | # Clang 3.2+ use this version. The no-omit-frame-pointer option is optional. 29 | "-g -fsanitize=address -fno-omit-frame-pointer" 30 | "-g -fsanitize=address" 31 | 32 | # Older deprecated flag for ASan 33 | "-g -faddress-sanitizer" 34 | ) 35 | 36 | 37 | if (SANITIZE_ADDRESS AND (SANITIZE_THREAD OR SANITIZE_MEMORY)) 38 | message(FATAL_ERROR "AddressSanitizer is not compatible with " 39 | "ThreadSanitizer or MemorySanitizer.") 40 | endif () 41 | 42 | 43 | include(sanitize-helpers) 44 | 45 | if (SANITIZE_ADDRESS) 46 | sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "AddressSanitizer" 47 | "ASan") 48 | 49 | find_program(ASan_WRAPPER "asan-wrapper" PATHS ${CMAKE_MODULE_PATH}) 50 | mark_as_advanced(ASan_WRAPPER) 51 | endif () 52 | 53 | function (add_sanitize_address TARGET) 54 | if (NOT SANITIZE_ADDRESS) 55 | return() 56 | endif () 57 | 58 | sanitizer_add_flags(${TARGET} "AddressSanitizer" "ASan") 59 | endfunction () 60 | -------------------------------------------------------------------------------- /ext/mstch/src/render_context.cpp: -------------------------------------------------------------------------------- 1 | #include "render_context.hpp" 2 | #include "state/outside_section.hpp" 3 | #include "visitor/get_token.hpp" 4 | 5 | using namespace mstch; 6 | 7 | const mstch::node render_context::null_node; 8 | 9 | render_context::push::push(render_context& context, const mstch::node& node): 10 | m_context(context) 11 | { 12 | context.m_nodes.emplace_front(node); 13 | context.m_node_ptrs.emplace_front(&node); 14 | context.m_state.push(std::unique_ptr(new outside_section)); 15 | } 16 | 17 | render_context::push::~push() { 18 | m_context.m_nodes.pop_front(); 19 | m_context.m_node_ptrs.pop_front(); 20 | m_context.m_state.pop(); 21 | } 22 | 23 | std::string render_context::push::render(const template_type& templt) { 24 | return m_context.render(templt); 25 | } 26 | 27 | render_context::render_context( 28 | const mstch::node& node, 29 | const std::map& partials): 30 | m_partials(partials), m_nodes(1, node), m_node_ptrs(1, &node) 31 | { 32 | m_state.push(std::unique_ptr(new outside_section)); 33 | } 34 | 35 | const mstch::node& render_context::find_node( 36 | const std::string& token, 37 | std::list current_nodes) 38 | { 39 | if (token != "." && token.find('.') != std::string::npos) 40 | return find_node(token.substr(token.rfind('.') + 1), 41 | {&find_node(token.substr(0, token.rfind('.')), current_nodes)}); 42 | else 43 | for (auto& node: current_nodes) 44 | if (visit(has_token(token), *node)) 45 | return visit(get_token(token, *node), *node); 46 | return null_node; 47 | } 48 | 49 | const mstch::node& render_context::get_node(const std::string& token) { 50 | return find_node(token, m_node_ptrs); 51 | } 52 | 53 | std::string render_context::render( 54 | const template_type& templt, const std::string& prefix) 55 | { 56 | std::string output; 57 | bool prev_eol = true; 58 | for (auto& token: templt) { 59 | if (prev_eol && prefix.length() != 0) 60 | output += m_state.top()->render(*this, {prefix}); 61 | output += m_state.top()->render(*this, token); 62 | prev_eol = token.eol(); 63 | } 64 | return output; 65 | } 66 | 67 | std::string render_context::render_partial( 68 | const std::string& partial_name, const std::string& prefix) 69 | { 70 | return m_partials.count(partial_name) ? 71 | render(m_partials.at(partial_name), prefix) : ""; 72 | } 73 | -------------------------------------------------------------------------------- /cmake/MyUtils.cmake: -------------------------------------------------------------------------------- 1 | 2 | macro(configure_files srcDir destDir) 3 | message(STATUS "Configuring directory ${destDir}") 4 | make_directory(${destDir}) 5 | 6 | file(GLOB templateFiles RELATIVE ${srcDir} ${srcDir}/*) 7 | foreach(templateFile ${templateFiles}) 8 | set(srcTemplatePath ${srcDir}/${templateFile}) 9 | if(NOT IS_DIRECTORY ${srcTemplatePath}) 10 | message(STATUS "Configuring file ${templateFile}") 11 | if(${templateFile} MATCHES "((jp|pn|sv)g|bmp)$") 12 | file(COPY ${srcDir}/${templateFile} DESTINATION ${destDir}) 13 | else() 14 | configure_file( 15 | ${srcTemplatePath} 16 | ${destDir}/${templateFile} 17 | @ONLY) 18 | endif() 19 | endif(NOT IS_DIRECTORY ${srcTemplatePath}) 20 | endforeach(templateFile) 21 | endmacro(configure_files) 22 | 23 | macro(create_git_version) 24 | # Get the current working branch 25 | execute_process( 26 | COMMAND git rev-parse --abbrev-ref HEAD 27 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 28 | OUTPUT_VARIABLE GIT_BRANCH 29 | OUTPUT_STRIP_TRAILING_WHITESPACE 30 | ) 31 | 32 | # http://xit0.org/2013/04/cmake-use-git-branch-and-commit-details-in-project/ 33 | # Get the latest abbreviated commit hash of the working branch 34 | execute_process( 35 | COMMAND git log -1 --format=%h 36 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 37 | OUTPUT_VARIABLE GIT_COMMIT_HASH 38 | OUTPUT_STRIP_TRAILING_WHITESPACE 39 | ) 40 | 41 | # Get the date and time of last commit 42 | execute_process( 43 | COMMAND git log -1 --format=%cd --date=short 44 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 45 | OUTPUT_VARIABLE GIT_COMMIT_DATETIME 46 | OUTPUT_STRIP_TRAILING_WHITESPACE 47 | ) 48 | 49 | # Get current branch name 50 | execute_process( 51 | COMMAND git rev-parse --abbrev-ref HEAD 52 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 53 | OUTPUT_VARIABLE GIT_BRANCH_NAME 54 | OUTPUT_STRIP_TRAILING_WHITESPACE 55 | ) 56 | 57 | 58 | 59 | configure_file( 60 | ${CMAKE_SOURCE_DIR}/src/version.h.in 61 | ${CMAKE_BINARY_DIR}/gen/version.h 62 | ) 63 | 64 | include_directories(${CMAKE_BINARY_DIR}/gen) 65 | 66 | endmacro(create_git_version) -------------------------------------------------------------------------------- /cmake/FindMSan.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | option(SANITIZE_MEMORY "Enable MemorySanitizer for sanitized targets." Off) 26 | 27 | set(FLAG_CANDIDATES 28 | "-g -fsanitize=memory" 29 | ) 30 | 31 | 32 | include(sanitize-helpers) 33 | 34 | if (SANITIZE_MEMORY) 35 | if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 36 | message(WARNING "MemorySanitizer disabled for target ${TARGET} because " 37 | "MemorySanitizer is supported for Linux systems only.") 38 | set(SANITIZE_MEMORY Off CACHE BOOL 39 | "Enable MemorySanitizer for sanitized targets." FORCE) 40 | elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8) 41 | message(WARNING "MemorySanitizer disabled for target ${TARGET} because " 42 | "MemorySanitizer is supported for 64bit systems only.") 43 | set(SANITIZE_MEMORY Off CACHE BOOL 44 | "Enable MemorySanitizer for sanitized targets." FORCE) 45 | else () 46 | sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "MemorySanitizer" 47 | "MSan") 48 | endif () 49 | endif () 50 | 51 | function (add_sanitize_memory TARGET) 52 | if (NOT SANITIZE_MEMORY) 53 | return() 54 | endif () 55 | 56 | sanitizer_add_flags(${TARGET} "MemorySanitizer" "MSan") 57 | endfunction () 58 | -------------------------------------------------------------------------------- /src/templates/checkrawoutputkeys.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 |

Signed Outputs Public Keys Checker

6 |
7 | 8 |

Data file prefix: {{data_prefix}}

9 | 10 | {{#has_error}} 11 |

Attempt failed

12 |

{{error_msg}}

13 | {{/has_error}} 14 | {{^has_error}} 15 |

Output keys for address: {{address}}

16 |

Viewkey: {{viewkey}}

17 | {{#has_total_etn}} 18 |

Total ETN: {{total_etn}}

19 | {{/has_total_etn}} 20 | 21 |
22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | {{#are_key_images_known}} 31 | 32 | {{/are_key_images_known}} 33 | 34 | 35 | {{#output_keys}} 36 | 37 | 38 | 39 | 40 | 41 | 42 | {{#are_key_images_known}} 43 | 50 | {{/are_key_images_known}} 51 | 52 | 53 | 54 | {{/output_keys}} 55 |
Output no.Public keyTimestampRingCTIs spent?Amount
{{output_no}}{{output_pub_key}}{{timestamp}}{{is_ringct}}{{^is_spent}} 44 | {{is_spent}} 45 | {{/is_spent}} 46 | {{#is_spent}} 47 | {{is_spent}} 48 | {{/is_spent}} 49 | {{amount}}
56 |
57 |
58 | 59 |
60 | 61 | {{/has_error}} 62 | 63 |
-------------------------------------------------------------------------------- /ext/crow/crow/dumb_timer_queue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "crow/logging.h" 10 | 11 | namespace crow 12 | { 13 | namespace detail 14 | { 15 | // fast timer queue for fixed tick value. 16 | class dumb_timer_queue 17 | { 18 | public: 19 | using key = std::pair; 20 | 21 | void cancel(key& k) 22 | { 23 | auto self = k.first; 24 | k.first = nullptr; 25 | if (!self) 26 | return; 27 | 28 | unsigned int index = (unsigned int)(k.second - self->step_); 29 | if (index < self->dq_.size()) 30 | self->dq_[index].second = nullptr; 31 | } 32 | 33 | key add(std::function f) 34 | { 35 | dq_.emplace_back(std::chrono::steady_clock::now(), std::move(f)); 36 | int ret = step_+dq_.size()-1; 37 | 38 | CROW_LOG_DEBUG << "timer add inside: " << this << ' ' << ret ; 39 | return {this, ret}; 40 | } 41 | 42 | void process() 43 | { 44 | if (!io_service_) 45 | return; 46 | 47 | auto now = std::chrono::steady_clock::now(); 48 | while(!dq_.empty()) 49 | { 50 | auto& x = dq_.front(); 51 | if (now - x.first < std::chrono::seconds(tick)) 52 | break; 53 | if (x.second) 54 | { 55 | CROW_LOG_DEBUG << "timer call: " << this << ' ' << step_; 56 | // we know that timer handlers are very simple currenty; call here 57 | x.second(); 58 | } 59 | dq_.pop_front(); 60 | step_++; 61 | } 62 | } 63 | 64 | void set_io_service(boost::asio::io_service& io_service) 65 | { 66 | io_service_ = &io_service; 67 | } 68 | 69 | dumb_timer_queue() noexcept 70 | { 71 | } 72 | 73 | private: 74 | 75 | int tick{5}; 76 | boost::asio::io_service* io_service_{}; 77 | std::deque>> dq_; 78 | int step_{}; 79 | }; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /ext/crow/crow/middleware_context.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "crow/utility.h" 4 | #include "crow/http_request.h" 5 | #include "crow/http_response.h" 6 | 7 | namespace crow 8 | { 9 | namespace detail 10 | { 11 | template 12 | struct partial_context 13 | : public black_magic::pop_back::template rebind 14 | , public black_magic::last_element_type::type::context 15 | { 16 | using parent_context = typename black_magic::pop_back::template rebind<::crow::detail::partial_context>; 17 | template 18 | using partial = typename std::conditional>::type; 19 | 20 | template 21 | typename T::context& get() 22 | { 23 | return static_cast(*this); 24 | } 25 | }; 26 | 27 | template <> 28 | struct partial_context<> 29 | { 30 | template 31 | using partial = partial_context; 32 | }; 33 | 34 | template 35 | bool middleware_call_helper(Container& middlewares, request& req, response& res, Context& ctx); 36 | 37 | template 38 | struct context : private partial_context 39 | //struct context : private Middlewares::context... // simple but less type-safe 40 | { 41 | template 42 | friend typename std::enable_if<(N==0)>::type after_handlers_call_helper(Container& middlewares, Context& ctx, request& req, response& res); 43 | template 44 | friend typename std::enable_if<(N>0)>::type after_handlers_call_helper(Container& middlewares, Context& ctx, request& req, response& res); 45 | 46 | template 47 | friend bool middleware_call_helper(Container& middlewares, request& req, response& res, Context& ctx); 48 | 49 | template 50 | typename T::context& get() 51 | { 52 | return static_cast(*this); 53 | } 54 | 55 | template 56 | using partial = typename partial_context::template partial; 57 | }; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /cmake/FindTSan.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | option(SANITIZE_THREAD "Enable ThreadSanitizer for sanitized targets." Off) 26 | 27 | set(FLAG_CANDIDATES 28 | "-g -fsanitize=thread" 29 | ) 30 | 31 | 32 | # ThreadSanitizer is not compatible with MemorySanitizer. 33 | if (SANITIZE_THREAD AND SANITIZE_MEMORY) 34 | message(FATAL_ERROR "ThreadSanitizer is not compatible with " 35 | "MemorySanitizer.") 36 | endif () 37 | 38 | 39 | include(sanitize-helpers) 40 | 41 | if (SANITIZE_THREAD) 42 | if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND 43 | NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") 44 | message(WARNING "ThreadSanitizer disabled for target ${TARGET} because " 45 | "ThreadSanitizer is supported for Linux systems and macOS only.") 46 | set(SANITIZE_THREAD Off CACHE BOOL 47 | "Enable ThreadSanitizer for sanitized targets." FORCE) 48 | elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8) 49 | message(WARNING "ThreadSanitizer disabled for target ${TARGET} because " 50 | "ThreadSanitizer is supported for 64bit systems only.") 51 | set(SANITIZE_THREAD Off CACHE BOOL 52 | "Enable ThreadSanitizer for sanitized targets." FORCE) 53 | else () 54 | sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ThreadSanitizer" 55 | "TSan") 56 | endif () 57 | endif () 58 | 59 | function (add_sanitize_thread TARGET) 60 | if (NOT SANITIZE_THREAD) 61 | return() 62 | endif () 63 | 64 | sanitizer_add_flags(${TARGET} "ThreadSanitizer" "TSan") 65 | endfunction () 66 | -------------------------------------------------------------------------------- /src/MicroCore.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mwo on 5/11/15. 3 | // 4 | 5 | #ifndef ETNEG01_MICROCORE_H 6 | #define ETNEG01_MICROCORE_H 7 | 8 | #include 9 | 10 | #include "electroneum_headers.h" 11 | #include "tools.h" 12 | 13 | namespace electroneumeg 14 | { 15 | using namespace cryptonote; 16 | using namespace crypto; 17 | using namespace std; 18 | 19 | /** 20 | * Micro version of cryptonode::core class 21 | * Micro version of constructor, 22 | * init and destructor are implemted. 23 | * 24 | * Just enough to read the blockchain 25 | * database for use in the example. 26 | */ 27 | class MicroCore { 28 | 29 | string blockchain_path; 30 | 31 | tx_memory_pool m_mempool; 32 | Blockchain m_blockchain_storage; 33 | 34 | hw::device* m_device; 35 | 36 | network_type nettype; 37 | 38 | public: 39 | MicroCore(); 40 | 41 | bool 42 | init(const string& _blockchain_path, network_type nt); 43 | 44 | Blockchain& 45 | get_core(); 46 | 47 | tx_memory_pool& 48 | get_mempool(); 49 | 50 | bool 51 | get_block_by_height(const uint64_t& height, block& blk); 52 | 53 | bool 54 | get_tx(const crypto::hash& tx_hash, transaction& tx); 55 | 56 | bool 57 | get_tx(const string& tx_hash, transaction& tx); 58 | 59 | bool 60 | find_output_in_tx(const transaction& tx, 61 | const public_key& output_pubkey, 62 | tx_out& out, 63 | size_t& output_index); 64 | 65 | uint64_t 66 | get_blk_timestamp(uint64_t blk_height); 67 | 68 | std::vector 69 | get_addr_outputs(const public_key &view_key, const public_key &spend_key); 70 | 71 | std::vector 72 | get_addr_txs(const public_key &view_key, const public_key &spend_key); 73 | 74 | uint64_t 75 | get_balance(const public_key &view_key, const public_key &spend_key); 76 | 77 | cryptonote::tx_input_t 78 | get_tx_input(const crypto::hash tx_hash, const uint64_t relative_out_index); 79 | 80 | bool 81 | get_block_complete_entry(block const& b, block_complete_entry& bce); 82 | 83 | string 84 | get_blkchain_path(); 85 | 86 | hw::device* const 87 | get_device() const; 88 | 89 | virtual ~MicroCore(); 90 | 91 | unique_ptr validators; 92 | }; 93 | 94 | 95 | 96 | bool 97 | init_blockchain(const string& path, 98 | MicroCore& mcore, 99 | Blockchain*& core_storage, 100 | network_type nt); 101 | 102 | 103 | } 104 | 105 | 106 | 107 | #endif //ETNEG01_MICROCORE_H 108 | -------------------------------------------------------------------------------- /src/CurrentBlockchainStatus.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mwo on 16/05/17. 3 | // 4 | 5 | #ifndef ETNBLOCKS_CURRENTBLOCKCHAINSTATUS_H 6 | #define ETNBLOCKS_CURRENTBLOCKCHAINSTATUS_H 7 | 8 | #include "MicroCore.h" 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace electroneumeg 19 | { 20 | 21 | using namespace std; 22 | 23 | namespace bf = boost::filesystem; 24 | 25 | struct CurrentBlockchainStatus 26 | { 27 | 28 | struct Emission 29 | { 30 | uint64_t coinbase; 31 | uint64_t fee; 32 | uint64_t blk_no; 33 | 34 | inline uint64_t 35 | checksum() const 36 | { 37 | return coinbase + fee + blk_no; 38 | } 39 | 40 | operator 41 | std::string() const 42 | { 43 | return to_string(blk_no) + "," + to_string(coinbase) 44 | + "," + to_string(fee) + "," + to_string(checksum()); 45 | } 46 | }; 47 | 48 | static bf::path blockchain_path; 49 | 50 | static cryptonote::network_type nettype; 51 | 52 | static string output_file; 53 | 54 | static string deamon_url; 55 | 56 | // how many blocks to read before thread goes to sleep 57 | static uint64_t blockchain_chunk_size; 58 | 59 | // gap from what we store total_emission_atomic and 60 | // current blockchain height. We dont want to store 61 | // what is on, e.g., top block, as this can get messy 62 | // if the block gets orphaned or blockchain reorganization 63 | // occurs. So the top 3 blocks (default number) will always 64 | // be calculated in flight and added to what we have so far. 65 | static uint64_t blockchain_chunk_gap; 66 | 67 | // current blockchain height and 68 | // hash of top block 69 | static atomic current_height; 70 | 71 | 72 | static atomic total_emission_atomic; 73 | 74 | 75 | static boost::thread m_thread; 76 | 77 | static atomic is_running; 78 | 79 | // make object for accessing the blockchain here 80 | static MicroCore* mcore; 81 | static Blockchain* core_storage; 82 | 83 | static void 84 | start_monitor_blockchain_thread(); 85 | 86 | static void 87 | set_blockchain_variables(MicroCore* _mcore, 88 | Blockchain* _core_storage); 89 | 90 | static void 91 | update_current_emission_amount(); 92 | 93 | static Emission 94 | calculate_emission_in_blocks(uint64_t start_blk, uint64_t end_blk); 95 | 96 | static bool 97 | save_current_emission_amount(); 98 | 99 | static bool 100 | load_current_emission_amount(); 101 | 102 | static Emission 103 | get_emission(); 104 | 105 | static bf::path 106 | get_output_file_path(); 107 | 108 | static bool 109 | is_thread_running(); 110 | }; 111 | 112 | } 113 | 114 | #endif //ETNBLOCKS_CURRENTBLOCKCHAINSTATUS_H 115 | -------------------------------------------------------------------------------- /ext/crow/crow/socket_adaptors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #ifdef CROW_ENABLE_SSL 4 | #include 5 | #endif 6 | #include "crow/settings.h" 7 | #if BOOST_VERSION >= 107000 8 | #define GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context()) 9 | #else 10 | #define GET_IO_SERVICE(s) ((s).get_io_service()) 11 | #endif 12 | namespace crow 13 | { 14 | using namespace boost; 15 | using tcp = asio::ip::tcp; 16 | 17 | struct SocketAdaptor 18 | { 19 | using context = void; 20 | SocketAdaptor(boost::asio::io_service& io_service, context*) 21 | : socket_(io_service) 22 | { 23 | } 24 | 25 | boost::asio::io_service& get_io_service() 26 | { 27 | return GET_IO_SERVICE(socket_); 28 | } 29 | 30 | tcp::socket& raw_socket() 31 | { 32 | return socket_; 33 | } 34 | 35 | tcp::socket& socket() 36 | { 37 | return socket_; 38 | } 39 | 40 | tcp::endpoint remote_endpoint() 41 | { 42 | return socket_.remote_endpoint(); 43 | } 44 | 45 | bool is_open() 46 | { 47 | return socket_.is_open(); 48 | } 49 | 50 | void close() 51 | { 52 | socket_.close(); 53 | } 54 | 55 | template 56 | void start(F f) 57 | { 58 | f(boost::system::error_code()); 59 | } 60 | 61 | tcp::socket socket_; 62 | }; 63 | 64 | #ifdef CROW_ENABLE_SSL 65 | struct SSLAdaptor 66 | { 67 | using context = boost::asio::ssl::context; 68 | using ssl_socket_t = boost::asio::ssl::stream; 69 | SSLAdaptor(boost::asio::io_service& io_service, context* ctx) 70 | : ssl_socket_(new ssl_socket_t(io_service, *ctx)) 71 | { 72 | } 73 | 74 | boost::asio::ssl::stream& socket() 75 | { 76 | return *ssl_socket_; 77 | } 78 | 79 | tcp::socket::lowest_layer_type& 80 | raw_socket() 81 | { 82 | return ssl_socket_->lowest_layer(); 83 | } 84 | 85 | tcp::endpoint remote_endpoint() 86 | { 87 | return raw_socket().remote_endpoint(); 88 | } 89 | 90 | bool is_open() 91 | { 92 | return raw_socket().is_open(); 93 | } 94 | 95 | void close() 96 | { 97 | raw_socket().close(); 98 | } 99 | 100 | boost::asio::io_service& get_io_service() 101 | { 102 | return GET_IO_SERVICE(raw_socket()); 103 | } 104 | 105 | template 106 | void start(F f) 107 | { 108 | ssl_socket_->async_handshake(boost::asio::ssl::stream_base::server, 109 | [f](const boost::system::error_code& ec) { 110 | f(ec); 111 | }); 112 | } 113 | 114 | std::unique_ptr> ssl_socket_; 115 | }; 116 | #endif 117 | } 118 | -------------------------------------------------------------------------------- /cmake/FindElectroneum.cmake: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # CMake helper for the majority of the cpp-ethereum modules. 3 | # 4 | # This module defines 5 | # Electroneum_XXX_LIBRARIES, the libraries needed to use ethereum. 6 | # Electroneum_FOUND, If false, do not try to use ethereum. 7 | # 8 | # File addetped from cpp-ethereum 9 | # 10 | # The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org 11 | # 12 | # ------------------------------------------------------------------------------ 13 | # This file is part of cpp-ethereum. 14 | # 15 | # cpp-ethereum is free software: you can redistribute it and/or modify 16 | # it under the terms of the GNU General Public License as published by 17 | # the Free Software Foundation, either version 3 of the License, or 18 | # (at your option) any later version. 19 | # 20 | # cpp-ethereum is distributed in the hope that it will be useful, 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | # GNU General Public License for more details. 24 | # 25 | # You should have received a copy of the GNU General Public License 26 | # along with cpp-ethereum. If not, see 27 | # 28 | # (c) 2014-2016 cpp-ethereum contributors. 29 | #------------------------------------------------------------------------------ 30 | 31 | set(LIBS common;blocks;cryptonote_basic;cryptonote_core;multisig; 32 | cryptonote_protocol;daemonizer;mnemonics;epee;lmdb;device; 33 | blockchain_db;ringct;wallet;cncrypto;easylogging;version;checkpoints;ed25519-donna) 34 | 35 | set(Etn_INCLUDE_DIRS "${CPP_ELECTRONEUM_DIR}") 36 | 37 | # if the project is a subset of main cpp-ethereum project 38 | # use same pattern for variables as Boost uses 39 | 40 | foreach (l ${LIBS}) 41 | 42 | string(TOUPPER ${l} L) 43 | 44 | find_library(Etn_${L}_LIBRARY 45 | NAMES ${l} 46 | PATHS ${CMAKE_LIBRARY_PATH} 47 | PATH_SUFFIXES "/" "/src/${l}" "/src/" "/external/db_drivers/lib${l}" "/lib" "/src/crypto" "/contrib/epee/src" "/external/easylogging++/" "/external/ed25519-donna/" 48 | NO_DEFAULT_PATH 49 | ) 50 | 51 | set(Etn_${L}_LIBRARIES ${Etn_${L}_LIBRARY}) 52 | 53 | message(STATUS FindElectroneum " Etn_${L}_LIBRARIES ${Etn_${L}_LIBRARY}") 54 | 55 | add_library(${l} STATIC IMPORTED) 56 | set_property(TARGET ${l} PROPERTY IMPORTED_LOCATION ${Etn_${L}_LIBRARIES}) 57 | 58 | endforeach() 59 | 60 | if (EXISTS ${ELECTRONEUM_BUILD_DIR}/src/ringct/libringct_basic.a) 61 | message(STATUS FindElectroneum " found libringct_basic.a") 62 | add_library(ringct_basic STATIC IMPORTED) 63 | set_property(TARGET ringct_basic 64 | PROPERTY IMPORTED_LOCATION ${ELECTRONEUM_BUILD_DIR}/src/ringct/libringct_basic.a) 65 | endif() 66 | 67 | 68 | message(STATUS ${ELECTRONEUM_SOURCE_DIR}/build) 69 | 70 | # include electroneum headers 71 | include_directories( 72 | ${ELECTRONEUM_SOURCE_DIR}/src 73 | ${ELECTRONEUM_SOURCE_DIR}/external 74 | ${ELECTRONEUM_SOURCE_DIR}/build 75 | ${ELECTRONEUM_SOURCE_DIR}/external/easylogging++ 76 | ${ELECTRONEUM_SOURCE_DIR}/external/ed25519-donna 77 | ${ELECTRONEUM_SOURCE_DIR}/contrib/epee/include 78 | ${ELECTRONEUM_SOURCE_DIR}/external/db_drivers/liblmdb) -------------------------------------------------------------------------------- /ext/vpetrigocaches/cache.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CACHE_HPP 2 | #define CACHE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "cache_policy.hpp" 10 | 11 | namespace caches 12 | { 13 | 14 | // Base class for caching algorithms 15 | template > 16 | class fixed_sized_cache 17 | { 18 | public: 19 | 20 | using iterator = typename std::unordered_map::iterator; 21 | 22 | using const_iterator = 23 | typename std::unordered_map::const_iterator; 24 | 25 | using operation_guard = typename std::lock_guard; 26 | 27 | fixed_sized_cache( 28 | size_t max_size, 29 | const Policy& policy = Policy()) 30 | : max_cache_size{max_size}, 31 | cache_policy(policy) 32 | { 33 | if (max_cache_size == 0) 34 | { 35 | max_cache_size = std::numeric_limits::max(); 36 | } 37 | } 38 | 39 | void Put(const Key& key, const Value& value) 40 | { 41 | operation_guard{safe_op}; 42 | auto elem_it = FindElem(key); 43 | 44 | if (elem_it == cache_items_map.end()) 45 | { 46 | // add new element to the cache 47 | if (Size() + 1 > max_cache_size) 48 | { 49 | auto disp_candidate_key = cache_policy.ReplCandidate(); 50 | 51 | Erase(disp_candidate_key); 52 | } 53 | 54 | Insert(key, value); 55 | } 56 | else 57 | { 58 | // update previous value 59 | Update(key, value); 60 | } 61 | } 62 | 63 | bool Contains(const Key& key) 64 | { 65 | operation_guard{safe_op}; 66 | auto elem_it = FindElem(key); 67 | return elem_it != cache_items_map.end(); 68 | } 69 | 70 | const Value& Get(const Key& key) const 71 | { 72 | operation_guard{safe_op}; 73 | auto elem_it = FindElem(key); 74 | 75 | if (elem_it == cache_items_map.end()) 76 | { 77 | throw std::range_error{"No such element in the cache"}; 78 | } 79 | cache_policy.Touch(key); 80 | 81 | return elem_it->second; 82 | } 83 | 84 | const size_t Size() const 85 | { 86 | operation_guard{safe_op}; 87 | 88 | return cache_items_map.size(); 89 | } 90 | 91 | // return a key of a displacement candidate 92 | void Clear() 93 | { 94 | operation_guard{safe_op}; 95 | 96 | cache_policy.Clear(); 97 | cache_items_map.clear(); 98 | } 99 | 100 | protected: 101 | 102 | void Insert(const Key& key, const Value& value) 103 | { 104 | cache_policy.Insert(key); 105 | cache_items_map.emplace(std::make_pair(key, value)); 106 | } 107 | 108 | void Erase(const Key& key) 109 | { 110 | cache_policy.Erase(key); 111 | cache_items_map.erase(key); 112 | } 113 | 114 | void Update(const Key& key, const Value& value) 115 | { 116 | cache_policy.Touch(key); 117 | cache_items_map[key] = value; 118 | } 119 | 120 | const_iterator FindElem(const Key& key) const 121 | { 122 | return cache_items_map.find(key); 123 | } 124 | 125 | 126 | private: 127 | 128 | std::unordered_map cache_items_map; 129 | 130 | mutable Policy cache_policy; 131 | mutable std::mutex safe_op; 132 | 133 | size_t max_cache_size; 134 | 135 | }; 136 | } 137 | 138 | #endif // CACHE_HPP 139 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Use ubuntu:20.04 as base for builder stage image 2 | FROM ubuntu:20.04 as builder 3 | 4 | # Set Electroneum branch/tag to be used for electroneumd compilation 5 | 6 | ARG ELECTRONEUM_BRANCH=master 7 | 8 | # Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation 9 | ENV DEBIAN_FRONTEND="noninteractive" 10 | 11 | # Install dependencies for electroneumd and etnblocks compilation 12 | RUN apt-get update \ 13 | && apt-get upgrade -y \ 14 | && apt-get install -y --no-install-recommends \ 15 | git \ 16 | build-essential \ 17 | cmake \ 18 | miniupnpc \ 19 | graphviz \ 20 | doxygen \ 21 | pkg-config \ 22 | ca-certificates \ 23 | zip \ 24 | libboost-all-dev \ 25 | libunbound-dev \ 26 | libunwind8-dev \ 27 | libssl-dev \ 28 | libcurl4-openssl-dev \ 29 | libgtest-dev \ 30 | libreadline-dev \ 31 | libzmq3-dev \ 32 | libsodium-dev \ 33 | libhidapi-dev \ 34 | libhidapi-libusb0 \ 35 | liblzma-dev \ 36 | libldns-dev \ 37 | libexpat1-dev \ 38 | libpgm-dev \ 39 | libusb-dev \ 40 | libsecp256k1-dev \ 41 | && apt-get clean \ 42 | && rm -rf /var/lib/apt/lists/* 43 | 44 | # Set compilation environment variables 45 | ENV CFLAGS='-fPIC' 46 | ENV CXXFLAGS='-fPIC' 47 | ENV USE_SINGLE_BUILDDIR 1 48 | ENV BOOST_DEBUG 1 49 | 50 | WORKDIR /root 51 | 52 | # Clone and compile electroneumd with all available threads 53 | ARG NPROC 54 | RUN git clone --recursive --branch ${ELECTRONEUM_BRANCH} https://github.com/electroneum/electroneum.git \ 55 | && cd electroneum \ 56 | && test -z "$NPROC" && nproc > /nproc || echo -n "$NPROC" > /nproc && make -j"$(cat /nproc)" 57 | 58 | 59 | # Copy and cmake/make etnblocks with all available threads 60 | COPY . /root/electroneum-blockchain-explorer/ 61 | WORKDIR /root/electroneum-blockchain-explorer/build 62 | RUN cmake .. && make -j"$(cat /nproc)" 63 | 64 | # Use ldd and awk to bundle up dynamic libraries for the final image 65 | RUN zip /lib.zip $(ldd etnblocks | grep -E '/[^\ ]*' -o) 66 | 67 | # Use ubuntu:20.04 as base for final image 68 | FROM ubuntu:20.04 69 | 70 | # Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation 71 | ENV DEBIAN_FRONTEND="noninteractive" 72 | 73 | # Install unzip to handle bundled libs from builder stage 74 | RUN apt-get update \ 75 | && apt-get upgrade -y \ 76 | && apt-get install -y --no-install-recommends unzip \ 77 | && apt-get clean \ 78 | && rm -rf /var/lib/apt/lists/* 79 | 80 | COPY --from=builder /lib.zip . 81 | RUN unzip -o lib.zip && rm -rf lib.zip 82 | 83 | # Add user and setup directories for electroneumd and etnblocks 84 | RUN useradd -ms /bin/bash electroneum \ 85 | && mkdir -p /home/electroneum/.electroneum \ 86 | && chown -R electroneum:electroneum /home/electroneum/.electroneum 87 | USER electroneum 88 | 89 | # Switch to home directory and install newly built etnblocks binary 90 | WORKDIR /home/electroneum 91 | COPY --chown=electroneum:electroneum --from=builder /root/electroneum-blockchain-explorer/build/etnblocks . 92 | COPY --chown=electroneum:electroneum --from=builder /root/electroneum-blockchain-explorer/build/templates ./templates/ 93 | 94 | # Expose volume used for lmdb access by etnblocks 95 | VOLUME /home/electroneum/.electroneum 96 | 97 | # Expose default explorer http port 98 | EXPOSE 8081 99 | 100 | ENTRYPOINT ["/bin/sh", "-c"] 101 | 102 | # Set sane defaults that are overridden if the user passes any commands 103 | CMD ["./etnblocks --enable-json-api --enable-autorefresh-option --enable-pusher"] 104 | -------------------------------------------------------------------------------- /ext/mstch/src/template_type.cpp: -------------------------------------------------------------------------------- 1 | #include "template_type.hpp" 2 | 3 | using namespace mstch; 4 | 5 | template_type::template_type(const std::string& str, const delim_type& delims): 6 | m_open(delims.first), m_close(delims.second) 7 | { 8 | tokenize(str); 9 | strip_whitespace(); 10 | } 11 | 12 | template_type::template_type(const std::string& str): 13 | m_open("{{"), m_close("}}") 14 | { 15 | tokenize(str); 16 | strip_whitespace(); 17 | } 18 | 19 | void template_type::process_text(citer begin, citer end) { 20 | if (begin == end) 21 | return; 22 | auto start = begin; 23 | for (auto it = begin; it != end; ++it) 24 | if (*it == '\n' || it == end - 1) { 25 | m_tokens.push_back({{start, it + 1}}); 26 | start = it + 1; 27 | } 28 | } 29 | 30 | void template_type::tokenize(const std::string& tmp) { 31 | citer beg = tmp.begin(); 32 | auto npos = std::string::npos; 33 | 34 | for (std::size_t cur_pos = 0; cur_pos < tmp.size();) { 35 | auto open_pos = tmp.find(m_open, cur_pos); 36 | auto close_pos = tmp.find( 37 | m_close, open_pos == npos ? open_pos : open_pos + 1); 38 | 39 | if (close_pos != npos && open_pos != npos) { 40 | if (*(beg + open_pos + m_open.size()) == '{' && 41 | *(beg + close_pos + m_close.size()) == '}') 42 | ++close_pos; 43 | 44 | process_text(beg + cur_pos, beg + open_pos); 45 | cur_pos = close_pos + m_close.size(); 46 | m_tokens.push_back({{beg + open_pos, beg + close_pos + m_close.size()}, 47 | m_open.size(), m_close.size()}); 48 | 49 | if (cur_pos == tmp.size()) { 50 | m_tokens.push_back({{""}}); 51 | m_tokens.back().eol(true); 52 | } 53 | 54 | if (*(beg + open_pos + m_open.size()) == '=' && 55 | *(beg + close_pos - 1) == '=') 56 | { 57 | auto tok_beg = beg + open_pos + m_open.size() + 1; 58 | auto tok_end = beg + close_pos - 1; 59 | auto front_skip = first_not_ws(tok_beg, tok_end); 60 | auto back_skip = first_not_ws(reverse(tok_end), reverse(tok_beg)); 61 | m_open = {front_skip, beg + tmp.find(' ', front_skip - beg)}; 62 | m_close = {beg + tmp.rfind(' ', back_skip - beg) + 1, back_skip + 1}; 63 | } 64 | } else { 65 | process_text(beg + cur_pos, tmp.end()); 66 | cur_pos = close_pos; 67 | } 68 | } 69 | } 70 | 71 | void template_type::strip_whitespace() { 72 | auto line_begin = m_tokens.begin(); 73 | bool has_tag = false, non_space = false; 74 | 75 | for (auto it = m_tokens.begin(); it != m_tokens.end(); ++it) { 76 | auto type = (*it).token_type(); 77 | if (type != token::type::text && type != token::type::variable && 78 | type != token::type::unescaped_variable) 79 | has_tag = true; 80 | else if (!(*it).ws_only()) 81 | non_space = true; 82 | 83 | if ((*it).eol()) { 84 | if (has_tag && !non_space) { 85 | store_prefixes(line_begin); 86 | 87 | auto c = line_begin; 88 | for (bool end = false; !end; (*c).ws_only() ? c = m_tokens.erase(c) : ++c) 89 | if ((end = (*c).eol())) 90 | it = c - 1; 91 | } 92 | 93 | non_space = has_tag = false; 94 | line_begin = it + 1; 95 | } 96 | } 97 | } 98 | 99 | void template_type::store_prefixes(std::vector::iterator beg) { 100 | for (auto cur = beg; !(*cur).eol(); ++cur) 101 | if ((*cur).token_type() == token::type::partial && 102 | cur != beg && (*(cur - 1)).ws_only()) 103 | (*cur).partial_prefix((*(cur - 1)).raw()); 104 | } 105 | -------------------------------------------------------------------------------- /cmake/FindSanitizers.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | # If any of the used compiler is a GNU compiler, add a second option to static 26 | # link against the sanitizers. 27 | option(SANITIZE_LINK_STATIC "Try to link static against sanitizers." Off) 28 | 29 | 30 | 31 | 32 | set(FIND_QUIETLY_FLAG "") 33 | if (DEFINED Sanitizers_FIND_QUIETLY) 34 | set(FIND_QUIETLY_FLAG "QUIET") 35 | endif () 36 | 37 | find_package(ASan ${FIND_QUIETLY_FLAG}) 38 | find_package(TSan ${FIND_QUIETLY_FLAG}) 39 | find_package(MSan ${FIND_QUIETLY_FLAG}) 40 | find_package(UBSan ${FIND_QUIETLY_FLAG}) 41 | 42 | 43 | 44 | 45 | function(sanitizer_add_blacklist_file FILE) 46 | if(NOT IS_ABSOLUTE ${FILE}) 47 | set(FILE "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}") 48 | endif() 49 | get_filename_component(FILE "${FILE}" REALPATH) 50 | 51 | sanitizer_check_compiler_flags("-fsanitize-blacklist=${FILE}" 52 | "SanitizerBlacklist" "SanBlist") 53 | endfunction() 54 | 55 | function(add_sanitizers ...) 56 | # If no sanitizer is enabled, return immediately. 57 | if (NOT (SANITIZE_ADDRESS OR SANITIZE_MEMORY OR SANITIZE_THREAD OR 58 | SANITIZE_UNDEFINED)) 59 | return() 60 | endif () 61 | 62 | foreach (TARGET ${ARGV}) 63 | # Check if this target will be compiled by exactly one compiler. Other- 64 | # wise sanitizers can't be used and a warning should be printed once. 65 | sanitizer_target_compilers(${TARGET} TARGET_COMPILER) 66 | list(LENGTH TARGET_COMPILER NUM_COMPILERS) 67 | if (NUM_COMPILERS GREATER 1) 68 | message(WARNING "Can't use any sanitizers for target ${TARGET}, " 69 | "because it will be compiled by incompatible compilers. " 70 | "Target will be compiled without sanitizers.") 71 | return() 72 | 73 | # If the target is compiled by no known compiler, ignore it. 74 | elseif (NUM_COMPILERS EQUAL 0) 75 | message(WARNING "Can't use any sanitizers for target ${TARGET}, " 76 | "because it uses an unknown compiler. Target will be " 77 | "compiled without sanitizers.") 78 | return() 79 | endif () 80 | 81 | # Add sanitizers for target. 82 | add_sanitize_address(${TARGET}) 83 | add_sanitize_thread(${TARGET}) 84 | add_sanitize_memory(${TARGET}) 85 | add_sanitize_undefined(${TARGET}) 86 | endforeach () 87 | endfunction(add_sanitizers) 88 | -------------------------------------------------------------------------------- /ext/mstch/include/mstch/mstch.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | namespace mstch { 12 | 13 | struct config { 14 | static std::function escape; 15 | }; 16 | 17 | namespace internal { 18 | 19 | template 20 | class object_t { 21 | public: 22 | const N& at(const std::string& name) const { 23 | cache[name] = (methods.at(name))(); 24 | return cache[name]; 25 | } 26 | 27 | bool has(const std::string name) const { 28 | return methods.count(name) != 0; 29 | } 30 | 31 | protected: 32 | template 33 | void register_methods(S* s, std::map methods) { 34 | for(auto& item: methods) 35 | this->methods.insert({item.first, std::bind(item.second, s)}); 36 | } 37 | 38 | private: 39 | std::map> methods; 40 | mutable std::map cache; 41 | }; 42 | 43 | template 44 | class is_fun { 45 | private: 46 | using not_fun = char; 47 | using fun_without_args = char[2]; 48 | using fun_with_args = char[3]; 49 | template struct really_has; 50 | template static fun_without_args& test( 51 | really_has*); 52 | template static fun_with_args& test( 53 | really_has*); 55 | template static not_fun& test(...); 56 | 57 | public: 58 | static bool const no_args = sizeof(test(0)) == sizeof(fun_without_args); 59 | static bool const has_args = sizeof(test(0)) == sizeof(fun_with_args); 60 | }; 61 | 62 | template 63 | using node_renderer = std::function; 64 | 65 | template 66 | class lambda_t { 67 | public: 68 | template 69 | lambda_t(F f, typename std::enable_if::no_args>::type* = 0): 70 | fun([f](node_renderer renderer, const std::string&) { 71 | return renderer(f()); 72 | }) 73 | { 74 | } 75 | 76 | template 77 | lambda_t(F f, typename std::enable_if::has_args>::type* = 0): 78 | fun([f](node_renderer renderer, const std::string& text) { 79 | return renderer(f(text)); 80 | }) 81 | { 82 | } 83 | 84 | std::string operator()(node_renderer renderer, 85 | const std::string& text = "") const 86 | { 87 | return fun(renderer, text); 88 | } 89 | 90 | private: 91 | std::function renderer, const std::string&)> fun; 92 | }; 93 | 94 | template 95 | struct map : public std::map 96 | { 97 | map() {} 98 | map(const map& rhs) : std::map(rhs) {} 99 | map(const std::initializer_list::value_type>& args) : std::map(args) {} 100 | map& operator=(const map& rhs) 101 | { 102 | std::map::clear(); 103 | for (auto& i : rhs) 104 | std::map::insert(i); 105 | return *this; 106 | } 107 | }; 108 | 109 | } 110 | 111 | using node = boost::make_recursive_variant< 112 | std::nullptr_t, std::string, int, double, bool, uint64_t, int64_t, uint32_t, 113 | internal::lambda_t, 114 | std::shared_ptr>, 115 | internal::map, 116 | std::vector>::type; 117 | using object = internal::object_t; 118 | using lambda = internal::lambda_t; 119 | using map = internal::map; 120 | using array = std::vector; 121 | 122 | std::string render( 123 | const std::string& tmplt, 124 | const node& root, 125 | const std::map& partials = 126 | std::map()); 127 | 128 | } 129 | -------------------------------------------------------------------------------- /ext/crow/crow/http_response.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "crow/json.h" 6 | #include "crow/http_request.h" 7 | #include "crow/ci_map.h" 8 | 9 | namespace crow 10 | { 11 | template 12 | class Connection; 13 | struct response 14 | { 15 | template 16 | friend class crow::Connection; 17 | 18 | int code{200}; 19 | std::string body; 20 | json::wvalue json_value; 21 | 22 | // `headers' stores HTTP headers. 23 | ci_map headers; 24 | 25 | void set_header(std::string key, std::string value) 26 | { 27 | headers.erase(key); 28 | headers.emplace(std::move(key), std::move(value)); 29 | } 30 | void add_header(std::string key, std::string value) 31 | { 32 | headers.emplace(std::move(key), std::move(value)); 33 | } 34 | 35 | const std::string& get_header_value(const std::string& key) 36 | { 37 | return crow::get_header_value(headers, key); 38 | } 39 | 40 | 41 | response() {} 42 | explicit response(int code) : code(code) {} 43 | response(std::string body) : body(std::move(body)) {} 44 | response(json::wvalue&& json_value) : json_value(std::move(json_value)) 45 | { 46 | json_mode(); 47 | } 48 | response(int code, std::string body) : code(code), body(std::move(body)) {} 49 | response(const json::wvalue& json_value) : body(json::dump(json_value)) 50 | { 51 | json_mode(); 52 | } 53 | response(int code, const json::wvalue& json_value) : code(code), body(json::dump(json_value)) 54 | { 55 | json_mode(); 56 | } 57 | 58 | response(response&& r) 59 | { 60 | *this = std::move(r); 61 | } 62 | 63 | response& operator = (const response& r) = delete; 64 | 65 | response& operator = (response&& r) noexcept 66 | { 67 | body = std::move(r.body); 68 | json_value = std::move(r.json_value); 69 | code = r.code; 70 | headers = std::move(r.headers); 71 | completed_ = r.completed_; 72 | return *this; 73 | } 74 | 75 | bool is_completed() const noexcept 76 | { 77 | return completed_; 78 | } 79 | 80 | void clear() 81 | { 82 | body.clear(); 83 | json_value.clear(); 84 | code = 200; 85 | headers.clear(); 86 | completed_ = false; 87 | } 88 | 89 | void redirect(const std::string& location) 90 | { 91 | code = 301; 92 | set_header("Location", location); 93 | } 94 | 95 | void write(const std::string& body_part) 96 | { 97 | body += body_part; 98 | } 99 | 100 | void end() 101 | { 102 | if (!completed_) 103 | { 104 | completed_ = true; 105 | 106 | if (complete_request_handler_) 107 | { 108 | complete_request_handler_(); 109 | } 110 | } 111 | } 112 | 113 | void end(const std::string& body_part) 114 | { 115 | body += body_part; 116 | end(); 117 | } 118 | 119 | bool is_alive() 120 | { 121 | return is_alive_helper_ && is_alive_helper_(); 122 | } 123 | 124 | private: 125 | bool completed_{}; 126 | std::function complete_request_handler_; 127 | std::function is_alive_helper_; 128 | 129 | //In case of a JSON object, set the Content-Type header 130 | void json_mode() 131 | { 132 | set_header("Content-Type", "application/json"); 133 | } 134 | }; 135 | } 136 | -------------------------------------------------------------------------------- /src/templates/js/crc32.js: -------------------------------------------------------------------------------- 1 | var crc32 = (function () { 2 | 'use strict'; 3 | var crc32 = {}; 4 | 5 | crc32.Utf8Encode = function (string) { 6 | return unescape(encodeURIComponent(string)); 7 | }; 8 | 9 | crc32.run = function (str) { 10 | var crc = new crc32.Type(); 11 | crc.processString(str); 12 | return crc.checksum(); 13 | }; 14 | 15 | crc32.table = [ 16 | 0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 17 | 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049, 18 | 498536548, 1789927666, 4089016648, 2227061214, 450548861, 1843258603, 4107580753, 2211677639, 19 | 325883990, 1684777152, 4251122042, 2321926636, 335633487, 1661365465, 4195302755, 2366115317, 20 | 997073096, 1281953886, 3579855332, 2724688242, 1006888145, 1258607687, 3524101629, 2768942443, 21 | 901097722, 1119000684, 3686517206, 2898065728, 853044451, 1172266101, 3705015759, 2882616665, 22 | 651767980, 1373503546, 3369554304, 3218104598, 565507253, 1454621731, 3485111705, 3099436303, 23 | 671266974, 1594198024, 3322730930, 2970347812, 795835527, 1483230225, 3244367275, 3060149565, 24 | 1994146192, 31158534, 2563907772, 4023717930, 1907459465, 112637215, 2680153253, 3904427059, 25 | 2013776290, 251722036, 2517215374, 3775830040, 2137656763, 141376813, 2439277719, 3865271297, 26 | 1802195444, 476864866, 2238001368, 4066508878, 1812370925, 453092731, 2181625025, 4111451223, 27 | 1706088902, 314042704, 2344532202, 4240017532, 1658658271, 366619977, 2362670323, 4224994405, 28 | 1303535960, 984961486, 2747007092, 3569037538, 1256170817, 1037604311, 2765210733, 3554079995, 29 | 1131014506, 879679996, 2909243462, 3663771856, 1141124467, 855842277, 2852801631, 3708648649, 30 | 1342533948, 654459306, 3188396048, 3373015174, 1466479909, 544179635, 3110523913, 3462522015, 31 | 1591671054, 702138776, 2966460450, 3352799412, 1504918807, 783551873, 3082640443, 3233442989, 32 | 3988292384, 2596254646, 62317068, 1957810842, 3939845945, 2647816111, 81470997, 1943803523, 33 | 3814918930, 2489596804, 225274430, 2053790376, 3826175755, 2466906013, 167816743, 2097651377, 34 | 4027552580, 2265490386, 503444072, 1762050814, 4150417245, 2154129355, 426522225, 1852507879, 35 | 4275313526, 2312317920, 282753626, 1742555852, 4189708143, 2394877945, 397917763, 1622183637, 36 | 3604390888, 2714866558, 953729732, 1340076626, 3518719985, 2797360999, 1068828381, 1219638859, 37 | 3624741850, 2936675148, 906185462, 1090812512, 3747672003, 2825379669, 829329135, 1181335161, 38 | 3412177804, 3160834842, 628085408, 1382605366, 3423369109, 3138078467, 570562233, 1426400815, 39 | 3317316542, 2998733608, 733239954, 1555261956, 3268935591, 3050360625, 752459403, 1541320221, 40 | 2607071920, 3965973030, 1969922972, 40735498, 2617837225, 3943577151, 1913087877, 83908371, 41 | 2512341634, 3803740692, 2075208622, 213261112, 2463272603, 3855990285, 2094854071, 198958881, 42 | 2262029012, 4057260610, 1759359992, 534414190, 2176718541, 4139329115, 1873836001, 414664567, 43 | 2282248934, 4279200368, 1711684554, 285281116, 2405801727, 4167216745, 1634467795, 376229701, 44 | 2685067896, 3608007406, 1308918612, 956543938, 2808555105, 3495958263, 1231636301, 1047427035, 45 | 2932959818, 3654703836, 1088359270, 936918000, 2847714899, 3736837829, 1202900863, 817233897, 46 | 3183342108, 3401237130, 1404277552, 615818150, 3134207493, 3453421203, 1423857449, 601450431, 47 | 3009837614, 3294710456, 1567103746, 711928724, 3020668471, 3272380065, 1510334235, 755167117 48 | ]; 49 | crc32.Type = function () { 50 | this.rem_ = 0xFFFFFFFF; 51 | this.checksum = function () { 52 | return ((this.rem_ ^ 0xFFFFFFFF) >>> 0); 53 | }; 54 | this.processString = function (str) { 55 | str = crc32.Utf8Encode(str); 56 | for (var i = 0; i < str.length; i++) { 57 | var byte_index = ((str.charCodeAt(i) ^ this.rem_) >>> 0) & 0xFF; 58 | this.rem_ = ((this.rem_ >>> 8) ^ crc32.table[byte_index]) >>> 0; 59 | } 60 | }; 61 | return this; 62 | }; 63 | 64 | return crc32; 65 | })(); 66 | -------------------------------------------------------------------------------- /ext/crow/crow/common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "crow/utility.h" 8 | 9 | namespace crow 10 | { 11 | enum class HTTPMethod 12 | { 13 | #ifndef DELETE 14 | DELETE = 0, 15 | GET, 16 | HEAD, 17 | POST, 18 | PUT, 19 | CONNECT, 20 | OPTIONS, 21 | TRACE, 22 | PATCH = 24, 23 | #endif 24 | 25 | Delete = 0, 26 | Get, 27 | Head, 28 | Post, 29 | Put, 30 | Connect, 31 | Options, 32 | Trace, 33 | Patch = 24, 34 | }; 35 | 36 | inline std::string method_name(HTTPMethod method) 37 | { 38 | switch(method) 39 | { 40 | case HTTPMethod::Delete: 41 | return "DELETE"; 42 | case HTTPMethod::Get: 43 | return "GET"; 44 | case HTTPMethod::Head: 45 | return "HEAD"; 46 | case HTTPMethod::Post: 47 | return "POST"; 48 | case HTTPMethod::Put: 49 | return "PUT"; 50 | case HTTPMethod::Connect: 51 | return "CONNECT"; 52 | case HTTPMethod::Options: 53 | return "OPTIONS"; 54 | case HTTPMethod::Trace: 55 | return "TRACE"; 56 | case HTTPMethod::Patch: 57 | return "PATCH"; 58 | } 59 | return "invalid"; 60 | } 61 | 62 | enum class ParamType 63 | { 64 | INT, 65 | UINT, 66 | DOUBLE, 67 | STRING, 68 | PATH, 69 | 70 | MAX 71 | }; 72 | 73 | struct routing_params 74 | { 75 | std::vector int_params; 76 | std::vector uint_params; 77 | std::vector double_params; 78 | std::vector string_params; 79 | 80 | void debug_print() const 81 | { 82 | std::cerr << "routing_params" << std::endl; 83 | for(auto i:int_params) 84 | std::cerr< 98 | T get(unsigned) const; 99 | 100 | }; 101 | 102 | template<> 103 | inline int64_t routing_params::get(unsigned index) const 104 | { 105 | return int_params[index]; 106 | } 107 | 108 | template<> 109 | inline uint64_t routing_params::get(unsigned index) const 110 | { 111 | return uint_params[index]; 112 | } 113 | 114 | template<> 115 | inline double routing_params::get(unsigned index) const 116 | { 117 | return double_params[index]; 118 | } 119 | 120 | template<> 121 | inline std::string routing_params::get(unsigned index) const 122 | { 123 | return string_params[index]; 124 | } 125 | } 126 | 127 | #ifndef CROW_MSVC_WORKAROUND 128 | constexpr crow::HTTPMethod operator "" _method(const char* str, size_t /*len*/) 129 | { 130 | return 131 | crow::black_magic::is_equ_p(str, "GET", 3) ? crow::HTTPMethod::Get : 132 | crow::black_magic::is_equ_p(str, "DELETE", 6) ? crow::HTTPMethod::Delete : 133 | crow::black_magic::is_equ_p(str, "HEAD", 4) ? crow::HTTPMethod::Head : 134 | crow::black_magic::is_equ_p(str, "POST", 4) ? crow::HTTPMethod::Post : 135 | crow::black_magic::is_equ_p(str, "PUT", 3) ? crow::HTTPMethod::Put : 136 | crow::black_magic::is_equ_p(str, "OPTIONS", 7) ? crow::HTTPMethod::Options : 137 | crow::black_magic::is_equ_p(str, "CONNECT", 7) ? crow::HTTPMethod::Connect : 138 | crow::black_magic::is_equ_p(str, "TRACE", 5) ? crow::HTTPMethod::Trace : 139 | crow::black_magic::is_equ_p(str, "PATCH", 5) ? crow::HTTPMethod::Patch : 140 | throw std::runtime_error("invalid http method"); 141 | } 142 | #endif 143 | -------------------------------------------------------------------------------- /ext/crow/crow/logging.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "crow/settings.h" 11 | 12 | namespace crow 13 | { 14 | enum class LogLevel 15 | { 16 | #ifndef ERROR 17 | DEBUG = 0, 18 | INFO, 19 | WARNING, 20 | ERROR, 21 | CRITICAL, 22 | #endif 23 | 24 | Debug = 0, 25 | Info, 26 | Warning, 27 | Error, 28 | Critical, 29 | }; 30 | 31 | class ILogHandler { 32 | public: 33 | virtual void log(std::string message, LogLevel level) = 0; 34 | }; 35 | 36 | class CerrLogHandler : public ILogHandler { 37 | public: 38 | void log(std::string message, LogLevel /*level*/) override { 39 | std::cerr << message; 40 | } 41 | }; 42 | 43 | class logger { 44 | 45 | private: 46 | // 47 | static std::string timestamp() 48 | { 49 | char date[32]; 50 | time_t t = time(0); 51 | 52 | tm my_tm; 53 | 54 | #ifdef _MSC_VER 55 | gmtime_s(&my_tm, &t); 56 | #else 57 | gmtime_r(&t, &my_tm); 58 | #endif 59 | 60 | size_t sz = strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", &my_tm); 61 | return std::string(date, date+sz); 62 | } 63 | 64 | public: 65 | 66 | 67 | logger(std::string prefix, LogLevel level) : level_(level) { 68 | #ifdef CROW_ENABLE_LOGGING 69 | stringstream_ << "(" << timestamp() << ") [" << prefix << "] "; 70 | #endif 71 | 72 | } 73 | ~logger() { 74 | #ifdef CROW_ENABLE_LOGGING 75 | if(level_ >= get_current_log_level()) { 76 | stringstream_ << std::endl; 77 | get_handler_ref()->log(stringstream_.str(), level_); 78 | } 79 | #endif 80 | } 81 | 82 | // 83 | template 84 | logger& operator<<(T const &value) { 85 | 86 | #ifdef CROW_ENABLE_LOGGING 87 | if(level_ >= get_current_log_level()) { 88 | stringstream_ << value; 89 | } 90 | #endif 91 | return *this; 92 | } 93 | 94 | // 95 | static void setLogLevel(LogLevel level) { 96 | get_log_level_ref() = level; 97 | } 98 | 99 | static void setHandler(ILogHandler* handler) { 100 | get_handler_ref() = handler; 101 | } 102 | 103 | static LogLevel get_current_log_level() { 104 | return get_log_level_ref(); 105 | } 106 | 107 | private: 108 | // 109 | static LogLevel& get_log_level_ref() 110 | { 111 | static LogLevel current_level = (LogLevel)CROW_LOG_LEVEL; 112 | return current_level; 113 | } 114 | static ILogHandler*& get_handler_ref() 115 | { 116 | static CerrLogHandler default_handler; 117 | static ILogHandler* current_handler = &default_handler; 118 | return current_handler; 119 | } 120 | 121 | // 122 | std::ostringstream stringstream_; 123 | LogLevel level_; 124 | }; 125 | } 126 | 127 | #define CROW_LOG_CRITICAL \ 128 | if (crow::logger::get_current_log_level() <= crow::LogLevel::Critical) \ 129 | crow::logger("CRITICAL", crow::LogLevel::Critical) 130 | #define CROW_LOG_ERROR \ 131 | if (crow::logger::get_current_log_level() <= crow::LogLevel::Error) \ 132 | crow::logger("ERROR ", crow::LogLevel::Error) 133 | #define CROW_LOG_WARNING \ 134 | if (crow::logger::get_current_log_level() <= crow::LogLevel::Warning) \ 135 | crow::logger("WARNING ", crow::LogLevel::Warning) 136 | #define CROW_LOG_INFO \ 137 | if (crow::logger::get_current_log_level() <= crow::LogLevel::Info) \ 138 | crow::logger("INFO ", crow::LogLevel::Info) 139 | #define CROW_LOG_DEBUG \ 140 | if (crow::logger::get_current_log_level() <= crow::LogLevel::Debug) \ 141 | crow::logger("DEBUG ", crow::LogLevel::Debug) 142 | 143 | -------------------------------------------------------------------------------- /ext/fmt/ostream.h: -------------------------------------------------------------------------------- 1 | /* 2 | Formatting library for C++ - std::ostream support 3 | 4 | Copyright (c) 2012 - 2016, Victor Zverovich 5 | All rights reserved. 6 | 7 | For the license information refer to format.h. 8 | */ 9 | 10 | #ifndef FMT_OSTREAM_H_ 11 | #define FMT_OSTREAM_H_ 12 | 13 | #include "format.h" 14 | #include 15 | 16 | namespace fmt { 17 | 18 | namespace internal { 19 | 20 | template 21 | class FormatBuf : public std::basic_streambuf { 22 | private: 23 | typedef typename std::basic_streambuf::int_type int_type; 24 | typedef typename std::basic_streambuf::traits_type traits_type; 25 | 26 | Buffer &buffer_; 27 | Char *start_; 28 | 29 | public: 30 | FormatBuf(Buffer &buffer) : buffer_(buffer), start_(&buffer[0]) { 31 | this->setp(start_, start_ + buffer_.capacity()); 32 | } 33 | 34 | FormatBuf(Buffer &buffer, Char *start) : buffer_(buffer) , start_(start) { 35 | this->setp(start_, start_ + buffer_.capacity()); 36 | } 37 | 38 | int_type overflow(int_type ch = traits_type::eof()) FMT_OVERRIDE { 39 | if (!traits_type::eq_int_type(ch, traits_type::eof())) { 40 | size_t buf_size = size(); 41 | buffer_.resize(buf_size); 42 | buffer_.reserve(buf_size * 2); 43 | 44 | start_ = &buffer_[0]; 45 | start_[buf_size] = traits_type::to_char_type(ch); 46 | this->setp(start_+ buf_size + 1, start_ + buf_size * 2); 47 | } 48 | return ch; 49 | } 50 | 51 | size_t size() const { 52 | return to_unsigned(this->pptr() - start_); 53 | } 54 | }; 55 | 56 | Yes &convert(std::ostream &); 57 | 58 | struct DummyStream : std::ostream { 59 | DummyStream(); // Suppress a bogus warning in MSVC. 60 | // Hide all operator<< overloads from std::ostream. 61 | void operator<<(Null<>); 62 | }; 63 | 64 | No &operator<<(std::ostream &, int); 65 | 66 | template 67 | struct ConvertToIntImpl { 68 | // Convert to int only if T doesn't have an overloaded operator<<. 69 | enum { 70 | value = sizeof(convert(get() << get())) == sizeof(No) 71 | }; 72 | }; 73 | 74 | // Write the content of w to os. 75 | void write(std::ostream &os, Writer &w); 76 | 77 | #if FMT_HAS_DECLTYPE_INCOMPLETE_RETURN_TYPES 78 | template 79 | class is_streamable { 80 | template 81 | static auto test(int) -> decltype(std::declval() << std::declval(), std::true_type()); 82 | 83 | template 84 | static auto test(...) -> std::false_type; 85 | 86 | public: 87 | static constexpr bool value = decltype(test(0))::value; 88 | }; 89 | #endif 90 | } // namespace internal 91 | 92 | // Formats a value. 93 | template 94 | void format_arg(BasicFormatter &f, 95 | const Char *&format_str, const T &value) { 96 | internal::MemoryBuffer buffer; 97 | 98 | internal::FormatBuf format_buf(buffer); 99 | std::basic_ostream output(&format_buf); 100 | output << value; 101 | 102 | BasicStringRef str(&buffer[0], format_buf.size()); 103 | typedef internal::MakeArg< BasicFormatter > MakeArg; 104 | format_str = f.format(format_str, MakeArg(str)); 105 | } 106 | 107 | /** 108 | \rst 109 | Prints formatted data to the stream *os*. 110 | 111 | **Example**:: 112 | 113 | print(cerr, "Don't {}!", "panic"); 114 | \endrst 115 | */ 116 | FMT_API void print(std::ostream &os, CStringRef format_str, ArgList args); 117 | FMT_VARIADIC(void, print, std::ostream &, CStringRef) 118 | 119 | #if __cplusplus >= 201103L 120 | template 121 | typename std::enable_if< 122 | !std::is_same< 123 | typename std::remove_cv::type>::type, 124 | char * 125 | >::value, 126 | BasicWriter& 127 | >::type 128 | operator<<(BasicWriter &writer, const T &value) { 129 | FMT_STATIC_ASSERT(internal::is_streamable::value, "T must be Streamable"); 130 | 131 | auto &buffer = writer.buffer(); 132 | Char *start = &buffer[0] + buffer.size(); 133 | 134 | internal::FormatBuf format_buf(buffer, start); 135 | std::basic_ostream output(&format_buf); 136 | output << value; 137 | 138 | buffer.resize(buffer.size() + format_buf.size()); 139 | return writer; 140 | } 141 | #endif 142 | } // namespace fmt 143 | 144 | #ifdef FMT_HEADER_ONLY 145 | # include "ostream.cc" 146 | #endif 147 | 148 | #endif // FMT_OSTREAM_H_ 149 | -------------------------------------------------------------------------------- /src/templates/mempool.html: -------------------------------------------------------------------------------- 1 | {{^mempool_full_page}} 2 |
3 | 7 |
8 |
9 |
10 | {{/mempool_full_page}} 11 | {{#mempool_full_page}} 12 |
13 |
14 | {{/mempool_full_page}} 15 | 16 |
17 |
18 | {{#mempool_full_page}} 19 | 20 | Transactions: {{mempool_size}} | Size: {{mempool_size_kB}} kB 21 | 22 | 23 | {{/mempool_full_page}} 24 | {{^mempool_full_page}} 25 | Transactions: {{mempool_size}} | Size: {{mempool_size_kB}} kB 26 | {{/mempool_full_page}} 27 |
28 |
29 | Mempool 30 |
31 |
32 | {{#mempool_full_page}} 33 |
34 | {{/mempool_full_page}} 35 | {{^mempool_full_page}} 36 |
37 | {{/mempool_full_page}} 38 | 78 |
79 |
80 |
-------------------------------------------------------------------------------- /ext/crow/crow/middleware.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "crow/http_request.h" 4 | #include "crow/http_response.h" 5 | 6 | namespace crow 7 | { 8 | // Any middleware requires following 3 members: 9 | 10 | // struct context; 11 | // storing data for the middleware; can be read from another middleware or handlers 12 | 13 | // before_handle 14 | // called before handling the request. 15 | // if res.end() is called, the operation is halted. 16 | // (still call after_handle of this middleware) 17 | // 2 signatures: 18 | // void before_handle(request& req, response& res, context& ctx) 19 | // if you only need to access this middlewares context. 20 | // template 21 | // void before_handle(request& req, response& res, context& ctx, AllContext& all_ctx) 22 | // you can access another middlewares' context by calling `all_ctx.template get()' 23 | // ctx == all_ctx.template get() 24 | 25 | // after_handle 26 | // called after handling the request. 27 | // void after_handle(request& req, response& res, context& ctx) 28 | // template 29 | // void after_handle(request& req, response& res, context& ctx, AllContext& all_ctx) 30 | 31 | struct CookieParser 32 | { 33 | struct context 34 | { 35 | std::unordered_map jar; 36 | std::unordered_map cookies_to_add; 37 | 38 | std::string get_cookie(const std::string& key) const 39 | { 40 | auto cookie = jar.find(key); 41 | if (cookie != jar.end()) 42 | return cookie->second; 43 | return {}; 44 | } 45 | 46 | void set_cookie(const std::string& key, const std::string& value) 47 | { 48 | cookies_to_add.emplace(key, value); 49 | } 50 | }; 51 | 52 | void before_handle(request& req, response& res, context& ctx) 53 | { 54 | int count = req.headers.count("Cookie"); 55 | if (!count) 56 | return; 57 | if (count > 1) 58 | { 59 | res.code = 400; 60 | res.end(); 61 | return; 62 | } 63 | std::string cookies = req.get_header_value("Cookie"); 64 | size_t pos = 0; 65 | while(pos < cookies.size()) 66 | { 67 | size_t pos_equal = cookies.find('=', pos); 68 | if (pos_equal == cookies.npos) 69 | break; 70 | std::string name = cookies.substr(pos, pos_equal-pos); 71 | boost::trim(name); 72 | pos = pos_equal+1; 73 | while(pos < cookies.size() && cookies[pos] == ' ') pos++; 74 | if (pos == cookies.size()) 75 | break; 76 | 77 | size_t pos_semicolon = cookies.find(';', pos); 78 | std::string value = cookies.substr(pos, pos_semicolon-pos); 79 | 80 | boost::trim(value); 81 | if (value[0] == '"' && value[value.size()-1] == '"') 82 | { 83 | value = value.substr(1, value.size()-2); 84 | } 85 | 86 | ctx.jar.emplace(std::move(name), std::move(value)); 87 | 88 | pos = pos_semicolon; 89 | if (pos == cookies.npos) 90 | break; 91 | pos++; 92 | while(pos < cookies.size() && cookies[pos] == ' ') pos++; 93 | } 94 | } 95 | 96 | void after_handle(request& /*req*/, response& res, context& ctx) 97 | { 98 | for(auto& cookie:ctx.cookies_to_add) 99 | { 100 | if (cookie.second.empty()) 101 | res.add_header("Set-Cookie", cookie.first + "=\"\""); 102 | else 103 | res.add_header("Set-Cookie", cookie.first + "=" + cookie.second); 104 | } 105 | } 106 | }; 107 | 108 | /* 109 | App app; 110 | A B C 111 | A::context 112 | int aa; 113 | 114 | ctx1 : public A::context 115 | ctx2 : public ctx1, public B::context 116 | ctx3 : public ctx2, public C::context 117 | 118 | C depends on A 119 | 120 | C::handle 121 | context.aaa 122 | 123 | App::context : private CookieParser::contetx, ... 124 | { 125 | jar 126 | 127 | } 128 | 129 | SimpleApp 130 | */ 131 | } 132 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | set(PROJECT_NAME 4 | etnblocks) 5 | 6 | 7 | project(${PROJECT_NAME}) 8 | 9 | set(CMAKE_CXX_STANDARD 11) 10 | 11 | if (WIN32) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj -O3") 13 | endif() 14 | 15 | 16 | if (NOT ELECTRONEUM_DIR) 17 | set(ELECTRONEUM_DIR ~/electroneum) 18 | endif() 19 | 20 | message(STATUS ELECTRONEUM_DIR ": ${ELECTRONEUM_DIR}") 21 | 22 | if (NOT ELECTRONEUM_SOURCE_DIR) 23 | set(ELECTRONEUM_SOURCE_DIR ${ELECTRONEUM_DIR} 24 | CACHE PATH "Path to the root directory for Electroneum") 25 | endif() 26 | 27 | if (NOT ELECTRONEUM_BUILD_DIR) 28 | # set location of ELECTRONEUM build tree 29 | set(ELECTRONEUM_BUILD_DIR ${ELECTRONEUM_SOURCE_DIR}/build/release/ 30 | CACHE PATH "Path to the build directory for Electroneum") 31 | endif() 32 | 33 | set(MY_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" 34 | CACHE PATH "The path to the cmake directory of the current project") 35 | 36 | list(APPEND CMAKE_MODULE_PATH "${MY_CMAKE_DIR}") 37 | 38 | set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${ELECTRONEUM_BUILD_DIR}" 39 | CACHE PATH "Add Electroneum directory for library searching") 40 | 41 | include(MyUtils) 42 | 43 | find_package(Electroneum) 44 | 45 | # find boost 46 | find_package(Boost COMPONENTS 47 | system 48 | filesystem 49 | thread 50 | date_time 51 | chrono 52 | regex 53 | serialization 54 | program_options 55 | date_time 56 | REQUIRED) 57 | 58 | #info https://github.com/arsenm/sanitizers-cmake 59 | find_package(Sanitizers) 60 | 61 | if(APPLE) 62 | include_directories(/usr/local/opt/openssl/include) 63 | link_directories(/usr/local/opt/openssl/lib) 64 | endif() 65 | 66 | 67 | if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32) 68 | add_library(unbound STATIC IMPORTED) 69 | set_property(TARGET unbound PROPERTY IMPORTED_LOCATION ${ELECTRONEUM_BUILD_DIR}/external/unbound/libunbound.a) 70 | endif() 71 | 72 | 73 | 74 | # include boost headers 75 | include_directories(${Boost_INCLUDE_DIRS}) 76 | 77 | # include ELECTRONEUM 78 | include_directories(${ELECTRONEUM_SOURCE_DIR}/build) 79 | 80 | include_directories("ext/mstch/include") 81 | include_directories("ext/mstch/include/src") 82 | include_directories("ext/crow") 83 | 84 | # add ext/ subfolder 85 | add_subdirectory(ext/) 86 | 87 | # add src/ subfolder 88 | add_subdirectory(src/) 89 | 90 | 91 | set(SOURCE_FILES 92 | main.cpp) 93 | 94 | #ADD_CUSTOM_TARGET(driver DEPENDS src/templates/index.html) 95 | 96 | add_executable(${PROJECT_NAME} 97 | ${SOURCE_FILES}) 98 | 99 | add_sanitizers(${PROJECT_NAME}) 100 | 101 | create_git_version() 102 | 103 | configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates ${CMAKE_CURRENT_BINARY_DIR}/templates) 104 | configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates/css ${CMAKE_CURRENT_BINARY_DIR}/templates/css) 105 | configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates/partials ${CMAKE_CURRENT_BINARY_DIR}/templates/partials) 106 | configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates/js ${CMAKE_CURRENT_BINARY_DIR}/templates/js) 107 | configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates/imgs ${CMAKE_CURRENT_BINARY_DIR}/templates/imgs) 108 | 109 | find_library(SECP256K1_LIBRARY secp256k1) 110 | 111 | set(LIBRARIES 112 | myxrm 113 | myext 114 | mstch 115 | wallet 116 | blockchain_db 117 | cryptonote_core 118 | cryptonote_protocol 119 | cryptonote_basic 120 | multisig 121 | daemonizer 122 | cncrypto 123 | blocks 124 | lmdb 125 | ringct 126 | ringct_basic 127 | device 128 | common 129 | mnemonics 130 | easylogging 131 | checkpoints 132 | version 133 | epee 134 | sodium 135 | ${Boost_LIBRARIES} 136 | pthread 137 | unbound 138 | curl 139 | crypto 140 | ssl 141 | ed25519-donna 142 | ${SECP256K1_LIBRARY} 143 | ) 144 | if(APPLE) 145 | set(LIBRARIES ${LIBRARIES} "-framework IOKit -framework Foundation") 146 | else() 147 | set(LIBRARIES ${LIBRARIES} atomic) 148 | endif() 149 | 150 | if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT WIN32) 151 | set(LIBRARIES ${LIBRARIES} unwind) 152 | endif() 153 | 154 | if (WIN32) 155 | set(LIBRARIES ${LIBRARIES} 156 | wsock32 157 | ntdll 158 | ws2_32 159 | Iphlpapi 160 | ) 161 | else() 162 | set(LIBRARIES ${LIBRARIES} dl) 163 | endif() 164 | 165 | find_package(HIDAPI) 166 | set(LIBRARIES ${LIBRARIES} ${HIDAPI_LIBRARIES}) 167 | 168 | target_link_libraries(${PROJECT_NAME} ${LIBRARIES}) 169 | -------------------------------------------------------------------------------- /src/templates/search_results.html: -------------------------------------------------------------------------------- 1 | 2 |

Search results for: {{search_text}}

3 | 4 | {{#no_results}} 5 |

Nothing in the blockchain has been found that matches the search term :-(

6 |
Note: there might be some delay when newest txs become searchable
7 | {{/no_results}} 8 | 9 | {{#to_many_results}} 10 |

More than 500 results found. Showing no more than this

11 | {{/to_many_results}} 12 | 13 |
14 | 15 | {{#has_key_images}} 16 | 17 |

The search term matches key image found in the following transaction

18 | 19 | 20 | {{>tx_table_head}} 21 | {{#key_images}} 22 | {{>tx_table_row}} 23 | {{/key_images}} 24 |
25 | 26 | {{/has_key_images}} 27 | 28 |
29 | 30 |
31 | 32 | {{#has_tx_public_keys}} 33 | 34 |

The search term matches tx public key of the following transaction

35 | 36 | 37 | {{>tx_table_head}} 38 | {{#tx_public_keys}} 39 | {{>tx_table_row}} 40 | {{/tx_public_keys}} 41 |
42 | 43 | {{/has_tx_public_keys}} 44 | 45 |
46 | 47 |
48 | 49 | {{#has_payments_id}} 50 | 51 |

The search term matches payment id found in the following transaction(s)

52 | 53 | 54 | {{>tx_table_head}} 55 | {{#payments_id}} 56 | {{>tx_table_row}} 57 | {{/payments_id}} 58 |
59 | 60 | {{/has_payments_id}} 61 | 62 |
63 | 64 | {{#has_encrypted_payments_id}} 65 | 66 |

The search term matches encrypted payment id found in the following transaction(s)

67 | 68 | 69 | {{>tx_table_head}} 70 | {{#encrypted_payments_id}} 71 | {{>tx_table_row}} 72 | {{/encrypted_payments_id}} 73 |
74 | 75 | {{/has_encrypted_payments_id}} 76 | 77 |
78 | 79 |
80 | 81 | {{#has_output_public_keys}} 82 | 83 |

The search term matches output public key found in the following transaction(s)

84 | 85 | 86 | {{>tx_table_head}} 87 | {{#output_public_keys}} 88 | {{>tx_table_row}} 89 | {{/output_public_keys}} 90 |
91 | 92 | {{/has_output_public_keys}} 93 | 94 |
95 | 96 |
97 | 98 | {{#has_output_public_keys_based_on_global_idx}} 99 | 100 |

The search term matches global index of an output in the following transaction(s)

101 | 102 | 103 | {{>tx_table_head}} 104 | {{#output_public_keys_based_on_global_idx}} 105 | {{>tx_table_row}} 106 | {{/output_public_keys_based_on_global_idx}} 107 |
108 | 109 | {{/has_output_public_keys_based_on_global_idx}} 110 | 111 |
112 | 113 |
114 | 115 | {{#has_output_public_keys_based_on_amount_idx}} 116 | 117 |

The search term matches amount index and an amount of an output 118 | in the following transaction(s)

119 | 120 | 121 | {{>tx_table_head}} 122 | {{#output_public_keys_based_on_amount_idx}} 123 | {{>tx_table_row}} 124 | {{/output_public_keys_based_on_amount_idx}} 125 |
126 | 127 | {{/has_output_public_keys_based_on_amount_idx}} 128 | 129 |
130 | 131 | 132 |
133 | 134 | {{#has_tx_in_the_minute}} 135 | 136 |

Transactions performed in the given minute

137 | 138 | 139 | {{>tx_table_head}} 140 | {{#tx_in_the_minute}} 141 | {{>tx_table_row}} 142 | {{/tx_in_the_minute}} 143 |
144 | 145 | {{/has_tx_in_the_minute}} 146 | 147 |
148 | 149 |
150 | 151 | {{#has_tx_in_the_hour}} 152 | 153 |

Transactions performed in the given hour

154 | 155 | 156 | {{>tx_table_head}} 157 | {{#tx_in_the_hour}} 158 | {{>tx_table_row}} 159 | {{/tx_in_the_hour}} 160 |
161 | 162 | {{/has_tx_in_the_hour}} 163 | 164 |
165 | 166 |
167 | 168 | {{#has_tx_in_the_day}} 169 | 170 |

Transactions performed in the given day

171 | 172 | 173 | {{>tx_table_head}} 174 | {{#tx_in_the_day}} 175 | {{>tx_table_row}} 176 | {{/tx_in_the_day}} 177 |
178 | 179 | {{/has_tx_in_the_day}} 180 | 181 |
182 | -------------------------------------------------------------------------------- /src/MempoolStatus.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mwo on 28/05/17. 3 | // 4 | 5 | #ifndef ETNBLOCKS_MEMPOOLSTATUS_H 6 | #define ETNBLOCKS_MEMPOOLSTATUS_H 7 | 8 | 9 | #include "MicroCore.h" 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace electroneumeg 20 | { 21 | 22 | struct MempoolStatus 23 | { 24 | 25 | using Guard = std::lock_guard; 26 | 27 | struct mempool_tx 28 | { 29 | crypto::hash tx_hash; 30 | transaction tx; 31 | 32 | uint64_t receive_time {0}; 33 | uint64_t sum_inputs {0}; 34 | uint64_t sum_outputs {0}; 35 | uint64_t no_inputs {0}; 36 | uint64_t no_outputs {0}; 37 | uint64_t num_nonrct_inputs {0}; 38 | uint64_t mixin_no {0}; 39 | 40 | string fee_str; 41 | string fee_micro_str; 42 | string payed_for_kB_str; 43 | string payed_for_kB_micro_str; 44 | string etn_inputs_str; 45 | string etn_outputs_str; 46 | string timestamp_str; 47 | string txsize; 48 | 49 | /*char pID; // '-' - no payment ID, 50 | // 'l' - legacy, long 64 character payment id, 51 | // 'e' - encrypted, short, from integrated addresses*/ 52 | }; 53 | 54 | 55 | // to keep network_info in cache 56 | // and to show previous info in case current querry for 57 | // the current info timesout. 58 | struct network_info 59 | { 60 | uint64_t status {0}; 61 | uint64_t height {0}; 62 | uint64_t target_height {0}; 63 | uint64_t difficulty {0}; 64 | uint64_t difficulty_top64 {0}; 65 | uint64_t target {0}; 66 | uint64_t tx_count {0}; 67 | uint64_t tx_pool_size {0}; 68 | uint64_t alt_blocks_count {0}; 69 | uint64_t outgoing_connections_count {0}; 70 | uint64_t incoming_connections_count {0}; 71 | uint64_t white_peerlist_size {0}; 72 | uint64_t grey_peerlist_size {0}; 73 | cryptonote::network_type nettype {cryptonote::network_type::MAINNET}; 74 | crypto::hash top_block_hash; 75 | uint64_t cumulative_difficulty {0}; 76 | uint64_t cumulative_difficulty_top64 {0}; 77 | uint64_t block_size_limit {0}; 78 | uint64_t block_size_median {0}; 79 | uint64_t block_weight_limit {0}; 80 | char block_size_limit_str[10]; // needs to be trivially copyable 81 | char block_size_median_str[10]; // std::string is not trivially copyable 82 | uint64_t start_time {0}; 83 | uint64_t current_hf_version {0}; 84 | 85 | uint64_t hash_rate {0}; 86 | uint64_t hash_rate_top64 {0}; 87 | uint64_t fee_per_kb {0}; 88 | uint64_t info_timestamp {0}; 89 | 90 | bool current {false}; 91 | 92 | static uint64_t 93 | get_status_uint(const string& status) 94 | { 95 | if (status == CORE_RPC_STATUS_OK) 96 | return 1; 97 | 98 | if (status == CORE_RPC_STATUS_BUSY) 99 | return 2; 100 | 101 | // default 102 | return 0; 103 | } 104 | 105 | static string 106 | get_status_string(const uint64_t& status) 107 | { 108 | if (status == 1) 109 | return CORE_RPC_STATUS_OK; 110 | 111 | if (status == 2) 112 | return CORE_RPC_STATUS_BUSY; 113 | 114 | // default 115 | return 0; 116 | } 117 | }; 118 | 119 | static boost::thread m_thread; 120 | 121 | static mutex mempool_mutx; 122 | 123 | static atomic is_running; 124 | 125 | static uint64_t mempool_refresh_time; 126 | 127 | static atomic mempool_no; // no of txs 128 | static atomic mempool_size; // size in bytes. 129 | 130 | static bf::path blockchain_path; 131 | static string deamon_url; 132 | static cryptonote::network_type nettype; 133 | 134 | // make object for accessing the blockchain here 135 | static MicroCore* mcore; 136 | static Blockchain* core_storage; 137 | 138 | // vector of mempool transactions that all threads 139 | // can refer to 140 | // 141 | static vector mempool_txs; 142 | 143 | static atomic current_network_info; 144 | 145 | static void 146 | set_blockchain_variables(MicroCore* _mcore, 147 | Blockchain* _core_storage); 148 | 149 | static void 150 | start_mempool_status_thread(); 151 | 152 | static bool 153 | read_mempool(); 154 | 155 | static bool 156 | read_network_info(); 157 | 158 | static vector 159 | get_mempool_txs(); 160 | 161 | // get first no_of_tx from the vector 162 | static vector 163 | get_mempool_txs(uint64_t no_of_tx); 164 | 165 | static bool 166 | is_thread_running(); 167 | }; 168 | 169 | } 170 | #endif //ETNBLOCKS_MEMPOOLSTATUS_H 171 | -------------------------------------------------------------------------------- /src/templates/checkrawtx.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 |

Transaction checking

6 |
7 | 8 |
9 | 10 | {{#has_error}} 11 |

Checking tx failed

12 |

{{error_msg}}

13 | {{/has_error}} 14 | {{^has_error}} 15 |

Data file prefix: {{data_prefix}}

16 | {{/has_error}} 17 | 18 | {{#unsigned_tx_given}} 19 |

Details of unsigned raw tx data given

20 | 21 | {{#txs}} 22 |
23 |

Basic information

24 |
25 | {{#dest_infos}} 26 | Send {{dest_amount}} to {{dest_address}}
27 | {{/dest_infos}} 28 | 29 | {{#has_payment_id}} 30 | Payment id: {{payment_id}}
31 | {{/has_payment_id}} 32 | 33 | {{#has_payment_id8}} 34 | Payment id (encrypted): {{payment_id8}}
35 | {{/has_payment_id8}} 36 |
37 | 38 |

39 | Inputs' ring size time scale (from {{min_mix_time}} till {{max_mix_time}}; 40 | resolution: {{timescales_scale}} days{{#have_raw_tx}}; R - real ring member {{/have_raw_tx}}) 41 |

42 |
43 |
    44 | {{#timescales}} 45 |
  • |{{timescale}}|
  • 46 | {{/timescales}} 47 |
48 |
49 | 50 | 51 |

Outputs selected for this tx (total: {{sum_outputs_amounts}})

52 | {{#dest_sources}} 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | {{#outputs}} 62 | 63 | 64 | 65 | {{#is_real}} 66 | 67 | {{/is_real}} 68 | {{^is_real}} 69 | 70 | {{/is_real}} 71 | 72 | 73 | 74 | 75 | {{/outputs}} 76 |
Output IndexStealth addressIs this real outputAge {{age_format}}Amount
{{out_index}}{{out_pub_key}}{{is_real}}{{is_real}}{{output_age}}{{output_amount}}
77 | {{/dest_sources}} 78 |

Change to be returned to the sender: {{change_amount}}

79 |
80 | {{/txs}} 81 | {{/unsigned_tx_given}} 82 | 83 | {{^unsigned_tx_given}} 84 |

Details of signed raw tx data given

85 | {{#txs}} 86 |
87 | {{#dest_infos}} 88 | {{^is_this_change}} 89 | Send {{dest_amount}} to {{dest_address}}
90 | {{/is_this_change}} 91 | {{#is_this_change}} 92 | Total change {{dest_amount}} back to {{dest_address}}
93 | {{/is_this_change}} 94 | {{/dest_infos}} 95 |
96 | {{>tx_details}} 97 | {{#tx_json}} 98 |
99 |

JSON representation of tx

100 |
101 | 102 | {{tx_json}} 103 | 104 |
105 | {{/tx_json}} 106 | {{/txs}} 107 | 108 | {{/unsigned_tx_given}} 109 | 110 | 111 |
112 | 113 |
114 |
115 | -------------------------------------------------------------------------------- /src/rpccalls.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mwo on 13/04/16. 3 | // 4 | 5 | 6 | #ifndef CROWETN_RPCCALLS_H 7 | #define CROWETN_RPCCALLS_H 8 | 9 | #include "electroneum_headers.h" 10 | 11 | #include 12 | #include 13 | 14 | 15 | 16 | 17 | namespace 18 | { 19 | 20 | // can be used to check if given class/struct exist 21 | // from: https://stackoverflow.com/a/10722840/248823 22 | template 23 | struct has_destructor 24 | { 25 | // has destructor 26 | template 27 | static std::true_type test(decltype(std::declval().~A()) *) 28 | { 29 | return std::true_type(); 30 | } 31 | 32 | // no constructor 33 | template 34 | static std::false_type test(...) 35 | { 36 | return std::false_type(); 37 | } 38 | 39 | /* This will be either `std::true_type` or `std::false_type` */ 40 | typedef decltype(test(0)) type; 41 | 42 | static const bool value = type::value; 43 | }; 44 | 45 | } 46 | 47 | 48 | namespace cryptonote 49 | { 50 | // declare struct in electroneum's cryptonote namespace. 51 | // electroneum should provide definition for this, 52 | // but we need to have it declared as we are going to 53 | // check if its definition exist or not. depending on this 54 | // we decide what gets to be defined as 55 | // get_alt_blocks(vector& alt_blocks_hashes); 56 | struct COMMAND_RPC_GET_ALT_BLOCKS_HASHES; 57 | } 58 | 59 | namespace electroneumeg 60 | { 61 | 62 | using namespace cryptonote; 63 | using namespace crypto; 64 | using namespace std; 65 | 66 | 67 | 68 | class rpccalls 69 | { 70 | string deamon_url ; 71 | uint64_t timeout_time; 72 | 73 | std::chrono::milliseconds timeout_time_ms; 74 | 75 | epee::net_utils::http::url_content url; 76 | 77 | epee::net_utils::http::http_simple_client m_http_client; 78 | std::mutex m_daemon_rpc_mutex; 79 | 80 | string port; 81 | 82 | public: 83 | 84 | rpccalls(string _deamon_url = "http:://127.0.0.1:26968", 85 | uint64_t _timeout = 200000); 86 | 87 | bool 88 | connect_to_electroneum_deamon(); 89 | 90 | uint64_t 91 | get_current_height(); 92 | 93 | bool 94 | get_mempool(vector& mempool_txs); 95 | 96 | bool 97 | commit_tx(tools::wallet2::pending_tx& ptx, string& error_msg); 98 | 99 | bool 100 | get_network_info(COMMAND_RPC_GET_INFO::response& info); 101 | 102 | bool 103 | get_hardfork_info( COMMAND_RPC_HARD_FORK_INFO::response& res); 104 | 105 | bool 106 | get_dynamic_per_kb_fee_estimate( 107 | uint64_t grace_blocks, 108 | uint64_t& fee, 109 | string& error_msg); 110 | 111 | 112 | /** 113 | * This must be in the header for now, as it will be tempalte function 114 | * 115 | * @param alt_blocks_hashes 116 | * @return bool 117 | */ 118 | template 119 | typename enable_if::value, bool>::type 120 | get_alt_blocks(vector& alt_blocks_hashes) 121 | { 122 | // definition of COMMAND_RPC_GET_ALT_BLOCKS_HASHES exist 123 | // so perform rpc call to get this information 124 | 125 | bool r {false}; 126 | 127 | typename T::request req; 128 | typename T::response resp; 129 | 130 | { 131 | std::lock_guard guard(m_daemon_rpc_mutex); 132 | 133 | if (!connect_to_electroneum_deamon()) 134 | { 135 | cerr << "get_alt_blocks: not connected to deamon" << endl; 136 | return false; 137 | } 138 | 139 | r = epee::net_utils::invoke_http_json("/get_alt_blocks_hashes", 140 | req, resp, 141 | m_http_client); 142 | } 143 | 144 | string err; 145 | 146 | if (r) 147 | { 148 | if (resp.status == CORE_RPC_STATUS_BUSY) 149 | { 150 | err = "daemon is busy. Please try again later."; 151 | } 152 | else if (resp.status != CORE_RPC_STATUS_OK) 153 | { 154 | err = "daemon rpc failed. Please try again later."; 155 | } 156 | 157 | if (!err.empty()) 158 | { 159 | cerr << "Error connecting to Electroneum deamon due to " 160 | << err << endl; 161 | return false; 162 | } 163 | } 164 | else 165 | { 166 | cerr << "Error connecting to Electroneum deamon at " 167 | << deamon_url << endl; 168 | return false; 169 | } 170 | 171 | alt_blocks_hashes = resp.blks_hashes; 172 | 173 | return true; 174 | } 175 | 176 | template 177 | typename enable_if::value, bool>::type 178 | get_alt_blocks(vector& alt_blocks_hashes) 179 | { 180 | cerr << "COMMAND_RPC_GET_ALT_BLOCKS_HASHES does not exist!" << endl; 181 | // definition of COMMAND_RPC_GET_ALT_BLOCKS_HASHES does NOT exist 182 | // so dont do anything 183 | return false; 184 | } 185 | 186 | bool 187 | get_block(string const& blk_hash, block& blk, string& error_msg); 188 | 189 | }; 190 | 191 | 192 | } 193 | 194 | 195 | 196 | #endif //CROWETN_RPCCALLS_H 197 | -------------------------------------------------------------------------------- /ext/crow/crow/parser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "crow/http_parser_merged.h" 9 | #include "crow/http_request.h" 10 | 11 | namespace crow 12 | { 13 | template 14 | struct HTTPParser : public http_parser 15 | { 16 | static int on_message_begin(http_parser* self_) 17 | { 18 | HTTPParser* self = static_cast(self_); 19 | self->clear(); 20 | return 0; 21 | } 22 | static int on_url(http_parser* self_, const char* at, size_t length) 23 | { 24 | HTTPParser* self = static_cast(self_); 25 | self->raw_url.insert(self->raw_url.end(), at, at+length); 26 | return 0; 27 | } 28 | static int on_header_field(http_parser* self_, const char* at, size_t length) 29 | { 30 | HTTPParser* self = static_cast(self_); 31 | switch (self->header_building_state) 32 | { 33 | case 0: 34 | if (!self->header_value.empty()) 35 | { 36 | self->headers.emplace(std::move(self->header_field), std::move(self->header_value)); 37 | } 38 | self->header_field.assign(at, at+length); 39 | self->header_building_state = 1; 40 | break; 41 | case 1: 42 | self->header_field.insert(self->header_field.end(), at, at+length); 43 | break; 44 | } 45 | return 0; 46 | } 47 | static int on_header_value(http_parser* self_, const char* at, size_t length) 48 | { 49 | HTTPParser* self = static_cast(self_); 50 | switch (self->header_building_state) 51 | { 52 | case 0: 53 | self->header_value.insert(self->header_value.end(), at, at+length); 54 | break; 55 | case 1: 56 | self->header_building_state = 0; 57 | self->header_value.assign(at, at+length); 58 | break; 59 | } 60 | return 0; 61 | } 62 | static int on_headers_complete(http_parser* self_) 63 | { 64 | HTTPParser* self = static_cast(self_); 65 | if (!self->header_field.empty()) 66 | { 67 | self->headers.emplace(std::move(self->header_field), std::move(self->header_value)); 68 | } 69 | self->process_header(); 70 | return 0; 71 | } 72 | static int on_body(http_parser* self_, const char* at, size_t length) 73 | { 74 | HTTPParser* self = static_cast(self_); 75 | self->body.insert(self->body.end(), at, at+length); 76 | return 0; 77 | } 78 | static int on_message_complete(http_parser* self_) 79 | { 80 | HTTPParser* self = static_cast(self_); 81 | 82 | // url params 83 | self->url = self->raw_url.substr(0, self->raw_url.find("?")); 84 | self->url_params = query_string(self->raw_url); 85 | 86 | self->process_message(); 87 | return 0; 88 | } 89 | HTTPParser(Handler* handler) : 90 | handler_(handler) 91 | { 92 | http_parser_init(this, HTTP_REQUEST); 93 | } 94 | 95 | // return false on error 96 | bool feed(const char* buffer, int length) 97 | { 98 | const static http_parser_settings settings_{ 99 | on_message_begin, 100 | on_url, 101 | nullptr, 102 | on_header_field, 103 | on_header_value, 104 | on_headers_complete, 105 | on_body, 106 | on_message_complete, 107 | }; 108 | 109 | int nparsed = http_parser_execute(this, &settings_, buffer, length); 110 | return nparsed == length; 111 | } 112 | 113 | bool done() 114 | { 115 | return feed(nullptr, 0); 116 | } 117 | 118 | void clear() 119 | { 120 | url.clear(); 121 | raw_url.clear(); 122 | header_building_state = 0; 123 | header_field.clear(); 124 | header_value.clear(); 125 | headers.clear(); 126 | url_params.clear(); 127 | body.clear(); 128 | } 129 | 130 | void process_header() 131 | { 132 | handler_->handle_header(); 133 | } 134 | 135 | void process_message() 136 | { 137 | handler_->handle(); 138 | } 139 | 140 | request to_request() const 141 | { 142 | return request{(HTTPMethod)method, std::move(raw_url), std::move(url), std::move(url_params), std::move(headers), std::move(body)}; 143 | } 144 | 145 | bool is_upgrade() const 146 | { 147 | return upgrade; 148 | } 149 | 150 | bool check_version(int major, int minor) const 151 | { 152 | return http_major == major && http_minor == minor; 153 | } 154 | 155 | std::string raw_url; 156 | std::string url; 157 | 158 | int header_building_state = 0; 159 | std::string header_field; 160 | std::string header_value; 161 | ci_map headers; 162 | query_string url_params; 163 | std::string body; 164 | 165 | Handler* handler_; 166 | }; 167 | } 168 | -------------------------------------------------------------------------------- /src/templates/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{#refresh}} 8 | 9 | {{/refresh}} 10 | Electroneum Blockchain Explorer 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |
23 | 24 |
25 | 27 | 28 |
29 |
30 |
31 | 152 |
153 |
-------------------------------------------------------------------------------- /src/CmdLineOptions.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mwo on 6/11/15. 3 | // 4 | 5 | #include "CmdLineOptions.h" 6 | 7 | 8 | namespace electroneumeg 9 | { 10 | /** 11 | * Take the acc and *avv[] from the main() and check and parse 12 | * all the options given 13 | */ 14 | CmdLineOptions::CmdLineOptions(int acc, const char *avv[]) { 15 | 16 | positional_options_description p; 17 | 18 | p.add("txhash", -1); 19 | 20 | options_description desc( 21 | "etnblocks, Electroneum Blockchain Explorer"); 22 | 23 | desc.add_options() 24 | ("help,h", value()->default_value(false)->implicit_value(true), 25 | "produce help message") 26 | ("testnet,t", value()->default_value(false)->implicit_value(true), 27 | "use testnet blockchain") 28 | ("stagenet,s", value()->default_value(false)->implicit_value(true), 29 | "use stagenet blockchain") 30 | ("enable-pusher", value()->default_value(false)->implicit_value(true), 31 | "enable signed transaction pusher") 32 | ("enable-mixin-details", value()->default_value(false)->implicit_value(true), 33 | "enable mixin details for key images, e.g., timescale, mixin of mixins, in tx context") 34 | ("enable-key-image-checker", value()->default_value(false)->implicit_value(true), 35 | "enable key images file checker") 36 | ("enable-output-key-checker", value()->default_value(false)->implicit_value(true), 37 | "enable outputs key file checker") 38 | ("enable-json-api", value()->default_value(false)->implicit_value(true), 39 | "enable JSON REST api") 40 | ("enable-tx-cache", value()->default_value(false)->implicit_value(true), 41 | "enable caching of transaction details") 42 | ("show-cache-times", value()->default_value(false)->implicit_value(true), 43 | "show times of getting data from cache vs no cache") 44 | ("enable-block-cache", value()->default_value(false)->implicit_value(true), 45 | "enable caching of block details") 46 | ("enable-js", value()->default_value(false)->implicit_value(true), 47 | "enable checking outputs and proving txs using JavaScript on client side") 48 | ("enable-as-hex", value()->default_value(false)->implicit_value(true), 49 | "enable links to provide hex represtations of a tx and a block") 50 | ("enable-autorefresh-option", value()->default_value(false)->implicit_value(true), 51 | "enable users to have the index page on autorefresh") 52 | ("enable-emission-monitor", value()->default_value(false)->implicit_value(true), 53 | "enable Electroneum total emission monitoring thread") 54 | ("port,p", value()->default_value("8081"), 55 | "default explorer port") 56 | ("bindaddr,x", value()->default_value("0.0.0.0"), 57 | "default bind address for the explorer") 58 | ("testnet-url", value()->default_value(""), 59 | "you can specify testnet url, if you run it on mainnet or stagenet. link will show on front page to testnet explorer") 60 | ("stagenet-url", value()->default_value(""), 61 | "you can specify stagenet url, if you run it on mainnet or testnet. link will show on front page to stagenet explorer") 62 | ("mainnet-url", value()->default_value(""), 63 | "you can specify mainnet url, if you run it on testnet or stagenet. link will show on front page to mainnet explorer") 64 | ("no-blocks-on-index", value()->default_value("10"), 65 | "number of last blocks to be shown on index page") 66 | ("mempool-info-timeout", value()->default_value("5000"), 67 | "maximum time, in milliseconds, to wait for mempool data for the front page") 68 | ("mempool-refresh-time", value()->default_value("5"), 69 | "time, in seconds, for each refresh of mempool state") 70 | ("concurrency,c", value()->default_value(0), 71 | "number of threads handling http queries. Default is 0 which means it is based you on the cpu") 72 | ("bc-path,b", value(), 73 | "path to lmdb folder of the blockchain, e.g., ~/.electroneum/lmdb") 74 | ("ssl-crt-file", value(), 75 | "path to crt file for ssl (https) functionality") 76 | ("ssl-key-file", value(), 77 | "path to key file for ssl (https) functionality") 78 | ("deamon-url,d", value()->default_value("http:://127.0.0.1:26968"), 79 | "Electroneum deamon url"); 80 | 81 | 82 | store(command_line_parser(acc, avv) 83 | .options(desc) 84 | .positional(p) 85 | .run(), vm); 86 | 87 | notify(vm); 88 | 89 | if (vm.count("help")) 90 | { 91 | if (vm["help"].as()) 92 | cout << desc << "\n"; 93 | } 94 | } 95 | 96 | /** 97 | * Return the value of the argument passed to the program 98 | * in wrapped around boost::optional 99 | */ 100 | template 101 | boost::optional 102 | CmdLineOptions::get_option(const string & opt_name) const 103 | { 104 | 105 | if (!vm.count(opt_name)) 106 | { 107 | return boost::none; 108 | } 109 | 110 | return vm[opt_name].as(); 111 | } 112 | 113 | 114 | // explicit instantiations of get_option template function 115 | template boost::optional 116 | CmdLineOptions::get_option(const string & opt_name) const; 117 | 118 | template boost::optional 119 | CmdLineOptions::get_option(const string & opt_name) const; 120 | 121 | template boost::optional 122 | CmdLineOptions::get_option(const string & opt_name) const; 123 | 124 | } 125 | -------------------------------------------------------------------------------- /ext/crow/crow/TinySHA1.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * TinySHA1 - a header only implementation of the SHA1 algorithm in C++. Based 4 | * on the implementation in boost::uuid::details. 5 | * 6 | * SHA1 Wikipedia Page: http://en.wikipedia.org/wiki/SHA-1 7 | * 8 | * Copyright (c) 2012-22 SAURAV MOHAPATRA 9 | * 10 | * Permission to use, copy, modify, and distribute this software for any 11 | * purpose with or without fee is hereby granted, provided that the above 12 | * copyright notice and this permission notice appear in all copies. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 15 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 16 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 17 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 19 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 20 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | */ 22 | #ifndef _TINY_SHA1_HPP_ 23 | #define _TINY_SHA1_HPP_ 24 | #include 25 | #include 26 | #include 27 | #include 28 | namespace sha1 29 | { 30 | class SHA1 31 | { 32 | public: 33 | typedef uint32_t digest32_t[5]; 34 | typedef uint8_t digest8_t[20]; 35 | inline static uint32_t LeftRotate(uint32_t value, size_t count) { 36 | return (value << count) ^ (value >> (32-count)); 37 | } 38 | SHA1(){ reset(); } 39 | virtual ~SHA1() {} 40 | SHA1(const SHA1& s) { *this = s; } 41 | const SHA1& operator = (const SHA1& s) { 42 | memcpy(m_digest, s.m_digest, 5 * sizeof(uint32_t)); 43 | memcpy(m_block, s.m_block, 64); 44 | m_blockByteIndex = s.m_blockByteIndex; 45 | m_byteCount = s.m_byteCount; 46 | return *this; 47 | } 48 | SHA1& reset() { 49 | m_digest[0] = 0x67452301; 50 | m_digest[1] = 0xEFCDAB89; 51 | m_digest[2] = 0x98BADCFE; 52 | m_digest[3] = 0x10325476; 53 | m_digest[4] = 0xC3D2E1F0; 54 | m_blockByteIndex = 0; 55 | m_byteCount = 0; 56 | return *this; 57 | } 58 | SHA1& processByte(uint8_t octet) { 59 | this->m_block[this->m_blockByteIndex++] = octet; 60 | ++this->m_byteCount; 61 | if(m_blockByteIndex == 64) { 62 | this->m_blockByteIndex = 0; 63 | processBlock(); 64 | } 65 | return *this; 66 | } 67 | SHA1& processBlock(const void* const start, const void* const end) { 68 | const uint8_t* begin = static_cast(start); 69 | const uint8_t* finish = static_cast(end); 70 | while(begin != finish) { 71 | processByte(*begin); 72 | begin++; 73 | } 74 | return *this; 75 | } 76 | SHA1& processBytes(const void* const data, size_t len) { 77 | const uint8_t* block = static_cast(data); 78 | processBlock(block, block + len); 79 | return *this; 80 | } 81 | const uint32_t* getDigest(digest32_t digest) { 82 | size_t bitCount = this->m_byteCount * 8; 83 | processByte(0x80); 84 | if (this->m_blockByteIndex > 56) { 85 | while (m_blockByteIndex != 0) { 86 | processByte(0); 87 | } 88 | while (m_blockByteIndex < 56) { 89 | processByte(0); 90 | } 91 | } else { 92 | while (m_blockByteIndex < 56) { 93 | processByte(0); 94 | } 95 | } 96 | processByte(0); 97 | processByte(0); 98 | processByte(0); 99 | processByte(0); 100 | processByte( static_cast((bitCount>>24) & 0xFF)); 101 | processByte( static_cast((bitCount>>16) & 0xFF)); 102 | processByte( static_cast((bitCount>>8 ) & 0xFF)); 103 | processByte( static_cast((bitCount) & 0xFF)); 104 | 105 | memcpy(digest, m_digest, 5 * sizeof(uint32_t)); 106 | return digest; 107 | } 108 | const uint8_t* getDigestBytes(digest8_t digest) { 109 | digest32_t d32; 110 | getDigest(d32); 111 | size_t di = 0; 112 | digest[di++] = ((d32[0] >> 24) & 0xFF); 113 | digest[di++] = ((d32[0] >> 16) & 0xFF); 114 | digest[di++] = ((d32[0] >> 8) & 0xFF); 115 | digest[di++] = ((d32[0]) & 0xFF); 116 | 117 | digest[di++] = ((d32[1] >> 24) & 0xFF); 118 | digest[di++] = ((d32[1] >> 16) & 0xFF); 119 | digest[di++] = ((d32[1] >> 8) & 0xFF); 120 | digest[di++] = ((d32[1]) & 0xFF); 121 | 122 | digest[di++] = ((d32[2] >> 24) & 0xFF); 123 | digest[di++] = ((d32[2] >> 16) & 0xFF); 124 | digest[di++] = ((d32[2] >> 8) & 0xFF); 125 | digest[di++] = ((d32[2]) & 0xFF); 126 | 127 | digest[di++] = ((d32[3] >> 24) & 0xFF); 128 | digest[di++] = ((d32[3] >> 16) & 0xFF); 129 | digest[di++] = ((d32[3] >> 8) & 0xFF); 130 | digest[di++] = ((d32[3]) & 0xFF); 131 | 132 | digest[di++] = ((d32[4] >> 24) & 0xFF); 133 | digest[di++] = ((d32[4] >> 16) & 0xFF); 134 | digest[di++] = ((d32[4] >> 8) & 0xFF); 135 | digest[di++] = ((d32[4]) & 0xFF); 136 | return digest; 137 | } 138 | 139 | protected: 140 | void processBlock() { 141 | uint32_t w[80]; 142 | for (size_t i = 0; i < 16; i++) { 143 | w[i] = (m_block[i*4 + 0] << 24); 144 | w[i] |= (m_block[i*4 + 1] << 16); 145 | w[i] |= (m_block[i*4 + 2] << 8); 146 | w[i] |= (m_block[i*4 + 3]); 147 | } 148 | for (size_t i = 16; i < 80; i++) { 149 | w[i] = LeftRotate((w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]), 1); 150 | } 151 | 152 | uint32_t a = m_digest[0]; 153 | uint32_t b = m_digest[1]; 154 | uint32_t c = m_digest[2]; 155 | uint32_t d = m_digest[3]; 156 | uint32_t e = m_digest[4]; 157 | 158 | for (std::size_t i=0; i<80; ++i) { 159 | uint32_t f = 0; 160 | uint32_t k = 0; 161 | 162 | if (i<20) { 163 | f = (b & c) | (~b & d); 164 | k = 0x5A827999; 165 | } else if (i<40) { 166 | f = b ^ c ^ d; 167 | k = 0x6ED9EBA1; 168 | } else if (i<60) { 169 | f = (b & c) | (b & d) | (c & d); 170 | k = 0x8F1BBCDC; 171 | } else { 172 | f = b ^ c ^ d; 173 | k = 0xCA62C1D6; 174 | } 175 | uint32_t temp = LeftRotate(a, 5) + f + e + k + w[i]; 176 | e = d; 177 | d = c; 178 | c = LeftRotate(b, 30); 179 | b = a; 180 | a = temp; 181 | } 182 | 183 | m_digest[0] += a; 184 | m_digest[1] += b; 185 | m_digest[2] += c; 186 | m_digest[3] += d; 187 | m_digest[4] += e; 188 | } 189 | private: 190 | digest32_t m_digest; 191 | uint8_t m_block[64]; 192 | size_t m_blockByteIndex; 193 | size_t m_byteCount; 194 | }; 195 | } 196 | #endif 197 | -------------------------------------------------------------------------------- /src/templates/my_outputs.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |

Tx hash: {{tx_hash}}

5 |
Tx public key: {{tx_pub_key}}
6 | 7 | 8 | {{#has_payment_id}} 9 |
Payment id: {{payment_id}}
10 | {{/has_payment_id}} 11 | 12 | {{#has_payment_id8}} 13 | {{^decrypted_payment_id8}} 14 |
Payment id (encrypted): {{payment_id8}}
15 | {{/decrypted_payment_id8}} 16 | {{#decrypted_payment_id8}} 17 |
Payment id (decrypted): {{decrypted_payment_id8}} 18 | (value incorrect if you are not the recipient of the tx)
19 | {{/decrypted_payment_id8}} 20 | {{/has_payment_id8}} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
Block: {{blk_height}}Timestamp [UCT]: {{blk_timestamp}}Age [y:d:h:m:s]: {{delta_time}}Fee: {{tx_fee}}Tx size: {{tx_size}} kB
33 | 34 | {{^tx_prove}} 35 |

Checking which outputs belong to the given address and viewkey

36 |
address: {{etn_address}}
37 |
viewkey: {{viewkey}}
38 | {{/tx_prove}} 39 | {{#tx_prove}} 40 |

Prove that you send this tx to the given address

41 |
address: {{etn_address}}
42 |
Tx private key: {{viewkey}}
43 | {{/tx_prove}} 44 | 45 |

Outputs ({{outputs_no}})

46 |
47 | 48 | 49 | 50 | 51 | 52 | 53 | {{#outputs}} 54 | 55 | 56 | 57 | {{#mine_output}} 58 | 63 | {{/mine_output}} 64 | {{^mine_output}} 65 | 66 | {{/mine_output}} 67 | 68 | {{/outputs}} 69 |
output public keyamountoutput match?
{{output_idx}}: {{out_pub_key}}{{amount}} 59 | 60 | {{mine_output}} 61 | 62 | {{mine_output}}
70 | 71 |

72 | Sum ETN from matched outputs (i.e., incoming ETN): 73 | {{#found_our_outputs}} 74 | {{sum_etn}} 75 | {{/found_our_outputs}} 76 | {{^found_our_outputs}} 77 | 0.000000000000 78 | {{/found_our_outputs}} 79 |

80 |

81 | link to this page 82 |

83 | 84 |
85 | 86 | {{#show_inputs}} 87 |
88 | 89 | 90 | 91 |
92 |

Inputs ({{inputs_no}})

93 |
94 | {{#inputs}} 95 |

Key image: {{key_image}}, amount {{key_image_amount}}

96 | {{#mixins}} 97 | {{#has_mixin_outputs}} 98 | {{#mixin_outputs}} 99 |
100 | 101 | 102 | 108 | 109 | {{#has_found_outputs}} 110 | 135 | {{/has_found_outputs}} 136 |
103 | Ring member {{mixin_pub_key}} might use your outputs 104 |
105 | from tx of hash: {{mix_tx_hash}} 106 |
(tx public key: {{mix_tx_pub_key}}) 107 |
111 |
112 | 113 | 114 | 115 | 116 | 117 | 118 | {{#found_outputs}} 119 | 120 | 121 | 122 | 130 | 131 | {{/found_outputs}} 132 |
output public keyamountoutput match?
{{my_public_key}}{{amount}} 123 | {{#mine_output}} 124 | {{mine_output}}{{#out_in_match}}*{{/out_in_match}} 125 | {{/mine_output}} 126 | {{^mine_output}} 127 | {{mine_output}} 128 | {{/mine_output}} 129 |
133 |
134 |
137 |
138 | {{/mixin_outputs}} 139 | {{/has_mixin_outputs}} 140 | {{/mixins}} 141 | {{/inputs}} 142 | 143 |
144 |

145 | Sum ETN from matched and marked by * ring member's outputs: {{sum_mixin_etn}} 146 |
147 | Possible spending is: 148 | {{possible_spending}} (tx fee included) 149 | 150 |
151 | Note: without private spendkey, 152 | it is impossible to know whether this is your real spending.
153 | So do not take this number seriously. 154 | It is probably totally wrong anyway.
155 |
156 | 157 | Number of possible our mixins is {{no_all_possible_mixins}} 158 | for {{all_possible_mixins_amount}} etn 159 | (amount as uint64). 160 | 161 |

162 |
163 | 164 | {{/show_inputs}} 165 | 166 | 167 |
168 |
169 | -------------------------------------------------------------------------------- /src/templates/js/base58.js: -------------------------------------------------------------------------------- 1 | var cnBase58 = (function () { 2 | var b58 = {}; 3 | 4 | var alphabet_str = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; 5 | var alphabet = []; 6 | for (var i = 0; i < alphabet_str.length; i++) { 7 | alphabet.push(alphabet_str.charCodeAt(i)); 8 | } 9 | var encoded_block_sizes = [0, 2, 3, 5, 6, 7, 9, 10, 11]; 10 | 11 | var alphabet_size = alphabet.length; 12 | var full_block_size = 8; 13 | var full_encoded_block_size = 11; 14 | 15 | var UINT64_MAX = new JSBigInt(2).pow(64); 16 | 17 | function hextobin(hex) { 18 | if (hex.length % 2 !== 0) throw "Hex string has invalid length!"; 19 | var res = new Uint8Array(hex.length / 2); 20 | for (var i = 0; i < hex.length / 2; ++i) { 21 | res[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); 22 | } 23 | return res; 24 | } 25 | 26 | function bintohex(bin) { 27 | var out = []; 28 | for (var i = 0; i < bin.length; ++i) { 29 | out.push(("0" + bin[i].toString(16)).slice(-2)); 30 | } 31 | return out.join(""); 32 | } 33 | 34 | function strtobin(str) { 35 | var res = new Uint8Array(str.length); 36 | for (var i = 0; i < str.length; i++) { 37 | res[i] = str.charCodeAt(i); 38 | } 39 | return res; 40 | } 41 | 42 | function bintostr(bin) { 43 | var out = []; 44 | for (var i = 0; i < bin.length; i++) { 45 | out.push(String.fromCharCode(bin[i])); 46 | } 47 | return out.join(""); 48 | } 49 | 50 | function uint8_be_to_64(data) { 51 | if (data.length < 1 || data.length > 8) { 52 | throw "Invalid input length"; 53 | } 54 | var res = JSBigInt.ZERO; 55 | var twopow8 = new JSBigInt(2).pow(8); 56 | var i = 0; 57 | switch (9 - data.length) { 58 | case 1: 59 | res = res.add(data[i++]); 60 | case 2: 61 | res = res.multiply(twopow8).add(data[i++]); 62 | case 3: 63 | res = res.multiply(twopow8).add(data[i++]); 64 | case 4: 65 | res = res.multiply(twopow8).add(data[i++]); 66 | case 5: 67 | res = res.multiply(twopow8).add(data[i++]); 68 | case 6: 69 | res = res.multiply(twopow8).add(data[i++]); 70 | case 7: 71 | res = res.multiply(twopow8).add(data[i++]); 72 | case 8: 73 | res = res.multiply(twopow8).add(data[i++]); 74 | break; 75 | default: 76 | throw "Impossible condition"; 77 | } 78 | return res; 79 | } 80 | 81 | function uint64_to_8be(num, size) { 82 | var res = new Uint8Array(size); 83 | if (size < 1 || size > 8) { 84 | throw "Invalid input length"; 85 | } 86 | var twopow8 = new JSBigInt(2).pow(8); 87 | for (var i = size - 1; i >= 0; i--) { 88 | res[i] = num.remainder(twopow8).toJSValue(); 89 | num = num.divide(twopow8); 90 | } 91 | return res; 92 | } 93 | 94 | b58.encode_block = function (data, buf, index) { 95 | if (data.length < 1 || data.length > full_encoded_block_size) { 96 | throw "Invalid block length: " + data.length; 97 | } 98 | var num = uint8_be_to_64(data); 99 | var i = encoded_block_sizes[data.length] - 1; 100 | // while num > 0 101 | while (num.compare(0) === 1) { 102 | var div = num.divRem(alphabet_size); 103 | // remainder = num % alphabet_size 104 | var remainder = div[1]; 105 | // num = num / alphabet_size 106 | num = div[0]; 107 | buf[index + i] = alphabet[remainder.toJSValue()]; 108 | i--; 109 | } 110 | return buf; 111 | }; 112 | 113 | b58.encode = function (hex) { 114 | var data = hextobin(hex); 115 | if (data.length === 0) { 116 | return ""; 117 | } 118 | var full_block_count = Math.floor(data.length / full_block_size); 119 | var last_block_size = data.length % full_block_size; 120 | var res_size = full_block_count * full_encoded_block_size + encoded_block_sizes[last_block_size]; 121 | 122 | var res = new Uint8Array(res_size); 123 | var i; 124 | for (i = 0; i < res_size; ++i) { 125 | res[i] = alphabet[0]; 126 | } 127 | for (i = 0; i < full_block_count; i++) { 128 | res = b58.encode_block(data.subarray(i * full_block_size, i * full_block_size + full_block_size), res, i * full_encoded_block_size); 129 | } 130 | if (last_block_size > 0) { 131 | res = b58.encode_block(data.subarray(full_block_count * full_block_size, full_block_count * full_block_size + last_block_size), res, full_block_count * full_encoded_block_size) 132 | } 133 | return bintostr(res); 134 | }; 135 | 136 | b58.decode_block = function (data, buf, index) { 137 | if (data.length < 1 || data.length > full_encoded_block_size) { 138 | throw "Invalid block length: " + data.length; 139 | } 140 | 141 | var res_size = encoded_block_sizes.indexOf(data.length); 142 | if (res_size <= 0) { 143 | throw "Invalid block size"; 144 | } 145 | var res_num = new JSBigInt(0); 146 | var order = new JSBigInt(1); 147 | for (var i = data.length - 1; i >= 0; i--) { 148 | var digit = alphabet.indexOf(data[i]); 149 | if (digit < 0) { 150 | throw "Invalid symbol"; 151 | } 152 | var product = order.multiply(digit).add(res_num); 153 | // if product > UINT64_MAX 154 | if (product.compare(UINT64_MAX) === 1) { 155 | throw "Overflow"; 156 | } 157 | res_num = product; 158 | order = order.multiply(alphabet_size); 159 | } 160 | if (res_size < full_block_size && (new JSBigInt(2).pow(8 * res_size).compare(res_num) <= 0)) { 161 | throw "Overflow 2"; 162 | } 163 | buf.set(uint64_to_8be(res_num, res_size), index); 164 | return buf; 165 | }; 166 | 167 | b58.decode = function (enc) { 168 | enc = strtobin(enc); 169 | if (enc.length === 0) { 170 | return ""; 171 | } 172 | var full_block_count = Math.floor(enc.length / full_encoded_block_size); 173 | var last_block_size = enc.length % full_encoded_block_size; 174 | var last_block_decoded_size = encoded_block_sizes.indexOf(last_block_size); 175 | if (last_block_decoded_size < 0) { 176 | throw "Invalid encoded length"; 177 | } 178 | var data_size = full_block_count * full_block_size + last_block_decoded_size; 179 | var data = new Uint8Array(data_size); 180 | for (var i = 0; i < full_block_count; i++) { 181 | data = b58.decode_block(enc.subarray(i * full_encoded_block_size, i * full_encoded_block_size + full_encoded_block_size), data, i * full_block_size); 182 | } 183 | if (last_block_size > 0) { 184 | data = b58.decode_block(enc.subarray(full_block_count * full_encoded_block_size, full_block_count * full_encoded_block_size + last_block_size), data, full_block_count * full_block_size); 185 | } 186 | return bintohex(data); 187 | }; 188 | 189 | return b58; 190 | })(); -------------------------------------------------------------------------------- /src/templates/index2.html: -------------------------------------------------------------------------------- 1 | {{#is_page_zero}} 2 |
3 | 4 | {{#show_alert}} 5 |
6 | × 7 | {{{alert_message}}} 8 |
9 | {{/show_alert}} 10 | 11 | {{{mempool_info}}} 12 |
13 |
14 |
15 |
Network Status
16 |
17 |
18 | {{#network_info}} 19 |
    20 |
  • 21 |
    22 |
    Block Size Limit
    23 |
    {{block_size_limit}} kB
    24 |
    25 |
  • 26 |
27 |
    28 |
  • 29 |
    30 |
    Transactions
    31 |
    {{tx_count}}
    32 |
    33 |
  • 34 |
  • 35 |
    36 |
    Fee per kB
    37 |
    {{fee_per_kb}} ETN
    38 |
    39 |
  • 40 |
41 |
    42 |
  • 43 |
    44 |
    Circulating Supply
    45 |
    ETN
    46 |
    47 |
  • 48 |
  • 49 |
    50 |
    Max Supply
    51 |
    21,000,000,000.00 ETN
    52 |
    53 |
  • 54 |
55 | {{/network_info}} 56 |
57 |
58 |
59 |
60 |
61 |
62 | 63 |
66 |
67 |
68 |
69 |
70 | {{/is_page_zero}} 71 |
72 |
73 |
74 |
75 | 76 | {{^is_page_zero}} 77 | Previous 78 | | Page {{page_no}}/{{total_page_no}} 79 | | Next 80 | {{/is_page_zero}} 81 | {{#is_page_zero}} 82 | 83 | More 84 | {{/is_page_zero}} 85 |
86 |
Latest Blocks
87 |
88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | {{#txs}} 100 | 101 | 102 | 103 | 104 | 105 | 107 | {{#has_multiple_tx}} 108 | 109 | {{/has_multiple_tx}} 110 | {{^has_multiple_tx}} 111 | 112 | {{/has_multiple_tx}} 113 | 114 | {{/txs}} 115 | 116 |
HeightBlock SizeRewardTimeBlock Hash
{{height}}{{blk_size}} kB{{sum_outputs_short}} ETN{{timestamp}}{{blk_hash}} 106 | {{tx_count}} Txs{{tx_count}} Tx
117 | {{^is_page_zero}} 118 | 157 | {{/is_page_zero}} 158 | 159 |
160 |
161 |
162 | 163 |

164 | {{#enable_autorefresh_option}} 165 | | 166 | {{#refresh}} 167 | Autorefresh is ON (10 s) 168 | {{/refresh}} 169 | {{^refresh}} 170 | Autorefresh is OFF 171 | {{/refresh}} 172 | {{/enable_autorefresh_option}} 173 |

-------------------------------------------------------------------------------- /cmake/sanitize-helpers.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | # Helper function to get the language of a source file. 26 | function (sanitizer_lang_of_source FILE RETURN_VAR) 27 | get_filename_component(FILE_EXT "${FILE}" EXT) 28 | string(TOLOWER "${FILE_EXT}" FILE_EXT) 29 | string(SUBSTRING "${FILE_EXT}" 1 -1 FILE_EXT) 30 | 31 | get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) 32 | foreach (LANG ${ENABLED_LANGUAGES}) 33 | list(FIND CMAKE_${LANG}_SOURCE_FILE_EXTENSIONS "${FILE_EXT}" TEMP) 34 | if (NOT ${TEMP} EQUAL -1) 35 | set(${RETURN_VAR} "${LANG}" PARENT_SCOPE) 36 | return() 37 | endif () 38 | endforeach() 39 | 40 | set(${RETURN_VAR} "" PARENT_SCOPE) 41 | endfunction () 42 | 43 | 44 | # Helper function to get compilers used by a target. 45 | function (sanitizer_target_compilers TARGET RETURN_VAR) 46 | # Check if all sources for target use the same compiler. If a target uses 47 | # e.g. C and Fortran mixed and uses different compilers (e.g. clang and 48 | # gfortran) this can trigger huge problems, because different compilers may 49 | # use different implementations for sanitizers. 50 | set(BUFFER "") 51 | get_target_property(TSOURCES ${TARGET} SOURCES) 52 | foreach (FILE ${TSOURCES}) 53 | # If expression was found, FILE is a generator-expression for an object 54 | # library. Object libraries will be ignored. 55 | string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _file ${FILE}) 56 | if ("${_file}" STREQUAL "") 57 | sanitizer_lang_of_source(${FILE} LANG) 58 | if (LANG) 59 | list(APPEND BUFFER ${CMAKE_${LANG}_COMPILER_ID}) 60 | endif () 61 | endif () 62 | endforeach () 63 | 64 | list(REMOVE_DUPLICATES BUFFER) 65 | set(${RETURN_VAR} "${BUFFER}" PARENT_SCOPE) 66 | endfunction () 67 | 68 | 69 | # Helper function to check compiler flags for language compiler. 70 | function (sanitizer_check_compiler_flag FLAG LANG VARIABLE) 71 | if (${LANG} STREQUAL "C") 72 | include(CheckCCompilerFlag) 73 | check_c_compiler_flag("${FLAG}" ${VARIABLE}) 74 | 75 | elseif (${LANG} STREQUAL "CXX") 76 | include(CheckCXXCompilerFlag) 77 | check_cxx_compiler_flag("${FLAG}" ${VARIABLE}) 78 | 79 | elseif (${LANG} STREQUAL "Fortran") 80 | # CheckFortranCompilerFlag was introduced in CMake 3.x. To be compatible 81 | # with older Cmake versions, we will check if this module is present 82 | # before we use it. Otherwise we will define Fortran coverage support as 83 | # not available. 84 | include(CheckFortranCompilerFlag OPTIONAL RESULT_VARIABLE INCLUDED) 85 | if (INCLUDED) 86 | check_fortran_compiler_flag("${FLAG}" ${VARIABLE}) 87 | elseif (NOT CMAKE_REQUIRED_QUIET) 88 | message(STATUS "Performing Test ${VARIABLE}") 89 | message(STATUS "Performing Test ${VARIABLE}" 90 | " - Failed (Check not supported)") 91 | endif () 92 | endif() 93 | endfunction () 94 | 95 | 96 | # Helper function to test compiler flags. 97 | function (sanitizer_check_compiler_flags FLAG_CANDIDATES NAME PREFIX) 98 | set(CMAKE_REQUIRED_QUIET ${${PREFIX}_FIND_QUIETLY}) 99 | 100 | get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) 101 | foreach (LANG ${ENABLED_LANGUAGES}) 102 | # Sanitizer flags are not dependend on language, but the used compiler. 103 | # So instead of searching flags foreach language, search flags foreach 104 | # compiler used. 105 | set(COMPILER ${CMAKE_${LANG}_COMPILER_ID}) 106 | if (NOT DEFINED ${PREFIX}_${COMPILER}_FLAGS) 107 | foreach (FLAG ${FLAG_CANDIDATES}) 108 | if(NOT CMAKE_REQUIRED_QUIET) 109 | message(STATUS "Try ${COMPILER} ${NAME} flag = [${FLAG}]") 110 | endif() 111 | 112 | set(CMAKE_REQUIRED_FLAGS "${FLAG}") 113 | unset(${PREFIX}_FLAG_DETECTED CACHE) 114 | sanitizer_check_compiler_flag("${FLAG}" ${LANG} 115 | ${PREFIX}_FLAG_DETECTED) 116 | 117 | if (${PREFIX}_FLAG_DETECTED) 118 | # If compiler is a GNU compiler, search for static flag, if 119 | # SANITIZE_LINK_STATIC is enabled. 120 | if (SANITIZE_LINK_STATIC AND (${COMPILER} STREQUAL "GNU")) 121 | string(TOLOWER ${PREFIX} PREFIX_lower) 122 | sanitizer_check_compiler_flag( 123 | "-static-lib${PREFIX_lower}" ${LANG} 124 | ${PREFIX}_STATIC_FLAG_DETECTED) 125 | 126 | if (${PREFIX}_STATIC_FLAG_DETECTED) 127 | set(FLAG "-static-lib${PREFIX_lower} ${FLAG}") 128 | endif () 129 | endif () 130 | 131 | set(${PREFIX}_${COMPILER}_FLAGS "${FLAG}" CACHE STRING 132 | "${NAME} flags for ${COMPILER} compiler.") 133 | mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS) 134 | break() 135 | endif () 136 | endforeach () 137 | 138 | if (NOT ${PREFIX}_FLAG_DETECTED) 139 | set(${PREFIX}_${COMPILER}_FLAGS "" CACHE STRING 140 | "${NAME} flags for ${COMPILER} compiler.") 141 | mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS) 142 | 143 | message(WARNING "${NAME} is not available for ${COMPILER} " 144 | "compiler. Targets using this compiler will be " 145 | "compiled without ${NAME}.") 146 | endif () 147 | endif () 148 | endforeach () 149 | endfunction () 150 | 151 | 152 | # Helper to assign sanitizer flags for TARGET. 153 | function (sanitizer_add_flags TARGET NAME PREFIX) 154 | # Get list of compilers used by target and check, if sanitizer is available 155 | # for this target. Other compiler checks like check for conflicting 156 | # compilers will be done in add_sanitizers function. 157 | sanitizer_target_compilers(${TARGET} TARGET_COMPILER) 158 | list(LENGTH TARGET_COMPILER NUM_COMPILERS) 159 | if ("${${PREFIX}_${TARGET_COMPILER}_FLAGS}" STREQUAL "") 160 | return() 161 | endif() 162 | 163 | # Set compile- and link-flags for target. 164 | set_property(TARGET ${TARGET} APPEND_STRING 165 | PROPERTY COMPILE_FLAGS " ${${PREFIX}_${TARGET_COMPILER}_FLAGS}") 166 | set_property(TARGET ${TARGET} APPEND_STRING 167 | PROPERTY COMPILE_FLAGS " ${SanBlist_${TARGET_COMPILER}_FLAGS}") 168 | set_property(TARGET ${TARGET} APPEND_STRING 169 | PROPERTY LINK_FLAGS " ${${PREFIX}_${TARGET_COMPILER}_FLAGS}") 170 | endfunction () 171 | --------------------------------------------------------------------------------