diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..57958d7af8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,50 @@
+# Prerequisites
+*.d
+
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+*.smod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+*.app
+
+# java
+*.class
+
+
+# ignore some directory
+build
+build/**
+deps
+deps/**
+libraftseal.bak
+libraftseal.bak/**
+tool/java/web3j-v2.1.0_src/bin
+tool/java/web3j-v2.1.0_src/bin/**
+tool/java/JuDfsSDK/bin
+tool/java/JuDfsSDK/bin/**
+
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000000..08cc4d6c3a
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,95 @@
+#------------------------------------------------------------------------------
+# Top-level CMake file for cpp-ethereum.
+#
+# The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org
+#
+# ------------------------------------------------------------------------------
+# This file is part of cpp-ethereum.
+#
+# cpp-ethereum is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cpp-ethereum is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cpp-ethereum. If not, see
+#
+# (c) 2014-2016 cpp-ethereum contributors.
+#------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.0.0)
+
+set(ETH_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The path to the cmake directory")
+list(APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR})
+
+set(CPP_ETHEREUM_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Path to the root directory for cpp-ethereum")
+
+# set cmake_policies
+include(EthPolicy)
+eth_policy()
+
+# project name and version should be set after cmake_policy CMP0048
+project(cpp-ethereum VERSION "1.3.0")
+
+if (NOT EXISTS ${CMAKE_SOURCE_DIR}/evmjit/)
+ message(FATAL_ERROR "Git submodules not initialized, execute:\n git submodule update --init")
+endif()
+
+set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY On)
+
+include(EthOptions)
+include(EthCompilerSettings)
+include(EthExecutableHelper)
+include(EthDependencies)
+include(EthUtils)
+
+include(ProjectBoost)
+include(ProjectCryptopp)
+include(ProjectJsonCpp)
+include(ProjectJsonRpcCpp)
+include(ProjectSecp256k1)
+
+configure_project(CPUID CURL EVMJIT FATDB MINIUPNPC ROCKSDB PARANOID VMTRACE)
+
+add_subdirectory(eth)
+add_subdirectory(libdevcore)
+add_subdirectory(libdevcrypto)
+add_subdirectory(libcontract)
+add_subdirectory(libsinglepoint)
+add_subdirectory(libpbftseal)
+add_subdirectory(libraftseal)
+add_subdirectory(libpailler)
+add_subdirectory(libethcore)
+add_subdirectory(libethereum)
+add_subdirectory(libevm)
+add_subdirectory(libevmcore)
+if (NOT EMSCRIPTEN)
+ add_subdirectory(libp2p)
+endif()
+add_subdirectory(libweb3jsonrpc)
+add_subdirectory(libwebthree)
+add_subdirectory(libwhisper)
+
+add_subdirectory(utils)
+
+
+if (EVMJIT)
+ add_subdirectory(evmjit)
+endif()
+
+if (TOOLS)
+
+
+ if (NOT EMSCRIPTEN)
+
+
+ endif()
+endif()
+
+# TODO - split out json_spirit, libscrypt and sec256k1
+
diff --git a/CodingStandards.txt b/CodingStandards.txt
new file mode 100644
index 0000000000..31957f2d25
--- /dev/null
+++ b/CodingStandards.txt
@@ -0,0 +1,254 @@
+0. Formatting
+
+GOLDEN RULE: Follow the style of the existing code when you make changes.
+
+a. Use tabs for leading indentation
+- tab stops are every 4 characters.
+- One indentation level -> exactly one byte (i.e. a tab character) in the source file.
+- If you have run-on lines, indent as you would for a block.
+b. Line widths:
+- Don't worry about having lines of code > 80-char wide.
+- Lines of comments should be formatted according to ease of viewing, but simplicity is to be prefered over beauty.
+c. Don't use braces for condition-body one-liners.
+d. Never place condition bodies on same line as condition.
+e. Space between first paren and keyword, but *not* following first paren or preceeding final paren.
+f. No spaces when fewer than intra-expression three parens together; when three or more, space according to clarity.
+g. No spaces for subscripting or unary operators.
+h. No space before ':' but one after it, except in the ternary operator: one on both sides.
+i. Space all other operators.
+j. Braces, when used, always have their own lines and are at same indentation level as "parent" scope.
+
+(WRONG)
+if( a==b[ i ] ) { printf ("Hello\n"); }
+foo->bar(someLongVariableName,
+ anotherLongVariableName,
+ anotherLongVariableName,
+ anotherLongVariableName,
+ anotherLongVariableName);
+
+(RIGHT)
+if (a == b[i])
+ printf("Hello\n"); // NOTE spaces used instead of tab here for clarity - first byte should be '\t'.
+foo->bar(
+ someLongVariableName,
+ anotherLongVariableName,
+ anotherLongVariableName,
+ anotherLongVariableName,
+ anotherLongVariableName
+);
+
+
+
+1. Namespaces;
+
+a. No "using namespace" declarations in header files.
+b. All symbols should be declared in a namespace except for final applications.
+c. Preprocessor symbols should be prefixed with the namespace in all-caps and an underscore.
+
+(WRONG)
+#include
+using namespace std;
+tuple meanAndSigma(vector const& _v);
+
+(CORRECT)
+#include
+std::tuple meanAndSigma(std::vector const& _v);
+
+
+
+2. Preprocessor;
+
+a. File comment is always at top, and includes:
+- Copyright.
+- License (e.g. see COPYING).
+b. Never use #ifdef/#define/#endif file guards. Prefer #pragma once as first line below file comment.
+c. Prefer static const variable to value macros.
+d. Prefer inline constexpr functions to function macros.
+e. Split complex macro on multiple lines with '\'.
+
+
+
+3. Capitalization;
+
+GOLDEN RULE: Preprocessor: ALL_CAPS; C++: camelCase.
+
+a. Use camelCase for splitting words in names, except where obviously extending STL/boost functionality in which case follow those naming conventions.
+b. The following entities' first alpha is upper case:
+- Type names.
+- Template parameters.
+- Enum members.
+- static const variables that form an external API.
+c. All preprocessor symbols (macros, macro argments) in full uppercase with underscore word separation.
+
+
+All other entities' first alpha is lower case.
+
+
+
+4. Variable prefixes:
+
+a. Leading underscore "_" to parameter names (both normal and template).
+- Exception: "o_parameterName" when it is used exclusively for output. See 6(f).
+- Exception: "io_parameterName" when it is used for both input and output. See 6(f).
+b. Leading "c_" to const variables (unless part of an external API).
+c. Leading "g_" to global (non-const) variables.
+d. Leading "s_" to static (non-const, non-global) variables.
+
+
+
+5. Error reporting:
+
+- Prefer exception to bool/int return type.
+
+
+
+6. Declarations:
+
+a. {Typename} + {qualifiers} + {name}.
+b. Only one per line.
+c. Associate */& with type, not variable (at ends with parser, but more readable, and safe if in conjunction with (b)).
+d. Favour declarations close to use; don't habitually declare at top of scope ala C.
+e. Always pass non-trivial parameters with a const& suffix.
+f. If a function returns multiple values, use std::tuple (std::pair acceptable). Prefer not using */& arguments, except where efficiency requires.
+g. Never use a macro where adequate non-preprocessor C++ can be written.
+h. Make use of auto whenever type is clear or unimportant:
+- Always avoid doubly-stating the type.
+- Use to avoid vast and unimportant type declarations.
+- However, avoid using auto where type is not immediately obvious from the context, and especially not for arithmetic expressions.
+i. Don't pass bools: prefer enumerations instead.
+j. Prefer enum class to straight enum.
+
+
+(WRONG)
+const double d = 0;
+int i, j;
+char *s;
+float meanAndSigma(std::vector _v, float* _sigma, bool _approximate);
+Derived* x(dynamic_cast(base));
+for (map::iterator i = l.begin(); i != l.end(); ++l) {}
+
+
+(CORRECT)
+enum class Accuracy
+{
+ Approximate,
+ Exact
+};
+double const d = 0;
+int i;
+int j;
+char* s;
+std::tuple meanAndSigma(std::vector const& _v, Accuracy _a);
+auto x = dynamic_cast(base);
+for (auto i = x.begin(); i != x.end(); ++i) {}
+
+
+7. Structs & classes
+
+a. Structs to be used when all members public and no virtual functions.
+- In this case, members should be named naturally and not prefixed with 'm_'
+b. Classes to be used in all other circumstances.
+
+
+
+8. Members:
+
+a. One member per line only.
+b. Private, non-static, non-const fields prefixed with m_.
+c. Avoid public fields, except in structs.
+d. Use override, final and const as much as possible.
+e. No implementations with the class declaration, except:
+- template or force-inline method (though prefer implementation at bottom of header file).
+- one-line implementation (in which case include it in same line as declaration).
+f. For a property 'foo'
+- Member: m_foo;
+- Getter: foo() [ also: for booleans, isFoo() ];
+- Setter: setFoo();
+
+
+
+9. Naming
+
+a. Collection conventions:
+- -s means std::vector e.g. using MyTypes = std::vector
+- -Set means std::set e.g. using MyTypeSet = std::set
+- -Hash means std::unordered_set e.g. using MyTypeHash = std::unordered_set
+b. Class conventions:
+- -Face means the interface of some shared concept. (e.g. FooFace might be a pure virtual class.)
+c. Avoid unpronouncable names;
+- If you need to shorten a name favour a pronouncable slice of the original to a scattered set of consonants.
+- e.g. Manager shortens to Man rather than Mgr.
+d. Avoid prefixes of initials (e.g. DON'T use IMyInterface, CMyImplementation)
+e. Find short, memorable & (at least semi-) descriptive names for commonly used classes or name-fragments.
+- A dictionary and thesaurus are your friends.
+- Spell correctly.
+- Think carefully about the class's purpose.
+- Imagine it as an isolated component to try to decontextualise it when considering its name.
+- Don't be trapped into naming it (purely) in terms of its implementation.
+
+
+
+10. Type-definitions
+
+a. Prefer 'using' to 'typedef'. e.g. using ints = std::vector; rather than typedef std::vector ints;
+b. Generally avoid shortening a standard form that already includes all important information:
+- e.g. stick to shared_ptr rather than shortening to ptr.
+c. Where there are exceptions to this (due to excessive use and clear meaning), note the change prominently and use it consistently.
+- e.g. using Guard = std::lock_guard; ///< Guard is used throughout the codebase since it's clear in meaning and used commonly.
+d. In general expressions should be roughly as important/semantically meaningful as the space they occupy.
+
+
+
+11. Commenting
+
+a. Comments should be doxygen-compilable, using @notation rather than \notation.
+b. Document the interface, not the implementation.
+- Documentation should be able to remain completely unchanged, even if the method is reimplemented.
+- Comment in terms of the method properties and intended alteration to class state (or what aspects of the state it reports).
+- Be careful to scrutinise documentation that extends only to intended purpose and usage.
+- Reject documentation that is simply an English transaction of the implementation.
+
+
+
+12. Include Headers
+
+Includes should go in increasing order of generality (libethereum -> libethcore -> libdevcrypto -> libdevcore -> boost -> STL). For example:
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+See http://stackoverflow.com/questions/614302/c-header-order/614333#614333 for the reason: this makes it easier to find missing includes in header files.
+
+
+
+13. Logging
+
+Logging should be performed at appropriate verbosities depending on the logging message.
+The more likely a message is to repeat (and thus cuase noise) the higher in verbosity it should be.
+Some rules to keep in mind:
+
+ - Verbosity == 0 -> Reserved for important stuff that users must see and can understand.
+ - Verbosity == 1 -> Reserved for stuff that users don't need to see but can understand.
+ - Verbosity >= 2 -> Anything that is or might be displayed more than once every minute
+ - Verbosity >= 3 -> Anything that only a developer would understand
+ - Verbosity >= 4 -> Anything that is low-level (e.g. peer disconnects, timers being cancelled)
+
+
+14. Recommended reading
+
+Herb Sutter and Bjarne Stroustrup
+- "C++ Core Guidelines" (https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md)
+
+Herb Sutter and Andrei Alexandrescu
+- "C++ Coding Standards: 101 Rules, Guidelines, and Best Practices"
+
+Scott Meyers
+- "Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)"
+- "More Effective C++: 35 New Ways to Improve Your Programs and Designs"
+- "Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14"
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000..4e5f7cc040
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,673 @@
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000000..c203b4c24f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,38 @@
+
+## 项目介绍
+BCOS平台(取BlockChainOpenSource涵义命名)是深圳前海微众银行股份有限公司、上海万向区块链股份公司、矩阵元技术(深圳)有限公司三方共同研发并且完全开源的区块链底层技术平台。
+
+BCOS平台基于现有的区块链开源项目进行开发,综合考虑开源项目的成熟度、开发接口友好性、技术组件齐备性、可插件化程度、多样化复杂业务支持程度等多方面的表现,并根据企业级区块链系统的规范和需求,对开源项目从底层进行改造和升级,形成符合企业级应用场景功能、性能、安全性、监管等要求的技术平台,帮助各行业的用户来构建商用区块链服务。
+
+
+BCOS平台是聚焦于企业级应用服务的区块链技术平台,已经在多个具备海量用户的企业级应用场景中被充分验证。在真实生产数据的检验下,BCOS平台保持零故障运行,印证了其安全可控、业务可行、健壮可用的优点,其功能、性能、容错性、可靠性、安全性、保密性、可追溯、模块化、可维护性、可移植性、互操作性、数据一致性等特性亦被验证可达到高标准。
+
+
+## 支持平台
+
+目前运行的操作系统平台如下:
+
+- Linux
+
+## 安装说明
+
+初次安装时,请参考[BCOS使用说明书1.0](https://github.com/bcosorg/bcos/blob/master/doc/manual/manual.md)。
+
+## 技术白皮书
+
+参见[BCOS平台白皮书——面向分布式商业的区块链基础设施](https://github.com/bcosorg/bcos/blob/master/doc/BCOS_Whitepaper.pdf)。
+
+
+## License
+
+BCOS的开源协议为GPL3.0,详情参见[LICENSE](https://github.com/bcosorg/bcos/blob/master/LICENSE)。
+
+## 联系我们
+邮箱:hi@bcos.org.cn。
+
+
+
+
+
+
+
diff --git a/accounttool/accountCheck.js b/accounttool/accountCheck.js
new file mode 100644
index 0000000000..f86f9493c8
--- /dev/null
+++ b/accounttool/accountCheck.js
@@ -0,0 +1,19 @@
+var crypto = require('crypto')
+var utils = require('./utils.js')
+
+function newAccount(pwd)
+{
+ var pKey ="bcec428d5205abe0f0cc8a734083908d9eb8563e31f943d760786edf42ad77dd";
+ var privKey =new Buffer(pKey, 'hex');
+ var pubKey = utils.privateToPublic(privKey);
+ var address = utils.privateToAddress(privKey);
+ var str_pri = '0x' + privKey.toString('hex');
+ var str_pub = '0x' + pubKey.toString('hex');
+ var str_addr = '0x' + address.toString('hex');
+ console.log("privKey : ",privKey," - " , str_pri," | pubKey : " ,pubKey," - ", str_pub," | address : ",address," - ",str_addr);
+}
+
+newAccount(123);
+
+
+
diff --git a/accounttool/accountManager.js b/accounttool/accountManager.js
new file mode 100644
index 0000000000..9c3ff48667
--- /dev/null
+++ b/accounttool/accountManager.js
@@ -0,0 +1,18 @@
+var crypto = require('crypto')
+var utils = require('./utils.js')
+
+function newAccount(pwd)
+{
+ var privKey = crypto.randomBytes(32);
+ var pubKey = utils.privateToPublic(privKey);
+ var address = utils.privateToAddress(privKey);
+ var str_pri = '0x' + privKey.toString('hex');
+ var str_pub = '0x' + pubKey.toString('hex');
+ var str_addr = '0x' + address.toString('hex');
+ console.log("privKey : ",privKey," - " , str_pri," | pubKey : " ,pubKey," - ", str_pub," | address : ",address," - ",str_addr);
+}
+
+newAccount();
+
+
+
diff --git a/accounttool/codeUtils.js b/accounttool/codeUtils.js
new file mode 100644
index 0000000000..21088bf844
--- /dev/null
+++ b/accounttool/codeUtils.js
@@ -0,0 +1,45 @@
+/*
+编码工具类,包含交易编码及日志编码
+*/
+var Web3 = require('web3');
+var sha3 = require("./sha3")
+var Event = require('web3/lib/web3/event');
+var Coder = require('web3/lib/solidity/coder');
+
+/*
+#交易编码
+###参数编码
+*/
+function codeParams(types,params)
+{
+ var code_ret = Coder.encodeParams(types, params);
+ console.log("code_ret : ",code_ret);
+ return code_ret;
+}
+
+/*
+###函数名编码
+*/
+function codeFun(fun_str)
+{
+
+ var code_fun = '0x' + sha3(fun_str).slice(0, 8);
+ console.log("code_fun : ",code_fun);
+ return code_fun;
+}
+
+/*
+###交易数据编码
+*/
+function codeTxData(fun_Str,types,params)
+{
+ var txData_code = codeFun(fun_Str);
+ txData_code += codeParams(types,params);
+ console.log("txData_code : ",txData_code);
+ return txData_code;
+}
+
+
+
+
+exports.codeTxData=codeTxData;
\ No newline at end of file
diff --git a/accounttool/config.js b/accounttool/config.js
new file mode 100644
index 0000000000..5bf62b91ab
--- /dev/null
+++ b/accounttool/config.js
@@ -0,0 +1,17 @@
+var abi_arr='[{"constant":false,"inputs":[{"name":"size","type":"uint256"}],"name":"add","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"bidder","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"HighestBidIncreased","type":"event"}]';
+var contract_addr='0x52d0e7c989c06ff92553b17eced8c5099e353f5c';//合约地址
+var ip="127.0.0.1";
+var rpcport=8545;
+var ipc_path="./data/geth.ipc"; //ipc文件
+var account="0x64fa644d2a694681bd6addd6c5e36cccd8dcdde3"; //区块链节点帐号
+var pwd=""; //帐号密码
+var privKey="bcec428d5205abe0f0cc8a734083908d9eb8563e31f943d760786edf42ad77dd";
+
+exports.abi_arr = abi_arr;
+exports.contract_addr = contract_addr;
+exports.ip = ip;
+exports.rpcport = rpcport;
+exports.ipc_path = ipc_path;
+exports.account = account;
+exports.pwd = pwd;
+exports.privKey = privKey;
\ No newline at end of file
diff --git a/accounttool/readMe.md b/accounttool/readMe.md
new file mode 100644
index 0000000000..baba1b7e0e
--- /dev/null
+++ b/accounttool/readMe.md
@@ -0,0 +1,10 @@
+1. 依赖库
+ crypto
+ secp256k1
+ keccak
+ assert
+ rlp
+ bn.js
+
+
+
\ No newline at end of file
diff --git a/accounttool/sendRawTransaction.js b/accounttool/sendRawTransaction.js
new file mode 100644
index 0000000000..bdebdd92af
--- /dev/null
+++ b/accounttool/sendRawTransaction.js
@@ -0,0 +1,61 @@
+var fs = require("fs");
+var Web3 = require('web3');
+var net = require('net');
+var conf = require('./config');
+var txm = require('./transactionManager');
+var coder = require('./codeUtils');
+
+//init web3
+var web3 = new Web3();
+var client = new net.Socket();
+web3.setProvider(new web3.providers.IpcProvider(conf.ipc_path,client));
+
+//sendRawTransaction
+function sendRawTransaction()
+{
+ web3.eth.getBlockNumber(function(e,d){
+ console.log(e+','+d);
+ var blocknumber=d+100;
+
+ var call_fun="add(uint256)";
+ var types=['uint256'];
+ var params=['15'];
+ var tx_data = coder.codeTxData(call_fun,types,params);
+
+ console.log('account:'+conf.account);
+
+ var postdata = {
+ data: tx_data,
+ from: conf.account,
+ to:conf.contract_addr,
+ gas: 1000000,
+ randomid:Math.ceil(Math.random()*100000000),
+ blockLimit:blocknumber
+ }
+
+ var signTX = txm.signTransaction(postdata,conf.privKey,null);
+ console.log("signTX : ",signTX);
+ web3.eth.sendRawTransaction(signTX, function(err, address) {
+ console.log(err,address);
+ if (!err)
+ {
+ console.log("发送交易成功!|",address);
+ process.exit();
+ return;
+ }
+ else
+ {
+ console.log("发送交易失败!",err);
+ process.exit();
+ return;
+ }
+ });
+
+
+ });
+
+
+}
+
+
+sendRawTransaction();
\ No newline at end of file
diff --git a/accounttool/sendTransaction.js b/accounttool/sendTransaction.js
new file mode 100644
index 0000000000..ece0351f69
--- /dev/null
+++ b/accounttool/sendTransaction.js
@@ -0,0 +1,192 @@
+var fs = require("fs");
+var Web3 = require('web3');
+var net = require('net');
+var conf = require('./config');
+
+//init web3
+var web3 = new Web3();
+var client = new net.Socket();
+web3.setProvider(new web3.providers.IpcProvider(conf.ipc_path,client));
+
+//sendTransaction
+function sendTransaction()
+{
+ var postdata = {
+ data: params_data,
+ from: conf.account,
+ to:conf.contract_addr,
+ value:params_value,
+ gas: 1000000
+ }
+ //发送交易
+ web3.eth.sendTransaction(postdata, function(err, address) {
+ if (!err)
+ {
+ logger.debug(tx_id + " | 发送交易成功!|",address);
+ process.exit();
+ return;
+ }
+ else
+ {
+ logger.debug(tx_id + "|发送交易失败!",err);
+ process.exit();
+ return;
+ }
+ });
+}
+
+function callContract()
+{
+ var test_params = '';
+ //调用合约
+ var abi_obj = conf.abi_arr;
+ var args = test_params;
+ console.log(" |args : " + args);
+ if( typeof(abi_obj) === 'string' || Object.prototype.toString.call(abi_obj) === '[object String]')
+ {
+ abi_obj = JSON.parse(abi_obj);
+ }
+ if( typeof(args) === 'string' || Object.prototype.toString.call(args) === '[object String]')
+ {
+ args = JSON.parse(args);
+ }
+ console.log(typeof(abi_obj) + " | " + Object.prototype.toString.call(abi_obj));
+ console.log(typeof(args) + " | " + Object.prototype.toString.call(args));
+ if(typeof(abi_obj) !== 'object' || Object.prototype.toString.call(abi_obj) !== '[object Array]' || typeof(args) !== 'object' || Object.prototype.toString.call(args) !== '[object Array]')
+ {
+ console.log("参数格式不合法! abi_obj : " + JSON.stringify(abi_obj) +" | args : " + JSON.stringify(args));
+ process.exit();
+ return;
+ }
+ else
+ {
+ console.log(" |args : " + args + " | " + JSON.stringify(args));
+ var breaked = false;
+ var abi_obj_size = abi_obj.length;
+ abi_obj.forEach(function (obj,index)
+ {
+ if(breaked) return;;
+ console.log("obj : " + JSON.stringify(obj) + " | " + abi_obj_size + " | " + index);
+ if(obj.constant !== undefined && obj.name !== undefined && obj.name === fun)
+ {
+ console.log("call fun : " + obj.name);
+ try{
+ // creation of contract object
+ var MyContract = web3.eth.contract(abi_obj);
+ // initiate contract for an address
+ if( conf.contract_addr === '' || conf.contract_addr === undefined)
+ {
+ console.log("未传入合约地址!");
+ process.exit();
+ return;
+ }
+ var myContractInstance = MyContract.at(conf.contract_addr);
+ var f = myContractInstance[fun];
+ if(obj.constant)
+ {
+ console.log(fun+" is a constant function, we should call it.");
+ if(typeof(f) === 'function')
+ {
+ try
+ {
+ var call_param = args;
+ function call_back(err,ret_data){
+ console.log("err : " + err + " | ret_data : " + JSON.stringify(ret_data));
+ if( !err )
+ {
+ console.log(f + " result : " + JSON.stringify(ret_data));
+ process.exit();
+ return;
+ }
+ else
+ {
+ console.log(" 调用合约失败");
+ process.exit();
+ return;
+ }
+ }
+ call_param.push(call_back);
+ console.log("f:"+f + " | args : " + JSON.stringify(call_param));
+ f.apply(myContractInstance, call_param);
+ }
+ catch(e)
+ {
+ console.log("exception:"+e.message);
+ process.exit();
+ return;
+ }
+ }
+ else
+ {
+ console.log(f + " 不是合约函数!");
+ process.exit();
+ return;
+ }
+ }
+ else
+ {
+ console.log(fun+" is not a constant function, we should send a Transaction.");
+ if(typeof(f) === 'function')
+ {
+ try
+ {
+ var call_param = args;
+ var fromparam = {
+ from:conf.account,
+ gas:100000000
+ };
+ //gas: 1000000000
+ call_param.push(fromparam);
+ function call_back(err,ret_data)
+ {
+ console.log("err : " + err + " | ret_data : " + JSON.stringify(ret_data));
+ if( !err )
+ {
+ console.log(f + " result : " + JSON.stringify(ret_data));
+ process.exit();
+ return;
+ }
+ else
+ {
+ console.log("调用合约失败!");
+ process.exit();
+ return;
+ }
+ }
+ call_param.push(call_back);
+ console.log("call_param : " + JSON.stringify(call_param));
+ f.apply(myContractInstance, call_param);
+ }
+ catch(e)
+ {
+ console.log("调用合约失败! | exception:",e);
+ process.exit();
+ return;
+ }
+ }
+ else
+ {
+ console.log(f + " 不是合约函数!");
+ process.exit();
+ return;
+ }
+ }
+ breaked = true;
+ }
+ catch(ex)
+ {
+ console.log("exception:",ex);
+ process.exit();
+ return;
+ }
+ }
+ if( parseInt(abi_obj_size) === (parseInt(index)+1) && !breaked )
+ {
+ console.log("合约未包含该函数!" + fun);
+ process.exit();
+ return;
+ }
+ });
+ }
+}
+
diff --git a/accounttool/sha3.js b/accounttool/sha3.js
new file mode 100644
index 0000000000..03e86683e9
--- /dev/null
+++ b/accounttool/sha3.js
@@ -0,0 +1,38 @@
+/*
+ This file is part of web3.js.
+
+ web3.js is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ web3.js is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with web3.js. If not, see .
+*/
+/**
+ * @file sha3.js
+ * @author Marek Kotewicz
+ * @date 2015
+ */
+
+var CryptoJS = require('crypto-js');
+var sha3 = require('crypto-js/sha3');
+
+module.exports = function (value, options) {
+ if (options && options.encoding === 'hex') {
+ if (value.length > 2 && value.substr(0, 2) === '0x') {
+ value = value.substr(2);
+ }
+ value = CryptoJS.enc.Hex.parse(value);
+ }
+
+ return sha3(value, {
+ outputLength: 256
+ }).toString();
+};
+
diff --git a/accounttool/signTransaction.js b/accounttool/signTransaction.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/accounttool/transactionManager.js b/accounttool/transactionManager.js
new file mode 100644
index 0000000000..d6f33e9f7d
--- /dev/null
+++ b/accounttool/transactionManager.js
@@ -0,0 +1,22 @@
+var Tx = require('./transactionObject.js');
+
+function signTransaction(tx_data,privKey,callback)
+{
+ // convert string private key to a Buffer Object
+ var privateKey = new Buffer(privKey, 'hex');
+ var tx = new Tx.Transaction(tx_data);
+ tx.sign(privateKey);
+ // Build a serialized hex version of the Tx
+ var serializedTx = '0x' + tx.serialize().toString('hex');
+ if( null !== callback)
+ {
+ callback(serializedTx);
+ return ;
+ }
+ else
+ {
+ return serializedTx;
+ }
+}
+
+exports.signTransaction=signTransaction;
\ No newline at end of file
diff --git a/accounttool/transactionObject.js b/accounttool/transactionObject.js
new file mode 100644
index 0000000000..a05243dc62
--- /dev/null
+++ b/accounttool/transactionObject.js
@@ -0,0 +1,253 @@
+const ethUtil = require('./utils.js')
+const BN = ethUtil.BN
+
+// secp256k1n/2
+const N_DIV_2 = new BN('7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0', 16)
+
+function Transaction(data) {
+ data = data || {}
+ // Define Properties
+ const fields = [{
+ name: 'randomid',
+ length: 32,
+ allowLess: true,
+ default: new Buffer([])
+ }, {
+ name: 'gasPrice',
+ length: 32,
+ allowLess: true,
+ default: new Buffer([])
+ }, {
+ name: 'gasLimit',
+ alias: 'gas',
+ length: 32,
+ allowLess: true,
+ default: new Buffer([])
+ }, {
+ name: 'blockLimit',
+ length: 32,
+ allowLess: true,
+ default: new Buffer([])
+ },{
+ name: 'to',
+ allowZero: true,
+ length: 20,
+ default: new Buffer([])
+ }, {
+ name: 'value',
+ length: 32,
+ allowLess: true,
+ default: new Buffer([])
+ }, {
+ name: 'data',
+ alias: 'input',
+ allowZero: true,
+ default: new Buffer([])
+ }, {
+ name: 'v',
+ length: 1,
+ default: new Buffer([0x1c])
+ }, {
+ name: 'r',
+ length: 32,
+ allowLess: true,
+ default: new Buffer([])
+ }, {
+ name: 's',
+ length: 32,
+ allowLess: true,
+ default: new Buffer([])
+ }]
+
+ /**
+ * Returns the rlp encoding of the transaction
+ * @method serialize
+ * @return {Buffer}
+ */
+ // attached serialize
+ ethUtil.defineProperties(this, fields, data)
+
+ /**
+ * @prop {Buffer} from (read only) sender address of this transaction, mathematically derived from other parameters.
+ */
+ Object.defineProperty(this, 'from', {
+ enumerable: true,
+ configurable: true,
+ get: this.getSenderAddress.bind(this)
+ })
+
+ // calculate chainId from signature
+ var sigV = ethUtil.bufferToInt(this.v)
+ var chainId = Math.floor((sigV - 35) / 2)
+ if (chainId < 0) chainId = 0
+
+ // set chainId
+ this._chainId = chainId || data.chainId || 0
+ this._homestead = true
+ }
+
+ /**
+ * If the tx's `to` is to the creation address
+ * @return {Boolean}
+ */
+ Transaction.prototype.toCreationAddress=function () {
+ return this.to.toString('hex') === ''
+ }
+
+ /**
+ * Computes a sha3-256 hash of the serialized tx
+ * @param {Boolean} [includeSignature=true] whether or not to inculde the signature
+ * @return {Buffer}
+ */
+ Transaction.prototype.hash=function (includeSignature) {
+ if (includeSignature === undefined) includeSignature = true
+ // backup original signature
+ const rawCopy = this.raw.slice(0)
+
+ // modify raw for signature generation only
+ if (this._chainId > 0) {
+ includeSignature = true
+ this.v = this._chainId
+ this.r = 0
+ this.s = 0
+ }
+
+ // generate rlp params for hash
+ console.log(this.raw.length)
+ var txRawForHash = includeSignature ? this.raw : this.raw.slice(0, this.raw.length - 3)
+ //var txRawForHash = includeSignature ? this.raw : this.raw.slice(0, 7)
+
+ // restore original signature
+ this.raw = rawCopy.slice()
+
+ // create hash
+ return ethUtil.rlphash(txRawForHash)
+ }
+
+ /**
+ * returns the public key of the sender
+ * @return {Buffer}
+ */
+ Transaction.prototype.getChainId=function() {
+ return this._chainId
+ }
+
+ /**
+ * returns the sender's address
+ * @return {Buffer}
+ */
+ Transaction.prototype.getSenderAddress = function() {
+ if (this._from) {
+ return this._from
+ }
+ const pubkey = this.getSenderPublicKey()
+ this._from = ethUtil.publicToAddress(pubkey)
+ return this._from
+ }
+
+ /**
+ * returns the public key of the sender
+ * @return {Buffer}
+ */
+ Transaction.prototype.getSenderPublicKey =function() {
+ if (!this._senderPubKey || !this._senderPubKey.length) {
+ if (!this.verifySignature()) throw new Error('Invalid Signature')
+ }
+ return this._senderPubKey
+ }
+
+ /**
+ * Determines if the signature is valid
+ * @return {Boolean}
+ */
+ Transaction.prototype.verifySignature =function() {
+ const msgHash = this.hash(false)
+ // All transaction signatures whose s-value is greater than secp256k1n/2 are considered invalid.
+ if (this._homestead && new BN(this.s).cmp(N_DIV_2) === 1) {
+ return false
+ }
+
+ try {
+ var v = ethUtil.bufferToInt(this.v)
+ if (this._chainId > 0) {
+ v -= this._chainId * 2 + 8
+ }
+ this._senderPubKey = ethUtil.ecrecover(msgHash, v, this.r, this.s)
+ } catch (e) {
+ return false
+ }
+
+ return !!this._senderPubKey
+ }
+
+ /**
+ * sign a transaction with a given a private key
+ * @param {Buffer} privateKey
+ */
+ Transaction.prototype.sign =function(privateKey) {
+ const msgHash = this.hash(false)
+ const sig = ethUtil.ecsign(msgHash, privateKey)
+ if (this._chainId > 0) {
+ sig.v += this._chainId * 2 + 8
+ }
+ Object.assign(this, sig)
+ }
+
+ /**
+ * The amount of gas paid for the data in this tx
+ * @return {BN}
+ */
+ Transaction.prototype.getDataFee=function() {
+ const data = this.raw[5]
+ const cost = new BN(0)
+ for (var i = 0; i < data.length; i++) {
+ data[i] === 0 ? cost.iaddn(fees.txDataZeroGas.v) : cost.iaddn(fees.txDataNonZeroGas.v)
+ }
+ return cost
+ }
+
+ /**
+ * the minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee)
+ * @return {BN}
+ */
+ Transaction.prototype.getBaseFee =function() {
+ const fee = this.getDataFee().iaddn(fees.txGas.v)
+ if (this._homestead && this.toCreationAddress()) {
+ fee.iaddn(fees.txCreation.v)
+ }
+ return fee
+ }
+
+ /**
+ * the up front amount that an account must have for this transaction to be valid
+ * @return {BN}
+ */
+ Transaction.prototype.getUpfrontCost =function() {
+ return new BN(this.gasLimit)
+ .imul(new BN(this.gasPrice))
+ .iadd(new BN(this.value))
+ }
+
+ /**
+ * validates the signature and checks to see if it has enough gas
+ * @param {Boolean} [stringError=false] whether to return a string with a dscription of why the validation failed or return a Bloolean
+ * @return {Boolean|String}
+ */
+ Transaction.prototype.validate =function(stringError) {
+ const errors = []
+ if (!this.verifySignature()) {
+ errors.push('Invalid Signature')
+ }
+
+ if (this.getBaseFee().cmp(new BN(this.gasLimit)) > 0) {
+ errors.push([`gas limit is to low. Need at least ${this.getBaseFee()}`])
+ }
+
+ if (stringError === undefined || stringError === false) {
+ return errors.length === 0
+ } else {
+ return errors.join(' ')
+ }
+ }
+
+exports.Transaction=Transaction;
diff --git a/accounttool/utils.js b/accounttool/utils.js
new file mode 100644
index 0000000000..88a77a5bdc
--- /dev/null
+++ b/accounttool/utils.js
@@ -0,0 +1,267 @@
+const secp256k1 = require('secp256k1')
+const createKeccakHash = require('keccak')
+const assert = require('assert')
+const rlp = require('rlp')
+const BN = require('bn.js')
+
+function privateToPublic(privateKey) {
+ privateKey = toBuffer(privateKey)
+ // skip the type flag and use the X, Y points
+ return secp256k1.publicKeyCreate(privateKey, false).slice(1)
+}
+
+function privateToAddress(privateKey) {
+ return publicToAddress(privateToPublic(privateKey))
+}
+
+function publicToAddress(pubKey, sanitize) {
+ pubKey = toBuffer(pubKey)
+ if (sanitize && (pubKey.length !== 64)) {
+ pubKey = secp256k1.publicKeyConvert(pubKey, false).slice(1)
+ }
+ assert(pubKey.length === 64)
+ // Only take the lower 160bits of the hash
+ return sha3(pubKey).slice(-20)
+}
+
+
+function toBuffer(v) {
+ if (!Buffer.isBuffer(v)) {
+ if (Array.isArray(v)) {
+ v = Buffer.from(v)
+ } else if (typeof v === 'string') {
+ if (isHexPrefixed(v)) {
+ v = Buffer.from(padToEven(stripHexPrefix(v)), 'hex')
+ } else {
+ v = Buffer.from(v)
+ }
+ } else if (typeof v === 'number') {
+ v = intToBuffer(v)
+ } else if (v === null || v === undefined) {
+ v = Buffer.allocUnsafe(0)
+ } else if (v.toArray) {
+ // converts a BN to a Buffer
+ v = Buffer.from(v.toArray())
+ } else {
+ throw new Error('invalid type')
+ }
+ }
+ return v
+}
+
+function isHexPrefixed(str) {
+ return str.slice(0, 2) === '0x'
+}
+
+function padToEven(a) {
+ if (a.length % 2) a = '0' + a
+ return a
+}
+
+function stripHexPrefix(str) {
+ if (typeof str !== 'string') {
+ return str
+ }
+ return isHexPrefixed(str) ? str.slice(2) : str
+}
+
+function intToBuffer(i) {
+ var hex = intToHex(i)
+ return Buffer.from(hex.slice(2), 'hex')
+}
+
+function intToHex(i) {
+ assert(i % 1 === 0, 'number is not a integer')
+ assert(i >= 0, 'number must be positive')
+ var hex = i.toString(16)
+ if (hex.length % 2) {
+ hex = '0' + hex
+ }
+ return '0x' + hex
+}
+
+function setLength(msg, length, right) {
+ var buf = zeros(length)
+ msg = toBuffer(msg)
+ if (right) {
+ if (msg.length < length) {
+ msg.copy(buf)
+ return buf
+ }
+ return msg.slice(0, length)
+ } else {
+ if (msg.length < length) {
+ msg.copy(buf, length - msg.length)
+ return buf
+ }
+ return msg.slice(-length)
+ }
+}
+
+function sha3(a, bits) {
+ a = toBuffer(a)
+ if (!bits) bits = 256
+ return createKeccakHash('keccak' + bits).update(a).digest()
+}
+
+function baToJSON(ba) {
+ if (Buffer.isBuffer(ba)) {
+ return '0x' + ba.toString('hex')
+ } else if (ba instanceof Array) {
+ var array = []
+ for (var i = 0; i < ba.length; i++) {
+ array.push(baToJSON(ba[i]))
+ }
+ return array
+ }
+}
+
+function zeros(bytes) {
+ return Buffer.allocUnsafe(bytes).fill(0)
+}
+
+function stripZeros(a) {
+ a = stripHexPrefix(a)
+ var first = a[0]
+ while (a.length > 0 && first.toString() === '0') {
+ a = a.slice(1)
+ first = a[0]
+ }
+ return a
+}
+
+function defineProperties(self, fields, data) {
+ self.raw = []
+ self._fields = []
+
+ // attach the `toJSON`
+ self.toJSON = function (label) {
+ if (label) {
+ var obj = {}
+ self._fields.forEach(function (field) {
+ obj[field] = '0x' + self[field].toString('hex')
+ })
+ return obj
+ }
+ return baToJSON(this.raw)
+ }
+
+ self.serialize = function serialize () {
+ return rlp.encode(self.raw)
+ }
+
+ fields.forEach(function (field, i) {
+ self._fields.push(field.name)
+ function getter () {
+ return self.raw[i]
+ }
+ function setter (v) {
+ v = toBuffer(v)
+
+ if (v.toString('hex') === '00' && !field.allowZero) {
+ v = Buffer.allocUnsafe(0)
+ }
+
+ if (field.allowLess && field.length) {
+ v = stripZeros(v)
+ assert(field.length >= v.length, 'The field ' + field.name + ' must not have more ' + field.length + ' bytes')
+ } else if (!(field.allowZero && v.length === 0) && field.length) {
+ assert(field.length === v.length, 'The field ' + field.name + ' must have byte length of ' + field.length)
+ }
+
+ self.raw[i] = v
+ }
+
+ Object.defineProperty(self, field.name, {
+ enumerable: true,
+ configurable: true,
+ get: getter,
+ set: setter
+ })
+
+ if (field.default) {
+ self[field.name] = field.default
+ }
+
+ // attach alias
+ if (field.alias) {
+ Object.defineProperty(self, field.alias, {
+ enumerable: false,
+ configurable: true,
+ set: setter,
+ get: getter
+ })
+ }
+ })
+
+ // if the constuctor is passed data
+ if (data) {
+ if (typeof data === 'string') {
+ data = Buffer.from(stripHexPrefix(data), 'hex')
+ }
+
+ if (Buffer.isBuffer(data)) {
+ data = rlp.decode(data)
+ }
+
+ if (Array.isArray(data)) {
+ if (data.length > self._fields.length) {
+ throw (new Error('wrong number of fields in data'))
+ }
+
+ // make sure all the items are buffers
+ data.forEach(function (d, i) {
+ self[self._fields[i]] = toBuffer(d)
+ })
+ } else if (typeof data === 'object') {
+ const keys = Object.keys(data)
+ fields.forEach(function (field) {
+ if (keys.indexOf(field.name) !== -1) self[field.name] = data[field.name]
+ if (keys.indexOf(field.alias) !== -1) self[field.alias] = data[field.alias]
+ })
+ } else {
+ throw new Error('invalid data')
+ }
+ }
+}
+
+function bufferToInt(buf) {
+ return new BN(toBuffer(buf)).toNumber()
+}
+
+function rlphash(a) {
+ return sha3(rlp.encode(a))
+}
+
+function ecrecover(msgHash, v, r, s) {
+ var signature = Buffer.concat([setLength(r, 32), setLength(s, 32)], 64)
+ var recovery = v - 27
+ if (recovery !== 0 && recovery !== 1) {
+ throw new Error('Invalid signature v value')
+ }
+ var senderPubKey = secp256k1.recover(msgHash, signature, recovery)
+ return secp256k1.publicKeyConvert(senderPubKey, false).slice(1)
+}
+
+function ecsign(msgHash, privateKey) {
+ var sig = secp256k1.sign(msgHash, privateKey)
+
+ var ret = {}
+ ret.r = sig.signature.slice(0, 32)
+ ret.s = sig.signature.slice(32, 64)
+ ret.v = sig.recovery + 27
+ return ret
+}
+
+exports.privateToPublic=privateToPublic
+exports.privateToAddress=privateToAddress
+exports.publicToAddress=publicToAddress
+exports.defineProperties=defineProperties
+exports.bufferToInt=bufferToInt
+exports.rlphash=rlphash
+exports.ecrecover=ecrecover
+exports.ecsign=ecsign
+
+exports.BN = BN
+exports.rlp = rlp
+exports.secp256k1 = secp256k1
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000000..993749c70b
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,87 @@
+#------------------------------------------------------------------------------
+# Appveyor configuration file for cpp-ethereum.
+#
+# The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org
+#
+# ------------------------------------------------------------------------------
+# This file is part of cpp-ethereum.
+#
+# cpp-ethereum is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cpp-ethereum is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cpp-ethereum. If not, see
+#
+# (c) 2016 cpp-ethereum contributors.
+#------------------------------------------------------------------------------
+
+branches:
+ only:
+ - master
+ - develop
+os: Visual Studio 2015
+configuration:
+ - RelWithDebInfo
+environment:
+ TESTS: On
+cache: build/evmjit/llvm
+#RDP LOGIN details for trouble shooting
+#init:
+# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
+#on_finish:
+# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
+install:
+ - git submodule update --init --recursive
+ - scripts/install_deps.bat
+ - set ETHEREUM_DEPS_PATH=%APPVEYOR_BUILD_FOLDER%\deps\install
+before_build:
+ - if not exist build mkdir build
+ - cd build
+ - cmake -G "Visual Studio 14 2015 Win64" .. -DTESTS=%TESTS% -DEVMJIT=On
+build_script:
+ - msbuild cpp-ethereum.sln /p:Configuration=%CONFIGURATION% /m:%NUMBER_OF_PROCESSORS% /v:minimal
+ - cd %APPVEYOR_BUILD_FOLDER%
+ - scripts\release.bat %CONFIGURATION% %ETHEREUM_DEPS_PATH% %TESTS%
+test_script:
+ - cd %APPVEYOR_BUILD_FOLDER%
+ - scripts\tests.bat %TESTS% %CONFIGURATION% %APPVEYOR_BUILD_FOLDER% %ETHEREUM_DEPS_PATH%
+artifacts:
+ - path: cpp-ethereum-windows.zip
+ name: cpp-ethereum-windows-zip
+
+# This is the deploy target for Windows which generates ZIPs per commit.
+# We are in agreement that generating ZIPs per commit for the develop
+# branch is probably just noise, so we only run this deployment target
+# on 'release'.
+#
+# See https://www.appveyor.com/docs/deployment/github for information
+# on GitHub Releases in Appveyor.
+#
+# You need to generate a GitHub personal access token for Appveyor
+# See https://github.com/settings/tokens for more information on that.
+# The token you generate there (in an encrypted form) is what is
+# passed to this deployment target in the 'auth_token' parameter
+# below.
+deploy:
+ prerelease: true
+ provider: GitHub
+ auth_token:
+ secure: yukM9mHUbzuZSS5WSBLKSW0yGJerJEqAXkFhDhSHBBcKJE7GAryjQsdO9Kxh3yRv
+ artifact: cpp-ethereum-windows-zip
+ on:
+ branch: release
+
+# Disable slightly annoying AppVeyorBot. The comments it adds onto Github issues are
+# redundant with the "Checks Passed/Failure" detail which is already on the issues.
+notifications:
+ - provider: GitHubPullRequest
+ on_build_success: false
+ on_build_failure: false
+ on_build_status_changed: false
diff --git a/cmake/CMakeParseArguments.cmake b/cmake/CMakeParseArguments.cmake
new file mode 100644
index 0000000000..11f1ab9bb7
--- /dev/null
+++ b/cmake/CMakeParseArguments.cmake
@@ -0,0 +1,161 @@
+#.rst:
+# CMakeParseArguments
+# -------------------
+#
+#
+#
+# CMAKE_PARSE_ARGUMENTS(
+# args...)
+#
+# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions
+# for parsing the arguments given to that macro or function. It
+# processes the arguments and defines a set of variables which hold the
+# values of the respective options.
+#
+# The argument contains all options for the respective macro,
+# i.e. keywords which can be used when calling the macro without any
+# value following, like e.g. the OPTIONAL keyword of the install()
+# command.
+#
+# The argument contains all keywords for this macro
+# which are followed by one value, like e.g. DESTINATION keyword of the
+# install() command.
+#
+# The argument contains all keywords for this
+# macro which can be followed by more than one value, like e.g. the
+# TARGETS or FILES keywords of the install() command.
+#
+# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
+# keywords listed in , and
+# a variable composed of the given
+# followed by "_" and the name of the respective keyword. These
+# variables will then hold the respective value from the argument list.
+# For the keywords this will be TRUE or FALSE.
+#
+# All remaining arguments are collected in a variable
+# _UNPARSED_ARGUMENTS, this can be checked afterwards to see
+# whether your macro was called with unrecognized parameters.
+#
+# As an example here a my_install() macro, which takes similar arguments
+# as the real install() command:
+#
+# ::
+#
+# function(MY_INSTALL)
+# set(options OPTIONAL FAST)
+# set(oneValueArgs DESTINATION RENAME)
+# set(multiValueArgs TARGETS CONFIGURATIONS)
+# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}"
+# "${multiValueArgs}" ${ARGN} )
+# ...
+#
+#
+#
+# Assume my_install() has been called like this:
+#
+# ::
+#
+# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
+#
+#
+#
+# After the cmake_parse_arguments() call the macro will have set the
+# following variables:
+#
+# ::
+#
+# MY_INSTALL_OPTIONAL = TRUE
+# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
+# MY_INSTALL_DESTINATION = "bin"
+# MY_INSTALL_RENAME = "" (was not used)
+# MY_INSTALL_TARGETS = "foo;bar"
+# MY_INSTALL_CONFIGURATIONS = "" (was not used)
+# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
+#
+#
+#
+# You can then continue and process these variables.
+#
+# Keywords terminate lists of values, e.g. if directly after a
+# one_value_keyword another recognized keyword follows, this is
+# interpreted as the beginning of the new option. E.g.
+# my_install(TARGETS foo DESTINATION OPTIONAL) would result in
+# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION
+# would be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
+
+#=============================================================================
+# Copyright 2010 Alexander Neundorf
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+
+if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
+ return()
+endif()
+set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
+
+
+function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
+ # first set all result variables to empty/FALSE
+ foreach(arg_name ${_singleArgNames} ${_multiArgNames})
+ set(${prefix}_${arg_name})
+ endforeach()
+
+ foreach(option ${_optionNames})
+ set(${prefix}_${option} FALSE)
+ endforeach()
+
+ set(${prefix}_UNPARSED_ARGUMENTS)
+
+ set(insideValues FALSE)
+ set(currentArgName)
+
+ # now iterate over all arguments and fill the result variables
+ foreach(currentArg ${ARGN})
+ list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
+ list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
+ list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
+
+ if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
+ if(insideValues)
+ if("${insideValues}" STREQUAL "SINGLE")
+ set(${prefix}_${currentArgName} ${currentArg})
+ set(insideValues FALSE)
+ elseif("${insideValues}" STREQUAL "MULTI")
+ list(APPEND ${prefix}_${currentArgName} ${currentArg})
+ endif()
+ else()
+ list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
+ endif()
+ else()
+ if(NOT ${optionIndex} EQUAL -1)
+ set(${prefix}_${currentArg} TRUE)
+ set(insideValues FALSE)
+ elseif(NOT ${singleArgIndex} EQUAL -1)
+ set(currentArgName ${currentArg})
+ set(${prefix}_${currentArgName})
+ set(insideValues "SINGLE")
+ elseif(NOT ${multiArgIndex} EQUAL -1)
+ set(currentArgName ${currentArg})
+ set(${prefix}_${currentArgName})
+ set(insideValues "MULTI")
+ endif()
+ endif()
+
+ endforeach()
+
+ # propagate the result variables to the caller:
+ foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
+ set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
+ endforeach()
+ set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
+
+endfunction()
diff --git a/cmake/EthBuildInfo.cmake b/cmake/EthBuildInfo.cmake
new file mode 100644
index 0000000000..8bd0685bd0
--- /dev/null
+++ b/cmake/EthBuildInfo.cmake
@@ -0,0 +1,53 @@
+function(create_build_info)
+
+ # Set build platform; to be written to BuildInfo.h
+ set(ETH_BUILD_OS "${CMAKE_SYSTEM_NAME}")
+
+ if (CMAKE_COMPILER_IS_MINGW)
+ set(ETH_BUILD_COMPILER "mingw")
+ elseif (CMAKE_COMPILER_IS_MSYS)
+ set(ETH_BUILD_COMPILER "msys")
+ elseif (CMAKE_COMPILER_IS_GNUCXX)
+ set(ETH_BUILD_COMPILER "g++")
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+ set(ETH_BUILD_COMPILER "msvc")
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set(ETH_BUILD_COMPILER "clang")
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
+ set(ETH_BUILD_COMPILER "appleclang")
+ else ()
+ set(ETH_BUILD_COMPILER "unknown")
+ endif ()
+
+ if (EVMJIT)
+ set(ETH_BUILD_JIT_MODE "JIT")
+ else ()
+ set(ETH_BUILD_JIT_MODE "Interpreter")
+ endif ()
+
+ set(ETH_BUILD_PLATFORM "${ETH_BUILD_OS}/${ETH_BUILD_COMPILER}/${ETH_BUILD_JIT_MODE}")
+
+ #cmake build type may be not speCified when using msvc
+ if (CMAKE_BUILD_TYPE)
+ set(_cmake_build_type ${CMAKE_BUILD_TYPE})
+ else()
+ set(_cmake_build_type "${CMAKE_CFG_INTDIR}")
+ endif()
+
+ # Generate header file containing useful build information
+ add_custom_target(BuildInfo.h ALL
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} -DETH_SOURCE_DIR="${PROJECT_SOURCE_DIR}" -DETH_BUILDINFO_IN="${ETH_CMAKE_DIR}/templates/BuildInfo.h.in" -DETH_DST_DIR="${PROJECT_BINARY_DIR}/include" -DETH_CMAKE_DIR="${ETH_CMAKE_DIR}"
+ -DETH_BUILD_TYPE="${_cmake_build_type}"
+ -DETH_BUILD_OS="${ETH_BUILD_OS}"
+ -DETH_BUILD_COMPILER="${ETH_BUILD_COMPILER}"
+ -DETH_BUILD_JIT_MODE="${ETH_BUILD_JIT_MODE}"
+ -DETH_BUILD_PLATFORM="${ETH_BUILD_PLATFORM}"
+ -DETH_BUILD_NUMBER="${BUILD_NUMBER}"
+ -DETH_VERSION_SUFFIX="${VERSION_SUFFIX}"
+ -DPROJECT_VERSION="${PROJECT_VERSION}"
+ -DETH_FATDB="${FATDB10}"
+ -P "${ETH_SCRIPTS_DIR}/buildinfo.cmake"
+ )
+ include_directories(BEFORE ${PROJECT_BINARY_DIR})
+endfunction()
diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake
new file mode 100644
index 0000000000..aa011b5ce3
--- /dev/null
+++ b/cmake/EthCompilerSettings.cmake
@@ -0,0 +1,188 @@
+#------------------------------------------------------------------------------
+# EthCompilerSettings.cmake
+#
+# CMake file for cpp-ethereum project which specifies our compiler settings
+# for each supported platform and build configuration.
+#
+# The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org
+#
+# Copyright (c) 2014-2016 cpp-ethereum contributors.
+#------------------------------------------------------------------------------
+
+# Clang seeks to be command-line compatible with GCC as much as possible, so
+# most of our compiler settings are common between GCC and Clang.
+#
+# These settings then end up spanning all POSIX platforms (Linux, OS X, BSD, etc)
+
+# Use ccache if available
+find_program(CCACHE_FOUND ccache)
+if(CCACHE_FOUND)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
+ message("Using ccache")
+endif(CCACHE_FOUND)
+
+if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
+
+ # Use ISO C++11 standard language.
+ set(CMAKE_CXX_FLAGS -std=c++11)
+ set(CMAKE_C_FLAGS -std=c99)
+
+ # Enables all the warnings about constructions that some users consider questionable,
+ # and that are easy to avoid. Also enable some extra warning flags that are not
+ # enabled by -Wall. Finally, treat at warnings-as-errors, which forces developers
+ # to fix warnings as they arise, so they don't accumulate "to be fixed later".
+ add_compile_options(-Wall)
+ add_compile_options(-Wno-unused-variable)
+ add_compile_options(-Wunused-parameter)
+ add_compile_options(-Wextra)
+ #add_compile_options(-Werror)
+
+ # Disable warnings about unknown pragmas (which is enabled by -Wall).
+ add_compile_options(-Wno-unknown-pragmas)
+
+ add_compile_options(-fno-omit-frame-pointer)
+
+ # Configuration-specific compiler settings.
+ set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DETH_DEBUG -DELPP_THREAD_SAFE")
+ set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG -DETH_RELEASE -DELPP_THREAD_SAFE")
+ set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -DETH_RELEASE -DELPP_THREAD_SAFE")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DETH_RELEASE -DELPP_THREAD_SAFE")
+
+ option(USE_LD_GOLD "Use GNU gold linker" ON)
+ if (USE_LD_GOLD)
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
+ if ("${LD_VERSION}" MATCHES "GNU gold")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
+ endif ()
+ endif ()
+
+ # Additional GCC-specific compiler settings.
+ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
+
+ # Check that we've got GCC 4.7 or newer.
+ execute_process(
+ COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
+ if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
+ message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.")
+ endif ()
+
+ # Strong stack protection was only added in GCC 4.9.
+ # Use it if we have the option to do so.
+ # See https://lwn.net/Articles/584225/
+ if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
+ add_compile_options(-fstack-protector-strong)
+ add_compile_options(-fstack-protector)
+ endif()
+
+ # Additional Clang-specific compiler settings.
+ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+
+ add_compile_options(-fstack-protector)
+
+ # Enable strong stack protection only on Mac and only for OS X Yosemite
+ # or newer (AppleClang 7.0+). We should be able to re-enable this setting
+ # on non-Apple Clang as well, if we can work out what expression to use for
+ # the version detection.
+
+ # The fact that the version-reporting for AppleClang loses the original
+ # Clang versioning is rather annoying. Ideally we could just have
+ # a single cross-platform "if version >= 3.4.1" check.
+ #
+ # There is debug text in the else clause below, to help us work out what
+ # such an expression should be, if we can get this running on a Trusty box
+ # with Clang. Greg Colvin previously replicated the issue there too.
+ #
+ # See https://github.com/ethereum/webthree-umbrella/issues/594
+
+ if (APPLE)
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
+ add_compile_options(-fstack-protector-strong)
+ endif()
+ else()
+ message(WARNING "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}")
+ endif()
+
+ # Some Linux-specific Clang settings. We don't want these for OS X.
+ if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
+
+ # Tell Boost that we're using Clang's libc++. Not sure exactly why we need to do.
+ add_definitions(-DBOOST_ASIO_HAS_CLANG_LIBCXX)
+
+ # Use fancy colors in the compiler diagnostics
+ add_compile_options(-fcolor-diagnostics)
+ endif()
+ endif()
+
+# The major alternative compiler to GCC/Clang is Microsoft's Visual C++ compiler, only available on Windows.
+elseif (MSVC)
+
+ add_compile_options(/MP) # enable parallel compilation
+ add_compile_options(/EHsc) # specify Exception Handling Model in msvc
+ add_compile_options(/WX) # enable warnings-as-errors
+ add_compile_options(/wd4068) # disable unknown pragma warning (4068)
+ add_compile_options(/wd4996) # disable unsafe function warning (4996)
+ add_compile_options(/wd4503) # disable decorated name length exceeded, name was truncated (4503)
+ add_compile_options(/wd4267) # disable conversion from 'size_t' to 'type', possible loss of data (4267)
+ add_compile_options(/wd4180) # disable qualifier applied to function type has no meaning; ignored (4180)
+ add_compile_options(/wd4290) # disable C++ exception specification ignored except to indicate a function is not __declspec(nothrow) (4290)
+ add_compile_options(/wd4297) # disable 's function assumed not to throw an exception but does (4297)
+ add_compile_options(/wd4244) # disable conversion from 'type1' to 'type2', possible loss of data (4244)
+ add_compile_options(/wd4800) # disable forcing value to bool 'true' or 'false' (performance warning) (4800)
+ add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement
+ add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions
+ add_compile_options(-DMINIUPNP_STATICLIB) # define miniupnp static library
+
+ # Always use Release variant of C++ runtime.
+ # We don't want to provide Debug variants of all dependencies. Some default
+ # flags set by CMake must be tweaked.
+ string(REPLACE "/MDd" "/MD" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+ string(REPLACE "/D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+ string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+ string(REPLACE "/MDd" "/MD" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
+ string(REPLACE "/D_DEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
+ string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
+ set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS OFF)
+
+ # disable empty object file warning
+ set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
+ # warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
+ # warning LNK4099: pdb was not found with lib
+ # stack size 16MB
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4099,4075 /STACK:16777216")
+
+# If you don't have GCC, Clang or VC++ then you are on your own. Good luck!
+else ()
+ message(WARNING "Your compiler is not tested, if you run into any issues, we'd welcome any patches.")
+endif ()
+
+if (SANITIZE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=${SANITIZE}")
+ if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/sanitizer-blacklist.txt")
+ endif()
+endif()
+
+if (PROFILING AND (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")))
+ set(CMAKE_CXX_FLAGS "-g ${CMAKE_CXX_FLAGS}")
+ set(CMAKE_C_FLAGS "-g ${CMAKE_C_FLAGS}")
+ add_definitions(-DETH_PROFILING_GPERF)
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lprofiler")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lprofiler")
+endif ()
+
+if (COVERAGE)
+ set(CMAKE_CXX_FLAGS "-g --coverage ${CMAKE_CXX_FLAGS}")
+ set(CMAKE_C_FLAGS "-g --coverage ${CMAKE_C_FLAGS}")
+ set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
+ set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
+ find_program(LCOV_TOOL lcov)
+ message(STATUS "lcov tool: ${LCOV_TOOL}")
+ if (LCOV_TOOL)
+ add_custom_target(coverage.info
+ COMMAND ${LCOV_TOOL} -o ${CMAKE_BINARY_DIR}/coverage.info -c -d ${CMAKE_BINARY_DIR}
+ COMMAND ${LCOV_TOOL} -o ${CMAKE_BINARY_DIR}/coverage.info -r ${CMAKE_BINARY_DIR}/coverage.info '/usr*' '${CMAKE_BINARY_DIR}/deps/*' '${CMAKE_SOURCE_DIR}/deps/*'
+ )
+ endif()
+endif ()
diff --git a/cmake/EthDependencies.cmake b/cmake/EthDependencies.cmake
new file mode 100644
index 0000000000..76f5eeed95
--- /dev/null
+++ b/cmake/EthDependencies.cmake
@@ -0,0 +1,105 @@
+# all dependencies that are not directly included in the cpp-ethereum distribution are defined here
+# for this to work, download the dependency via the cmake script in extdep or install them manually!
+
+function(eth_show_dependency DEP NAME)
+ get_property(DISPLAYED GLOBAL PROPERTY ETH_${DEP}_DISPLAYED)
+ if (NOT DISPLAYED)
+ set_property(GLOBAL PROPERTY ETH_${DEP}_DISPLAYED TRUE)
+ message(STATUS "${NAME} headers: ${${DEP}_INCLUDE_DIRS}")
+ message(STATUS "${NAME} lib : ${${DEP}_LIBRARIES}")
+ if (NOT("${${DEP}_DLLS}" STREQUAL ""))
+ message(STATUS "${NAME} dll : ${${DEP}_DLLS}")
+ endif()
+ endif()
+endfunction()
+
+# The Windows platform has not historically had any standard packaging system for delivering
+# versioned releases of libraries. Homebrew and PPA perform that function for macOS and Ubuntu
+# respectively, and there are analogous standards for other Linux distros. In the absense of
+# such a standard, we have chosen to make a "fake packaging system" for cpp-ethereum, which is
+# implemented in https://github.com/ethereum/cpp-dependencies.
+#
+# NOTE - In the last couple of years, the NuGet packaging system, first created for delivery
+# of .NET packages, has added support for C++ packages, and it may be possible for us to migrate
+# our "fake package server" to that real package server. That would certainly be preferable
+# to rolling our own, but it also puts us at the mercy of intermediate package maintainers who
+# may be inactive. There is not a fantastic range of packages available at the time of writing,
+# so we might find that such a move turns us into becoming the package maintainer for our
+# dependencies. Not a net win :-)
+#
+# "Windows - Try to use NuGet C++ packages"
+# https://github.com/ethereum/webthree-umbrella/issues/509
+#
+# Perhaps a better alternative is to step away from dependencies onto binary releases entirely,
+# and switching to build-from-source for some (or all) of our dependencies, especially if they
+# are small. That gives us total control, but at the cost of longer build times. That is the
+# approach which Pawel has taken for LLVM in https://github.com/ethereum/evmjit.
+
+if (MSVC)
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.0)
+ message(FATAL_ERROR "ERROR - As of the 1.3.0 release, cpp-ethereum only supports Visual Studio 2015 or newer.\nPlease download from https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx.")
+ else()
+ get_filename_component(ETH_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_LIST_DIR}/../deps/x64" ABSOLUTE)
+ endif()
+ set (CMAKE_PREFIX_PATH ${ETH_DEPENDENCY_INSTALL_DIR} ${CMAKE_PREFIX_PATH})
+endif()
+
+# custom cmake scripts
+set(ETH_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
+set(ETH_SCRIPTS_DIR ${ETH_CMAKE_DIR}/scripts)
+
+find_program(CTEST_COMMAND ctest)
+
+# Use Boost "multithreaded mode" for Windows. The platform C/C++ runtime libraries come in
+# two flavors on Windows, which causes an ABI schism across the whole ecosystem. This setting
+# is declaring which side of that schism we fall on.
+if (MSVC)
+ set(Boost_USE_MULTITHREADED ON)
+endif()
+
+# Use the dynamic libraries for Boost for Linux and static linkage on Windows and macOS.
+# We would like to use static linkage on Linux too, but on Ubuntu at least it appears that
+# the prebuilt binaries for Boost won't support this.
+#
+# We will need to build Boost from source ourselves, with -fPIC enabled, before we are
+# able to remove this conditional. That is exactly what has been happening for months for
+# the doublethinkco cross-builds (see https://github.com/doublethinkco/cpp-ethereum-cross).
+#
+# Typical build error we get if trying to do static Boost on Ubunty Trusty (many of them):
+#
+# Linking CXX shared library libdevcore.so
+# /usr/bin/ld.gold: error: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/
+# libboost_thread.a(thread.o): requires dynamic R_X86_64_32 reloc which may overflow at
+# runtime; recompile with -fPIC
+#
+# https://travis-ci.org/bobsummerwill/cpp-ethereum/jobs/145955041
+
+if (UNIX AND NOT APPLE)
+ set(Boost_USE_STATIC_LIBS OFF)
+else()
+ set(Boost_USE_STATIC_LIBS ON)
+endif()
+
+include_directories(BEFORE "${PROJECT_BINARY_DIR}/include")
+
+function(eth_use TARGET REQUIRED)
+ if (NOT TARGET ${TARGET})
+ message(FATAL_ERROR "eth_use called for non existing target ${TARGET}")
+ endif()
+
+ foreach(MODULE ${ARGN})
+ string(REPLACE "::" ";" MODULE_PARTS "${MODULE}")
+ list(GET MODULE_PARTS 0 MODULE_MAIN)
+ list(LENGTH MODULE_PARTS MODULE_LENGTH)
+ if (MODULE_LENGTH GREATER 1)
+ list(GET MODULE_PARTS 1 MODULE_SUB)
+ endif()
+ # TODO: check if file exists if not, throws FATAL_ERROR with detailed description
+ get_target_property(TARGET_APPLIED ${TARGET} TARGET_APPLIED_${MODULE_MAIN}_${MODULE_SUB})
+ if (NOT TARGET_APPLIED)
+ include(Use${MODULE_MAIN})
+ set_target_properties(${TARGET} PROPERTIES TARGET_APPLIED_${MODULE_MAIN}_${MODULE_SUB} TRUE)
+ eth_apply(${TARGET} ${REQUIRED} ${MODULE_SUB})
+ endif()
+ endforeach()
+endfunction()
diff --git a/cmake/EthExecutableHelper.cmake b/cmake/EthExecutableHelper.cmake
new file mode 100644
index 0000000000..422ccbdd8c
--- /dev/null
+++ b/cmake/EthExecutableHelper.cmake
@@ -0,0 +1,155 @@
+#
+# this function requires the following variables to be specified:
+# ETH_VERSION
+# PROJECT_NAME
+# PROJECT_VERSION
+# PROJECT_COPYRIGHT_YEAR
+# PROJECT_VENDOR
+# PROJECT_DOMAIN_SECOND
+# PROJECT_DOMAIN_FIRST
+# SRC_LIST
+# HEADERS
+#
+# params:
+# ICON
+#
+
+macro(eth_add_executable EXECUTABLE)
+ set (extra_macro_args ${ARGN})
+ set (options)
+ set (one_value_args ICON)
+ set (multi_value_args UI_RESOURCES WIN_RESOURCES)
+ cmake_parse_arguments (ETH_ADD_EXECUTABLE "${options}" "${one_value_args}" "${multi_value_args}" "${extra_macro_args}")
+
+ if (APPLE)
+
+ add_executable(${EXECUTABLE} MACOSX_BUNDLE ${SRC_LIST} ${HEADERS} ${ETH_ADD_EXECUTABLE_UI_RESOURCES})
+ set(PROJECT_VERSION "${ETH_VERSION}")
+ set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${PROJECT_VERSION}")
+ set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_NAME} ${PROJECT_VERSION}")
+ set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} ${PROJECT_VERSION}")
+ set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}")
+ set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}")
+ set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}")
+ set(MACOSX_BUNDLE_BUNDLE_NAME ${EXECUTABLE})
+ set(MACOSX_BUNDLE_ICON_FILE ${ETH_ADD_EXECUTABLE_ICON})
+ set_target_properties(${EXECUTABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in")
+ set_source_files_properties(${EXECUTABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS)
+ set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${MACOSX_BUNDLE_ICON_FILE}.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
+
+ else ()
+ add_executable(${EXECUTABLE} ${ETH_ADD_EXECUTABLE_UI_RESOURCES} ${ETH_ADD_EXECUTABLE_WIN_RESOURCES} ${SRC_LIST} ${HEADERS})
+ endif()
+
+endmacro()
+
+macro(eth_copy_dll EXECUTABLE DLL)
+ # dlls must be unsubstitud list variable (without ${}) in format
+ # optimized;path_to_dll.dll;debug;path_to_dlld.dll
+ if(DEFINED MSVC)
+ list(GET ${DLL} 1 DLL_RELEASE)
+ list(GET ${DLL} 3 DLL_DEBUG)
+ add_custom_command(TARGET ${EXECUTABLE}
+ PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} ARGS
+ -DDLL_RELEASE="${DLL_RELEASE}"
+ -DDLL_DEBUG="${DLL_DEBUG}"
+ -DCONF="$"
+ -DDESTINATION="${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}"
+ -P "${ETH_SCRIPTS_DIR}/copydlls.cmake"
+ )
+ endif()
+endmacro()
+
+macro(eth_copy_dlls EXECUTABLE)
+ foreach(dll ${ARGN})
+ eth_copy_dll(${EXECUTABLE} ${dll})
+ endforeach(dll)
+endmacro()
+
+
+macro(eth_install_executable EXECUTABLE)
+
+ if (APPLE)
+
+ # TODO - Why is this different than the branch Linux below, which has the RUNTIME keyword too?
+ install(TARGETS ${EXECUTABLE} DESTINATION bin)
+
+ elseif (MSVC)
+
+ set(COMPONENT ${EXECUTABLE})
+
+ install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Debug/"
+ DESTINATION .
+ CONFIGURATIONS Debug
+ COMPONENT ${COMPONENT}
+ )
+
+ install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Release/"
+ DESTINATION .
+ CONFIGURATIONS Release
+ COMPONENT ${COMPONENT}
+ )
+
+ install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/"
+ DESTINATION .
+ CONFIGURATIONS RelWithDebInfo
+ COMPONENT ${COMPONENT}
+ )
+
+ else()
+ install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin)
+ endif ()
+
+endmacro()
+
+macro (eth_name KEY VALUE)
+ if (NOT (APPLE OR WIN32))
+ string(TOLOWER ${VALUE} LVALUE )
+ set(${KEY} ${LVALUE})
+ else()
+ set(${KEY} ${VALUE})
+ endif()
+endmacro()
+
+macro(jsonrpcstub_client_create EXECUTABLE SPEC CLIENTNAME CLIENTDIR CLIENTFILENAME)
+ if (ETH_JSON_RPC_STUB)
+ add_custom_target(${SPEC}stub)
+ add_custom_command(
+ TARGET ${SPEC}stub
+ POST_BUILD
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${SPEC}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} -DETH_SPEC_PATH="${CMAKE_CURRENT_SOURCE_DIR}/${SPEC}" -DETH_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DETH_CMAKE_DIR="${ETH_CMAKE_DIR}"
+ -DETH_CLIENT_DIR="${CLIENTDIR}"
+ -DETH_CLIENT_NAME=${CLIENTNAME}
+ -DETH_CLIENT_FILENAME=${CLIENTFILENAME}
+ -DETH_JSON_RPC_STUB="${ETH_JSON_RPC_STUB}"
+ -P "${ETH_SCRIPTS_DIR}/jsonrpcstub.cmake"
+ )
+ add_dependencies(${EXECUTABLE} ${SPEC}stub)
+ endif ()
+endmacro()
+
+macro(jsonrpcstub_create EXECUTABLE SPEC SERVERNAME SERVERDIR SERVERFILENAME CLIENTNAME CLIENTDIR CLIENTFILENAME)
+ if (ETH_JSON_RPC_STUB)
+ add_custom_target(${SPEC}stub)
+ add_custom_command(
+ TARGET ${SPEC}stub
+ POST_BUILD
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${SPEC}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} -DETH_SPEC_PATH="${CMAKE_CURRENT_SOURCE_DIR}/${SPEC}" -DETH_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DETH_CMAKE_DIR="${ETH_CMAKE_DIR}"
+ -DETH_CLIENT_DIR="${CLIENTDIR}"
+ -DETH_CLIENT_NAME=${CLIENTNAME}
+ -DETH_CLIENT_FILENAME=${CLIENTFILENAME}
+ -DETH_SERVER_DIR="${SERVERDIR}"
+ -DETH_SERVER_NAME=${SERVERNAME}
+ -DETH_SERVER_FILENAME=${SERVERFILENAME}
+ -DETH_JSON_RPC_STUB="${ETH_JSON_RPC_STUB}"
+ -P "${ETH_SCRIPTS_DIR}/jsonrpcstub.cmake"
+ )
+ add_dependencies(${EXECUTABLE} ${SPEC}stub)
+ endif ()
+endmacro()
+
diff --git a/cmake/EthOptions.cmake b/cmake/EthOptions.cmake
new file mode 100644
index 0000000000..6042e73600
--- /dev/null
+++ b/cmake/EthOptions.cmake
@@ -0,0 +1,138 @@
+macro(configure_project)
+ set(NAME ${PROJECT_NAME})
+
+ # Default to RelWithDebInfo configuration if no configuration is explicitly specified.
+ if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
+ "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
+ endif()
+
+ eth_default_option(BUILD_SHARED_LIBS OFF)
+
+ # features
+ eth_default_option(VMTRACE OFF)
+ eth_default_option(PROFILING OFF)
+ eth_default_option(FATDB ON)
+ eth_default_option(ROCKSDB OFF)
+ eth_default_option(PARANOID OFF)
+ eth_default_option(MINIUPNPC ON)
+
+ # components
+ eth_default_option(TESTS ON)
+ eth_default_option(TOOLS ON)
+ eth_default_option(EVMJIT OFF)
+
+ # Resolve any clashes between incompatible options.
+ if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
+ if (PARANOID)
+ message("Paranoia requires debug - disabling for release build.")
+ set(PARANOID OFF)
+ endif ()
+ if (VMTRACE)
+ message("VM Tracing requires debug - disabling for release build.")
+ set (VMTRACE OFF)
+ endif ()
+ endif ()
+
+ # Define a matching property name of each of the "features".
+ foreach(FEATURE ${ARGN})
+ set(SUPPORT_${FEATURE} TRUE)
+ endforeach()
+
+ # Temporary pre-processor symbol used for hiding broken unit-tests.
+ # Hiding them behind this pre-processor symbol lets us turn them off
+ # and on again easily enough, and also to grep for them.
+ add_definitions(-DDISABLE_BROKEN_UNIT_TESTS_UNTIL_WE_FIX_THEM)
+
+ # Are we including the JIT EVM module?
+ # That pulls in a quite heavyweight LLVM dependency, which is
+ # not suitable for all platforms.
+ if (EVMJIT)
+ add_definitions(-DETH_EVMJIT)
+ endif ()
+
+ if (ODBC)
+ add_definitions(-DETH_ODBC)
+ endif ()
+
+ # FATDB is an option to include the reverse hashes for the trie,
+ # i.e. it allows you to iterate over the contents of the state.
+ if (FATDB)
+ add_definitions(-DETH_FATDB)
+ endif ()
+
+ # TODO: What does "paranoia" even mean?
+ if (PARANOID)
+ add_definitions(-DETH_PARANOIA)
+ endif ()
+
+ # TODO: What does "VM trace" even mean?
+ if (VMTRACE)
+ add_definitions(-DETH_VMTRACE)
+ endif ()
+
+ # CI Builds should provide (for user builds this is totally optional)
+ # -DBUILD_NUMBER - A number to identify the current build with. Becomes TWEAK component of project version.
+ # -DVERSION_SUFFIX - A string to append to the end of the version string where applicable.
+ if (NOT DEFINED BUILD_NUMBER)
+ # default is big so that local build is always considered greater
+ # and can easily replace CI build for for all platforms if needed.
+ # Windows max version component number is 65535
+ set(BUILD_NUMBER 65535)
+ endif()
+
+ # Suffix like "-rc1" e.t.c. to append to versions wherever needed.
+ if (NOT DEFINED VERSION_SUFFIX)
+ set(VERSION_SUFFIX "")
+ endif()
+
+ include(EthBuildInfo)
+ create_build_info()
+ print_config(${NAME})
+endmacro()
+
+macro(print_config NAME)
+ message("")
+ message("------------------------------------------------------------------------")
+ message("-- Configuring ${NAME}")
+ message("------------------------------------------------------------------------")
+ message("-- CMake ${CMAKE_VERSION} (${CMAKE_COMMAND})")
+ message("-- CMAKE_BUILD_TYPE Build type ${CMAKE_BUILD_TYPE}")
+ message("-- TARGET_PLATFORM Target platform ${CMAKE_SYSTEM_NAME}")
+ message("-- STATIC BUILD ${STATIC_BUILD}")
+ message("--------------------------------------------------------------- features")
+if (SUPPORT_CPUID)
+ message("-- Hardware identification support ${CPUID_FOUND}")
+endif()
+if (SUPPORT_CURL)
+ message("-- HTTP Request support ${CURL_FOUND}")
+endif()
+if (SUPPORT_VMTRACE)
+ message("-- VMTRACE VM execution tracing ${VMTRACE}")
+endif()
+ message("-- PROFILING Profiling support ${PROFILING}")
+if (SUPPORT_FATDB)
+ message("-- FATDB Full database exploring ${FATDB}")
+endif()
+if (SUPPORT_ROCKSDB)
+ message("-- ROCKSDB Prefer rocksdb to leveldb ${ROCKSDB}")
+endif()
+if (SUPPORT_PARANOID)
+ message("-- PARANOID - ${PARANOID}")
+endif()
+if (SUPPORT_MINIUPNPC)
+ message("-- MINIUPNPC - ${MINIUPNPC}")
+endif()
+ message("------------------------------------------------------------- components")
+if (SUPPORT_TESTS)
+ message("-- TESTS Build tests ${TESTS}")
+endif()
+if (SUPPORT_TOOLS)
+ message("-- TOOLS Build tools ${TOOLS}")
+endif()
+if (SUPPORT_EVMJIT)
+ message("-- EVMJIT Build LLVM-based JIT EVM ${EVMJIT}")
+endif()
+ message("------------------------------------------------------------------------")
+ message("")
+endmacro()
diff --git a/cmake/EthPolicy.cmake b/cmake/EthPolicy.cmake
new file mode 100644
index 0000000000..7f7b2d2490
--- /dev/null
+++ b/cmake/EthPolicy.cmake
@@ -0,0 +1,35 @@
+# it must be a macro cause policies have scopes
+# http://www.cmake.org/cmake/help/v3.0/command/cmake_policy.html
+macro (eth_policy)
+ # link_directories() treats paths relative to the source dir.
+ cmake_policy(SET CMP0015 NEW)
+
+ # let cmake autolink dependencies on windows
+ cmake_policy(SET CMP0020 NEW)
+
+ # CMake 2.8.12 and lower allowed the use of targets and files with double
+ # colons in target_link_libraries,
+ cmake_policy(SET CMP0028 NEW)
+
+ if (${CMAKE_VERSION} VERSION_GREATER 3.0)
+
+ # fix MACOSX_RPATH
+ cmake_policy(SET CMP0042 OLD)
+
+ # ignore COMPILE_DEFINITIONS_ properties
+ cmake_policy(SET CMP0043 OLD)
+
+ # allow VERSION argument in project()
+ cmake_policy(SET CMP0048 NEW)
+
+ endif()
+
+ if (${CMAKE_VERSION} VERSION_GREATER 3.1)
+
+ # do not interpret if() arguments as variables!
+ cmake_policy(SET CMP0054 NEW)
+
+ endif()
+
+endmacro()
+
diff --git a/cmake/EthUtils.cmake b/cmake/EthUtils.cmake
new file mode 100644
index 0000000000..1096bb61b1
--- /dev/null
+++ b/cmake/EthUtils.cmake
@@ -0,0 +1,114 @@
+#
+# renames the file if it is different from its destination
+include(CMakeParseArguments)
+#
+macro(replace_if_different SOURCE DST)
+ set(extra_macro_args ${ARGN})
+ set(options CREATE)
+ set(one_value_args)
+ set(multi_value_args)
+ cmake_parse_arguments(REPLACE_IF_DIFFERENT "${options}" "${one_value_args}" "${multi_value_args}" "${extra_macro_args}")
+
+ if (REPLACE_IF_DIFFERENT_CREATE AND (NOT (EXISTS "${DST}")))
+ file(WRITE "${DST}" "")
+ endif()
+
+ execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files "${SOURCE}" "${DST}" RESULT_VARIABLE DIFFERENT OUTPUT_QUIET ERROR_QUIET)
+
+ if (DIFFERENT)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E rename "${SOURCE}" "${DST}")
+ else()
+ execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${SOURCE}")
+ endif()
+endmacro()
+
+macro(eth_add_test NAME)
+
+ # parse arguments here
+ set(commands)
+ set(current_command "")
+ foreach (arg ${ARGN})
+ if (arg STREQUAL "ARGS")
+ if (current_command)
+ list(APPEND commands ${current_command})
+ endif()
+ set(current_command "")
+ else ()
+ set(current_command "${current_command} ${arg}")
+ endif()
+ endforeach(arg)
+ list(APPEND commands ${current_command})
+
+ message(STATUS "test: ${NAME} | ${commands}")
+
+ # create tests
+ set(index 0)
+ list(LENGTH commands count)
+ while (index LESS count)
+ list(GET commands ${index} test_arguments)
+
+ set(run_test "--run_test=${NAME}")
+ add_test(NAME "${NAME}.${index}" COMMAND testeth ${run_test} ${test_arguments})
+
+ math(EXPR index "${index} + 1")
+ endwhile(index LESS count)
+
+ # add target to run them
+ add_custom_target("test.${NAME}"
+ DEPENDS testeth
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${CMAKE_COMMAND} -DETH_TEST_NAME="${NAME}" -DCTEST_COMMAND="${CTEST_COMMAND}" -P "${ETH_SCRIPTS_DIR}/runtest.cmake"
+ )
+
+endmacro()
+
+# Creates C resources file from files
+function(eth_add_resources RESOURCE_FILE OUT_FILE ETH_RES_DIR)
+ include("${RESOURCE_FILE}")
+ set(OUTPUT "${ETH_RESOURCE_LOCATION}/${ETH_RESOURCE_NAME}.hpp")
+ #message(FATAL_ERROR "res:! ${ETH_RESOURCE_LOCATION}")
+ include_directories("${ETH_RESOURCE_LOCATION}")
+ set(${OUT_FILE} "${OUTPUT}" PARENT_SCOPE)
+
+ set(filenames "${RESOURCE_FILE}")
+ list(APPEND filenames "${ETH_SCRIPTS_DIR}/resources.cmake")
+ foreach(resource ${ETH_RESOURCES})
+ list(APPEND filenames "${${resource}}")
+ endforeach(resource)
+
+ add_custom_command(OUTPUT ${OUTPUT}
+ COMMAND ${CMAKE_COMMAND} -DETH_RES_FILE="${RESOURCE_FILE}" -DETH_RES_DIR="${ETH_RES_DIR}" -P "${ETH_SCRIPTS_DIR}/resources.cmake"
+ DEPENDS ${filenames}
+ )
+endfunction()
+
+macro(eth_default_option O DEF)
+ if (DEFINED ${O})
+ if (${${O}})
+ set(${O} ON)
+ else ()
+ set(${O} OFF)
+ endif()
+ else ()
+ set(${O} ${DEF})
+ endif()
+endmacro()
+
+# In Windows split repositories build we need to be checking whether or not
+# Debug/Release or both versions were built for the config phase to run smoothly
+macro(eth_check_library_link L)
+ if (${${L}_LIBRARY} AND ${${L}_LIBRARY} EQUAL "${L}_LIBRARY-NOTFOUND")
+ unset(${${L}_LIBRARY})
+ endif()
+ if (${${L}_LIBRARY_DEBUG} AND ${${L}_LIBRARY_DEBUG} EQUAL "${L}_LIBRARY_DEBUG-NOTFOUND")
+ unset(${${L}_LIBRARY_DEBUG})
+ endif()
+ if (${${L}_LIBRARY} AND ${${L}_LIBRARY_DEBUG})
+ set(${L}_LIBRARIES optimized ${${L}_LIBRARY} debug ${${L}_LIBRARY_DEBUG})
+ elseif (${${L}_LIBRARY})
+ set(${L}_LIBRARIES ${${L}_LIBRARY})
+ elseif (${${L}_LIBRARY_DEBUG})
+ set(${L}_LIBRARIES ${${L}_LIBRARY_DEBUG})
+ endif()
+endmacro()
+
diff --git a/cmake/FindCURL.cmake b/cmake/FindCURL.cmake
new file mode 100644
index 0000000000..f3c1e28ff0
--- /dev/null
+++ b/cmake/FindCURL.cmake
@@ -0,0 +1,57 @@
+# Find CURL
+#
+# Find the curl includes and library
+#
+# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH
+#
+# This module defines
+# CURL_INCLUDE_DIRS, where to find header, etc.
+# CURL_LIBRARIES, the libraries needed to use curl.
+# CURL_FOUND, If false, do not try to use curl.
+
+# only look in default directories
+find_path(
+ CURL_INCLUDE_DIR
+ NAMES curl/curl.h
+ DOC "curl include dir"
+)
+
+find_library(
+ CURL_LIBRARY
+ # names from cmake's FindCURL
+ NAMES curl curllib libcurl_imp curllib_static libcurl
+ DOC "curl library"
+)
+
+set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
+set(CURL_LIBRARIES ${CURL_LIBRARY})
+
+# debug library on windows
+# same naming convention as in qt (appending debug library with d)
+# boost is using the same "hack" as us with "optimized" and "debug"
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+
+ find_library(
+ CURL_LIBRARY_DEBUG
+ NAMES curld libcurld
+ DOC "curl debug library"
+ )
+
+ set(CURL_LIBRARIES optimized ${CURL_LIBRARIES} debug ${CURL_LIBRARY_DEBUG})
+
+ # prepare dlls
+ string(REPLACE ".lib" ".dll" CURL_DLL "${CURL_LIBRARY}")
+ string(REPLACE "/lib/" "/bin/" CURL_DLL "${CURL_DLL}")
+ string(REPLACE ".lib" ".dll" CURL_DLL_DEBUG "${CURL_LIBRARY_DEBUG}")
+ string(REPLACE "/lib/" "/bin/" CURL_DLL_DEBUG "${CURL_DLL_DEBUG}")
+ set(CURL_DLLS optimized "${CURL_DLL}" debug "${CURL_DLL_DEBUG}")
+
+endif()
+
+# handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE
+# if all listed variables are TRUE, hide their existence from configuration view
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(CURL DEFAULT_MSG
+ CURL_LIBRARY CURL_INCLUDE_DIR)
+mark_as_advanced (CURL_INCLUDE_DIR CURL_LIBRARY)
+
diff --git a/cmake/FindCpuid.cmake b/cmake/FindCpuid.cmake
new file mode 100644
index 0000000000..53d03de662
--- /dev/null
+++ b/cmake/FindCpuid.cmake
@@ -0,0 +1,33 @@
+# Find libcpuid
+#
+# Find the libcpuid includes and library
+#
+# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH
+#
+# This module defines
+# CPUID_INCLUDE_DIRS, where to find header, etc.
+# CPUID_LIBRARIES, the libraries needed to use cpuid.
+# CPUID_FOUND, If false, do not try to use cpuid.
+
+# only look in default directories
+find_path(
+ CPUID_INCLUDE_DIR
+ NAMES libcpuid/libcpuid.h
+ DOC "libcpuid include dir"
+ )
+
+find_library(
+ CPUID_LIBRARY
+ NAMES cpuid
+ DOC "libcpuid library"
+ )
+
+set(CPUID_INCLUDE_DIRS ${CPUID_INCLUDE_DIR})
+set(CPUID_LIBRARIES ${CPUID_LIBRARY})
+
+# handle the QUIETLY and REQUIRED arguments and set CPUID_FOUND to TRUE
+# if all listed variables are TRUE, hide their existence from configuration view
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Cpuid DEFAULT_MSG CPUID_LIBRARY CPUID_INCLUDE_DIR)
+mark_as_advanced (CPUID_INCLUDE_DIR CPUID_LIBRARY)
+
diff --git a/cmake/FindDev.cmake b/cmake/FindDev.cmake
new file mode 100644
index 0000000000..bf84d5c1d9
--- /dev/null
+++ b/cmake/FindDev.cmake
@@ -0,0 +1,69 @@
+#------------------------------------------------------------------------------
+# CMake helper for libdevcore, libdevcrypto and libp2p modules.
+#
+# This module defines
+# Dev_XXX_LIBRARIES, the libraries needed to use ethereum.
+# Dev_INCLUDE_DIRS
+#
+# The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org
+#
+# ------------------------------------------------------------------------------
+# This file is part of cpp-ethereum.
+#
+# cpp-ethereum is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cpp-ethereum is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cpp-ethereum. If not, see
+#
+# (c) 2014-2016 cpp-ethereum contributors.
+#------------------------------------------------------------------------------
+
+include(EthUtils)
+set(LIBS devcore;devcrypto;p2p;contract)
+
+set(Dev_INCLUDE_DIRS "${CPP_ETHEREUM_DIR}")
+
+# if the project is a subset of main cpp-ethereum project
+# use same pattern for variables as Boost uses
+if ((DEFINED cpp-ethereum_VERSION) OR (DEFINED dev_VERSION))
+
+ foreach (l ${LIBS})
+ string(TOUPPER ${l} L)
+ set ("Dev_${L}_LIBRARIES" ${l})
+ endforeach()
+
+else()
+
+ foreach (l ${LIBS})
+ string(TOUPPER ${l} L)
+
+ find_library(Dev_${L}_LIBRARY
+ NAMES ${l}
+ PATHS ${CMAKE_LIBRARY_PATH}
+ PATH_SUFFIXES "lib${l}" "${l}" "lib${l}/Debug" "lib${l}/Release"
+ NO_DEFAULT_PATH
+ )
+
+ set(Dev_${L}_LIBRARIES ${Dev_${L}_LIBRARY})
+
+ if (MSVC)
+ find_library(Dev_${L}_LIBRARY_DEBUG
+ NAMES ${l}
+ PATHS ${CMAKE_LIBRARY_PATH}
+ PATH_SUFFIXES "lib${l}/Debug"
+ NO_DEFAULT_PATH
+ )
+ eth_check_library_link(Dev_${L})
+ endif()
+ endforeach()
+
+endif()
+
diff --git a/cmake/FindEth.cmake b/cmake/FindEth.cmake
new file mode 100644
index 0000000000..5dde3e8779
--- /dev/null
+++ b/cmake/FindEth.cmake
@@ -0,0 +1,76 @@
+#------------------------------------------------------------------------------
+# CMake helper for the majority of the cpp-ethereum modules.
+#
+# This module defines
+# ETH_XXX_LIBRARIES, the libraries needed to use ethereum.
+# ETH_FOUND, If false, do not try to use ethereum.
+# TODO: ETH_INCLUDE_DIRS
+#
+# The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org
+#
+# ------------------------------------------------------------------------------
+# This file is part of cpp-ethereum.
+#
+# cpp-ethereum is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cpp-ethereum is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cpp-ethereum. If not, see
+#
+# (c) 2014-2016 cpp-ethereum contributors.
+#------------------------------------------------------------------------------
+
+include(EthUtils)
+if (ODBC)
+ set(LIBS ethashseal;ethereum;evm;ethcore;evmcore;ethash-cl;ethash;evmjit;testutils;pbftseal;raftseal;singlepoint;odbc)
+else ()
+ set(LIBS ethashseal;ethereum;evm;ethcore;evmcore;ethash-cl;ethash;evmjit;testutils;pbftseal;raftseal;singlepoint)
+endif()
+set(Eth_INCLUDE_DIRS "${CPP_ETHEREUM_DIR}")
+
+# if the project is a subset of main cpp-ethereum project
+# use same pattern for variables as Boost uses
+if ((DEFINED cpp-ethereum_VERSION) OR (DEFINED ethereum_VERSION))
+
+ foreach (l ${LIBS})
+ string(TOUPPER ${l} L)
+ set ("Eth_${L}_LIBRARIES" ${l})
+ endforeach()
+
+else()
+
+ foreach (l ${LIBS})
+ string(TOUPPER ${l} L)
+
+ find_library(Eth_${L}_LIBRARY
+ NAMES ${l}
+ PATHS ${CMAKE_LIBRARY_PATH}
+ PATH_SUFFIXES "lib${l}" "${l}" "lib${l}/Debug" "lib${l}/Release"
+ # libevmjit is nested...
+ "evmjit/libevmjit" "evmjit/libevmjit/Release"
+ NO_DEFAULT_PATH
+ )
+
+ set(Eth_${L}_LIBRARIES ${Eth_${L}_LIBRARY})
+
+ if (MSVC)
+ find_library(Eth_${L}_LIBRARY_DEBUG
+ NAMES ${l}
+ PATHS ${CMAKE_LIBRARY_PATH}
+ PATH_SUFFIXES "lib${l}/Debug"
+ # libevmjit is nested...
+ "evmjit/libevmjit/Debug"
+ NO_DEFAULT_PATH
+ )
+ eth_check_library_link(Eth_${L})
+ endif()
+ endforeach()
+
+endif()
diff --git a/cmake/FindGmp.cmake b/cmake/FindGmp.cmake
new file mode 100644
index 0000000000..76af9fcb65
--- /dev/null
+++ b/cmake/FindGmp.cmake
@@ -0,0 +1,34 @@
+# Find gmp
+#
+# Find the gmp includes and library
+#
+# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH
+#
+# This module defines
+# GMP_INCLUDE_DIRS, where to find header, etc.
+# GMP_LIBRARIES, the libraries needed to use gmp.
+# GMP_FOUND, If false, do not try to use gmp.
+
+# only look in default directories
+find_path(
+ GMP_INCLUDE_DIR
+ NAMES gmp.h
+ DOC "gmp include dir"
+)
+
+find_library(
+ GMP_LIBRARY
+ NAMES gmp
+ DOC "gmp library"
+)
+
+set(GMP_INCLUDE_DIRS ${GMP_INCLUDE_DIR})
+set(GMP_LIBRARIES ${GMP_LIBRARY})
+
+# handle the QUIETLY and REQUIRED arguments and set GMP_FOUND to TRUE
+# if all listed variables are TRUE, hide their existence from configuration view
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(gmp DEFAULT_MSG
+ GMP_LIBRARY GMP_INCLUDE_DIR)
+mark_as_advanced (GMP_INCLUDE_DIR GMP_LIBRARY)
+
diff --git a/cmake/FindLevelDB.cmake b/cmake/FindLevelDB.cmake
new file mode 100644
index 0000000000..9a609c811e
--- /dev/null
+++ b/cmake/FindLevelDB.cmake
@@ -0,0 +1,61 @@
+# Find leveldb
+#
+# Find the leveldb includes and library
+#
+# if you need to add a custom library search path, do it via via CMAKE_PREFIX_PATH
+#
+# This module defines
+# LEVELDB_INCLUDE_DIRS, where to find header, etc.
+# LEVELDB_LIBRARIES, the libraries needed to use leveldb.
+# LEVELDB_FOUND, If false, do not try to use leveldb.
+
+# only look in default directories
+find_path(
+ LEVELDB_INCLUDE_DIR
+ NAMES leveldb/db.h
+ DOC "leveldb include dir"
+)
+
+find_library(
+ LEVELDB_LIBRARY
+ NAMES leveldb
+ DOC "leveldb library"
+)
+
+set(LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR})
+set(LEVELDB_LIBRARIES ${LEVELDB_LIBRARY})
+
+# When we're static linking (at least on OS X), leveldb also drags in snappy.
+# This might be due to some dependency within leveldb which would be dead-code
+# stripped if we were using a static lib for leveldb. We aren't (yet), because
+# we only have partial static-linkage on OS X so far.
+if (NOT BUILD_SHARED_LIBS AND APPLE)
+ find_path(SNAPPY_INCLUDE_DIR snappy.h PATH_SUFFIXES snappy)
+ find_library(SNAPPY_LIBRARY snappy)
+ set(LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR} ${SNAPPY_INCLUDE_DIR})
+ set(LEVELDB_LIBRARIES ${LEVELDB_LIBRARY} ${SNAPPY_LIBRARY})
+endif()
+
+# debug library on windows
+# same naming convention as in qt (appending debug library with d)
+# boost is using the same "hack" as us with "optimized" and "debug"
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+
+ find_library(
+ LEVELDB_LIBRARY_DEBUG
+ NAMES leveldbd
+ DOC "leveldb debug library"
+ )
+
+ list(APPEND LEVELDB_LIBRARIES "shlwapi")
+ list(APPEND LEVELDB_LIBRARY_DEBUG "shlwapi")
+ set(LEVELDB_LIBRARIES optimized ${LEVELDB_LIBRARIES} debug ${LEVELDB_LIBRARY_DEBUG})
+endif()
+
+# handle the QUIETLY and REQUIRED arguments and set LEVELDB_FOUND to TRUE
+# if all listed variables are TRUE, hide their existence from configuration view
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(leveldb DEFAULT_MSG
+ LEVELDB_LIBRARY LEVELDB_INCLUDE_DIR)
+mark_as_advanced (LEVELDB_INCLUDE_DIR LEVELDB_LIBRARY)
+
diff --git a/cmake/FindMHD.cmake b/cmake/FindMHD.cmake
new file mode 100644
index 0000000000..c72d675c9b
--- /dev/null
+++ b/cmake/FindMHD.cmake
@@ -0,0 +1,54 @@
+# Find microhttpd
+#
+# Find the microhttpd includes and library
+#
+# if you need to add a custom library search path, do it via via CMAKE_PREFIX_PATH
+#
+# This module defines
+# MHD_INCLUDE_DIRS, where to find header, etc.
+# MHD_LIBRARIES, the libraries needed to use jsoncpp.
+# MHD_FOUND, If false, do not try to use jsoncpp.
+
+find_path(
+ MHD_INCLUDE_DIR
+ NAMES microhttpd.h
+ DOC "microhttpd include dir"
+)
+
+find_library(
+ MHD_LIBRARY
+ NAMES microhttpd microhttpd-10 libmicrohttpd libmicrohttpd-dll
+ DOC "microhttpd library"
+)
+
+set(MHD_INCLUDE_DIRS ${MHD_INCLUDE_DIR})
+set(MHD_LIBRARIES ${MHD_LIBRARY})
+
+# debug library on windows
+# same naming convention as in QT (appending debug library with d)
+# boost is using the same "hack" as us with "optimized" and "debug"
+# official MHD project actually uses _d suffix
+if (MSVC)
+
+ find_library(
+ MHD_LIBRARY_DEBUG
+ NAMES microhttpd_d microhttpd-10_d libmicrohttpd_d libmicrohttpd-dll_d
+ DOC "mhd debug library"
+ )
+
+ set(MHD_LIBRARIES optimized ${MHD_LIBRARIES} debug ${MHD_LIBRARY_DEBUG})
+
+ # prepare dlls
+ string(REPLACE ".lib" ".dll" MHD_DLL "${MHD_LIBRARY}")
+ string(REPLACE "/lib/" "/bin/" MHD_DLL "${MHD_DLL}")
+ string(REPLACE ".lib" ".dll" MHD_DLL_DEBUG "${MHD_LIBRARY_DEBUG}")
+ string(REPLACE "/lib/" "/bin/" MHD_DLL_DEBUG "${MHD_DLL_DEBUG}")
+ set(MHD_DLLS optimized ${MHD_DLL} debug "${MHD_DLL_DEBUG}")
+
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(mhd DEFAULT_MSG
+ MHD_LIBRARY MHD_INCLUDE_DIR)
+
+mark_as_advanced(MHD_INCLUDE_DIR MHD_LIBRARY)
diff --git a/cmake/FindMiniupnpc.cmake b/cmake/FindMiniupnpc.cmake
new file mode 100644
index 0000000000..c0b086bc50
--- /dev/null
+++ b/cmake/FindMiniupnpc.cmake
@@ -0,0 +1,49 @@
+# Find miniupnpc
+#
+# Find the miniupnpc includes and library
+#
+# if you nee to add a custom library search path, do it via CMAKE_PREFIX_PATH
+#
+# This module defines
+# MINIUPNPC_INCLUDE_DIRS, where to find header, etc.
+# MINIUPNPC_LIBRARIES, the libraries needed to use miniupnpc.
+# MINIUPNPC_FOUND, If false, do not try to use miniupnpc.
+
+# only look in default directories
+find_path(
+ MINIUPNPC_INCLUDE_DIR
+ NAMES miniupnpc/miniupnpc.h
+ DOC "miniupnpc include dir"
+)
+
+find_library(
+ MINIUPNPC_LIBRARY
+ NAMES miniupnpc
+ DOC "miniupnpc library"
+)
+
+set(MINIUPNPC_INCLUDE_DIRS ${MINIUPNPC_INCLUDE_DIR})
+set(MINIUPNPC_LIBRARIES ${MINIUPNPC_LIBRARY})
+
+# debug library on windows
+# same naming convention as in QT (appending debug library with d)
+# boost is using the same "hack" as us with "optimized" and "debug"
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+
+ find_library(
+ MINIUPNPC_LIBRARY_DEBUG
+ NAMES miniupnpcd
+ DOC "miniupnpc debug library"
+ )
+
+ set(MINIUPNPC_LIBRARIES "iphlpapi" optimized ${MINIUPNPC_LIBRARIES} debug ${MINIUPNPC_LIBRARY_DEBUG})
+
+endif()
+
+# handle the QUIETLY and REQUIRED arguments and set MINIUPNPC_FOUND to TRUE
+# if all listed variables are TRUE, hide their existence from configuration view
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(miniupnpc DEFAULT_MSG
+ MINIUPNPC_LIBRARY MINIUPNPC_INCLUDE_DIR)
+mark_as_advanced (MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY)
+
diff --git a/cmake/FindPackageHandleStandardArgs.cmake b/cmake/FindPackageHandleStandardArgs.cmake
new file mode 100644
index 0000000000..228ff0160f
--- /dev/null
+++ b/cmake/FindPackageHandleStandardArgs.cmake
@@ -0,0 +1,382 @@
+#.rst:
+# FindPackageHandleStandardArgs
+# -----------------------------
+#
+#
+#
+# FIND_PACKAGE_HANDLE_STANDARD_ARGS( ... )
+#
+# This function is intended to be used in FindXXX.cmake modules files.
+# It handles the REQUIRED, QUIET and version-related arguments to
+# find_package(). It also sets the _FOUND variable. The
+# package is considered found if all variables ... listed contain
+# valid results, e.g. valid filepaths.
+#
+# There are two modes of this function. The first argument in both
+# modes is the name of the Find-module where it is called (in original
+# casing).
+#
+# The first simple mode looks like this:
+#
+# ::
+#
+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+# (DEFAULT_MSG|"Custom failure message") ... )
+#
+# If the variables to are all valid, then
+# _FOUND will be set to TRUE. If DEFAULT_MSG is given
+# as second argument, then the function will generate itself useful
+# success and error messages. You can also supply a custom error
+# message for the failure case. This is not recommended.
+#
+# The second mode is more powerful and also supports version checking:
+#
+# ::
+#
+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME
+# [FOUND_VAR ]
+# [REQUIRED_VARS ...]
+# [VERSION_VAR ]
+# [HANDLE_COMPONENTS]
+# [CONFIG_MODE]
+# [FAIL_MESSAGE "Custom failure message"] )
+#
+# In this mode, the name of the result-variable can be set either to
+# either _FOUND or _FOUND using the
+# FOUND_VAR option. Other names for the result-variable are not
+# allowed. So for a Find-module named FindFooBar.cmake, the two
+# possible names are FooBar_FOUND and FOOBAR_FOUND. It is recommended
+# to use the original case version. If the FOUND_VAR option is not
+# used, the default is _FOUND.
+#
+# As in the simple mode, if through are all valid,
+# _FOUND will be set to TRUE. After REQUIRED_VARS the
+# variables which are required for this package are listed. Following
+# VERSION_VAR the name of the variable can be specified which holds the
+# version of the package which has been found. If this is done, this
+# version will be checked against the (potentially) specified required
+# version used in the find_package() call. The EXACT keyword is also
+# handled. The default messages include information about the required
+# version and the version which has been actually found, both if the
+# version is ok or not. If the package supports components, use the
+# HANDLE_COMPONENTS option to enable handling them. In this case,
+# find_package_handle_standard_args() will report which components have
+# been found and which are missing, and the _FOUND variable
+# will be set to FALSE if any of the required components (i.e. not the
+# ones listed after OPTIONAL_COMPONENTS) are missing. Use the option
+# CONFIG_MODE if your FindXXX.cmake module is a wrapper for a
+# find_package(... NO_MODULE) call. In this case VERSION_VAR will be
+# set to _VERSION and the macro will automatically check whether
+# the Config module was found. Via FAIL_MESSAGE a custom failure
+# message can be specified, if this is not used, the default message
+# will be displayed.
+#
+# Example for mode 1:
+#
+# ::
+#
+# find_package_handle_standard_args(LibXml2 DEFAULT_MSG
+# LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
+#
+#
+#
+# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and
+# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to
+# TRUE. If it is not found and REQUIRED was used, it fails with
+# FATAL_ERROR, independent whether QUIET was used or not. If it is
+# found, success will be reported, including the content of . On
+# repeated Cmake runs, the same message won't be printed again.
+#
+# Example for mode 2:
+#
+# ::
+#
+# find_package_handle_standard_args(LibXslt
+# FOUND_VAR LibXslt_FOUND
+# REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS
+# VERSION_VAR LibXslt_VERSION_STRING)
+#
+# In this case, LibXslt is considered to be found if the variable(s)
+# listed after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and
+# LibXslt_INCLUDE_DIRS in this case. The result will then be stored in
+# LibXslt_FOUND . Also the version of LibXslt will be checked by using
+# the version contained in LibXslt_VERSION_STRING. Since no
+# FAIL_MESSAGE is given, the default messages will be printed.
+#
+# Another example for mode 2:
+#
+# ::
+#
+# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4)
+# find_package_handle_standard_args(Automoc4 CONFIG_MODE)
+#
+# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4
+# NO_MODULE) and adds an additional search directory for automoc4. Here
+# the result will be stored in AUTOMOC4_FOUND. The following
+# FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper
+# success/error message.
+
+#=============================================================================
+# Copyright 2007-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
+
+# internal helper macro
+macro(_FPHSA_FAILURE_MESSAGE _msg)
+ if (${_NAME}_FIND_REQUIRED)
+ message(FATAL_ERROR "${_msg}")
+ else ()
+ if (NOT ${_NAME}_FIND_QUIETLY)
+ message(STATUS "${_msg}")
+ endif ()
+ endif ()
+endmacro()
+
+
+# internal helper macro to generate the failure message when used in CONFIG_MODE:
+macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
+ # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
+ if(${_NAME}_CONFIG)
+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
+ else()
+ # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version.
+ # List them all in the error message:
+ if(${_NAME}_CONSIDERED_CONFIGS)
+ set(configsText "")
+ list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount)
+ math(EXPR configsCount "${configsCount} - 1")
+ foreach(currentConfigIndex RANGE ${configsCount})
+ list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
+ list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
+ set(configsText "${configsText} ${filename} (version ${version})\n")
+ endforeach()
+ if (${_NAME}_NOT_FOUND_MESSAGE)
+ set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n")
+ endif()
+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}")
+
+ else()
+ # Simple case: No Config-file was found at all:
+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}")
+ endif()
+ endif()
+endmacro()
+
+
+function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
+
+# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
+# new extended or in the "old" mode:
+ set(options CONFIG_MODE HANDLE_COMPONENTS)
+ set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR)
+ set(multiValueArgs REQUIRED_VARS)
+ set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
+ list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
+
+ if(${INDEX} EQUAL -1)
+ set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
+ set(FPHSA_REQUIRED_VARS ${ARGN})
+ set(FPHSA_VERSION_VAR)
+ else()
+
+ CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
+
+ if(FPHSA_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
+ endif()
+
+ if(NOT FPHSA_FAIL_MESSAGE)
+ set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
+ endif()
+ endif()
+
+# now that we collected all arguments, process them
+
+ if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG")
+ set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
+ endif()
+
+ # In config-mode, we rely on the variable _CONFIG, which is set by find_package()
+ # when it successfully found the config-file, including version checking:
+ if(FPHSA_CONFIG_MODE)
+ list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
+ list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
+ set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
+ endif()
+
+ if(NOT FPHSA_REQUIRED_VARS)
+ message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
+ endif()
+
+ list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
+
+ string(TOUPPER ${_NAME} _NAME_UPPER)
+ string(TOLOWER ${_NAME} _NAME_LOWER)
+
+ if(FPHSA_FOUND_VAR)
+ if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$")
+ set(_FOUND_VAR ${FPHSA_FOUND_VAR})
+ else()
+ message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.")
+ endif()
+ else()
+ set(_FOUND_VAR ${_NAME_UPPER}_FOUND)
+ endif()
+
+ # collect all variables which were not found, so they can be printed, so the
+ # user knows better what went wrong (#6375)
+ set(MISSING_VARS "")
+ set(DETAILS "")
+ # check if all passed variables are valid
+ unset(${_FOUND_VAR})
+ foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS})
+ if(NOT ${_CURRENT_VAR})
+ set(${_FOUND_VAR} FALSE)
+ set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
+ else()
+ set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
+ endif()
+ endforeach()
+ if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE")
+ set(${_FOUND_VAR} TRUE)
+ endif()
+
+ # component handling
+ unset(FOUND_COMPONENTS_MSG)
+ unset(MISSING_COMPONENTS_MSG)
+
+ if(FPHSA_HANDLE_COMPONENTS)
+ foreach(comp ${${_NAME}_FIND_COMPONENTS})
+ if(${_NAME}_${comp}_FOUND)
+
+ if(NOT DEFINED FOUND_COMPONENTS_MSG)
+ set(FOUND_COMPONENTS_MSG "found components: ")
+ endif()
+ set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}")
+
+ else()
+
+ if(NOT DEFINED MISSING_COMPONENTS_MSG)
+ set(MISSING_COMPONENTS_MSG "missing components: ")
+ endif()
+ set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}")
+
+ if(${_NAME}_FIND_REQUIRED_${comp})
+ set(${_FOUND_VAR} FALSE)
+ set(MISSING_VARS "${MISSING_VARS} ${comp}")
+ endif()
+
+ endif()
+ endforeach()
+ set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}")
+ set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]")
+ endif()
+
+ # version handling:
+ set(VERSION_MSG "")
+ set(VERSION_OK TRUE)
+ set(VERSION ${${FPHSA_VERSION_VAR}})
+
+ # check with DEFINED here as the requested or found version may be "0"
+ if (DEFINED ${_NAME}_FIND_VERSION)
+ if(DEFINED ${FPHSA_VERSION_VAR})
+
+ if(${_NAME}_FIND_VERSION_EXACT) # exact version required
+ # count the dots in the version string
+ string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${VERSION}")
+ # add one dot because there is one dot more than there are components
+ string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS)
+ if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT)
+ # Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT
+ # is at most 4 here. Therefore a simple lookup table is used.
+ if (${_NAME}_FIND_VERSION_COUNT EQUAL 1)
+ set(_VERSION_REGEX "[^.]*")
+ elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2)
+ set(_VERSION_REGEX "[^.]*\\.[^.]*")
+ elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3)
+ set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*")
+ else ()
+ set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*")
+ endif ()
+ string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${VERSION}")
+ unset(_VERSION_REGEX)
+ if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD)
+ set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
+ set(VERSION_OK FALSE)
+ else ()
+ set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
+ endif ()
+ unset(_VERSION_HEAD)
+ else ()
+ if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}")
+ set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
+ set(VERSION_OK FALSE)
+ else ()
+ set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
+ endif ()
+ endif ()
+ unset(_VERSION_DOTS)
+
+ else() # minimum version specified:
+ if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}")
+ set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
+ set(VERSION_OK FALSE)
+ else ()
+ set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
+ endif ()
+ endif()
+
+ else()
+
+ # if the package was not found, but a version was given, add that to the output:
+ if(${_NAME}_FIND_VERSION_EXACT)
+ set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")")
+ else()
+ set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")")
+ endif()
+
+ endif()
+ else ()
+ if(VERSION)
+ set(VERSION_MSG "(found version \"${VERSION}\")")
+ endif()
+ endif ()
+
+ if(VERSION_OK)
+ set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]")
+ else()
+ set(${_FOUND_VAR} FALSE)
+ endif()
+
+
+ # print the result:
+ if (${_FOUND_VAR})
+ FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}")
+ else ()
+
+ if(FPHSA_CONFIG_MODE)
+ _FPHSA_HANDLE_FAILURE_CONFIG_MODE()
+ else()
+ if(NOT VERSION_OK)
+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
+ else()
+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
+ endif()
+ endif()
+
+ endif ()
+
+ set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE)
+
+endfunction()
diff --git a/cmake/FindPackageMessage.cmake b/cmake/FindPackageMessage.cmake
new file mode 100644
index 0000000000..73fef9af72
--- /dev/null
+++ b/cmake/FindPackageMessage.cmake
@@ -0,0 +1,57 @@
+#.rst:
+# FindPackageMessage
+# ------------------
+#
+#
+#
+# FIND_PACKAGE_MESSAGE( "message for user" "find result details")
+#
+# This macro is intended to be used in FindXXX.cmake modules files. It
+# will print a message once for each unique find result. This is useful
+# for telling the user where a package was found. The first argument
+# specifies the name (XXX) of the package. The second argument
+# specifies the message to display. The third argument lists details
+# about the find result so that if they change the message will be
+# displayed again. The macro also obeys the QUIET argument to the
+# find_package command.
+#
+# Example:
+#
+# ::
+#
+# if(X11_FOUND)
+# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}"
+# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
+# else()
+# ...
+# endif()
+
+#=============================================================================
+# Copyright 2008-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+function(FIND_PACKAGE_MESSAGE pkg msg details)
+ # Avoid printing a message repeatedly for the same find result.
+ if(NOT ${pkg}_FIND_QUIETLY)
+ string(REPLACE "\n" "" details "${details}")
+ set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
+ if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
+ # The message has not yet been printed.
+ message(STATUS "${msg}")
+
+ # Save the find details in the cache to avoid printing the same
+ # message again.
+ set("${DETAILS_VAR}" "${details}"
+ CACHE INTERNAL "Details about finding ${pkg}")
+ endif()
+ endif()
+endfunction()
diff --git a/cmake/FindRocksDB.cmake b/cmake/FindRocksDB.cmake
new file mode 100644
index 0000000000..5ffb5da55e
--- /dev/null
+++ b/cmake/FindRocksDB.cmake
@@ -0,0 +1,49 @@
+# Find rocksdb
+#
+# Find the rocksdb includes and library
+#
+# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH
+#
+# This module defines
+# ROCKSDB_INCLUDE_DIRS, where to find header, etc.
+# ROCKSDB_LIBRARIES, the libraries needed to use rocksdb.
+# ROCKSDB_FOUND, If false, do not try to use rocksdb.
+
+# only look in default directories
+find_path(
+ ROCKSDB_INCLUDE_DIR
+ NAMES rocksdb/db.h
+ DOC "rocksdb include dir"
+)
+
+find_library(
+ ROCKSDB_LIBRARY
+ NAMES rocksdb
+ DOC "rocksdb library"
+)
+
+set(ROCKSDB_INCLUDE_DIRS ${ROCKSDB_INCLUDE_DIR})
+set(ROCKSDB_LIBRARIES ${ROCKSDB_LIBRARY})
+
+# debug library on windows
+# same naming convention as in qt (appending debug library with d)
+# boost is using the same "hack" as us with "optimized" and "debug"
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+
+ find_library(
+ ROCKSDB_LIBRARY_DEBUG
+ NAMES rocksdbd
+ DOC "rocksdb debug library"
+ )
+
+ set(ROCKSDB_LIBRARIES optimized ${ROCKSDB_LIBRARIES} debug ${ROCKSDB_LIBRARY_DEBUG})
+
+endif()
+
+# handle the QUIETLY and REQUIRED arguments and set ROCKSDB_FOUND to TRUE
+# if all listed variables are TRUE, hide their existence from configuration view
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(RocksDB DEFAULT_MSG
+ ROCKS_DB_LIBRARY ROCKSDB_INCLUDE_DIR)
+mark_as_advanced (ROCKSDB_INCLUDE_DIR ROCKSDB_LIBRARY)
+
diff --git a/cmake/FindSSH2.cmake b/cmake/FindSSH2.cmake
new file mode 100644
index 0000000000..fe51f9ff0e
--- /dev/null
+++ b/cmake/FindSSH2.cmake
@@ -0,0 +1,30 @@
+# - Try to find the ssh2 libssh2 library
+# Once done this will define
+#
+# SSH2_FOUND - system has the SSH2 libssh2 library
+# SSH2_INCLUDE_DIR - the SSH2 libssh2 include directory
+# SSH2_LIBRARIES - The libraries needed to use SSH2 libssh2
+
+# only look in default directories
+find_path(
+ SSH2_INCLUDE_DIR
+ NAMES libssh2.h
+ DOC "ssh2 include dir"
+)
+
+find_library(
+ SSH2_LIBRARY
+ NAMES ssh2 libssh2
+ DOC "ssh2 library"
+)
+
+set(SSH2_INCLUDE_DIRS ${SSH2_INCLUDE_DIR})
+set(SSH2_LIBRARIES ${SSH2_LIBRARY})
+
+# handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE
+# if all listed variables are TRUE, hide their existence from configuration view
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SSH2 DEFAULT_MSG
+ SSH2_LIBRARY SSH2_INCLUDE_DIR)
+mark_as_advanced (SSH2_INCLUDE_DIR SSH2_LIBRARY)
+
diff --git a/cmake/FindUtils.cmake b/cmake/FindUtils.cmake
new file mode 100644
index 0000000000..e26db96394
--- /dev/null
+++ b/cmake/FindUtils.cmake
@@ -0,0 +1,70 @@
+#------------------------------------------------------------------------------
+# CMake helper for the "utils" modules, which are orphaned external
+# packages - secp256k1, libscrypt and json_spirit.
+#
+# This module defines
+# Utils_XXX_LIBRARIES, the libraries needed to use ethereum.
+# Utils_INCLUDE_DIRS
+#
+# The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org
+#
+# ------------------------------------------------------------------------------
+# This file is part of cpp-ethereum.
+#
+# cpp-ethereum is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cpp-ethereum is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cpp-ethereum. If not, see
+#
+# (c) 2014-2016 cpp-ethereum contributors.
+#------------------------------------------------------------------------------
+
+include(EthUtils)
+set(LIBS secp256k1;scrypt)
+
+set(Utils_INCLUDE_DIRS "${CPP_ETHEREUM_DIR}")
+
+# if the project is a subset of main cpp-ethereum project
+# use same pattern for variables as Boost uses
+if (DEFINED cpp-ethereum_VERSION)
+
+ foreach (l ${LIBS})
+ string(TOUPPER ${l} L)
+ set ("Utils_${L}_LIBRARIES" ${l})
+ endforeach()
+
+else()
+
+ foreach (l ${LIBS})
+ string(TOUPPER ${l} L)
+
+ find_library(Utils_${L}_LIBRARY
+ NAMES ${l}
+ PATHS ${CMAKE_LIBRARY_PATH}
+ PATH_SUFFIXES "lib${l}" "${l}" "lib${l}/Debug" "${l}/Debug" "lib${l}/Release" "${l}/Release"
+ NO_DEFAULT_PATH
+ )
+
+ set(Utils_${L}_LIBRARIES ${Utils_${L}_LIBRARY})
+
+ if (MSVC)
+ find_library(Utils_${L}_LIBRARY_DEBUG
+ NAMES ${l}
+ PATHS ${CMAKE_LIBRARY_PATH}
+ PATH_SUFFIXES "lib${l}/Debug" "${l}/Debug"
+ NO_DEFAULT_PATH
+ )
+ eth_check_library_link(Utils_${L})
+ endif()
+ endforeach()
+
+endif()
+
diff --git a/cmake/FindWeb3.cmake b/cmake/FindWeb3.cmake
new file mode 100644
index 0000000000..a7988dda13
--- /dev/null
+++ b/cmake/FindWeb3.cmake
@@ -0,0 +1,68 @@
+#------------------------------------------------------------------------------
+# CMake helper for libwhisper, libwebthree and libweb3jsonrpc.
+#
+# This module defines
+# Web3_XXX_LIBRARIES, the libraries needed to use ethereum.
+# TODO: Web3_INCLUDE_DIRS
+#
+# The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org
+#
+# ------------------------------------------------------------------------------
+# This file is part of cpp-ethereum.
+#
+# cpp-ethereum is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cpp-ethereum is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cpp-ethereum. If not, see
+#
+# (c) 2014-2016 cpp-ethereum contributors.
+#------------------------------------------------------------------------------
+
+include(EthUtils)
+set(LIBS whisper;webthree;web3jsonrpc)
+
+set(Web3_INCLUDE_DIRS ${CPP_ETHEREUM_DIR})
+
+# if the project is a subset of cpp-ethereum
+# use same pattern for variables as Boost uses
+if ((DEFINED webthree_VERSION) OR (DEFINED cpp-ethereum_VERSION))
+
+ foreach (l ${LIBS})
+ string(TOUPPER ${l} L)
+ set ("Web3_${L}_LIBRARIES" ${l})
+ endforeach()
+
+else()
+
+ foreach (l ${LIBS})
+ string(TOUPPER ${l} L)
+
+ find_library(Web3_${L}_LIBRARY
+ NAMES ${l}
+ PATHS ${CMAKE_LIBRARY_PATH}
+ PATH_SUFFIXES "lib${l}" "${l}" "lib${l}/Release"
+ NO_DEFAULT_PATH
+ )
+
+ set(Web3_${L}_LIBRARIES ${Web3_${L}_LIBRARY})
+
+ if (MSVC)
+ find_library(Web3_${L}_LIBRARY_DEBUG
+ NAMES ${l}
+ PATHS ${CMAKE_LIBRARY_PATH}
+ PATH_SUFFIXES "lib${l}/Debug"
+ NO_DEFAULT_PATH
+ )
+ eth_check_library_link(Web3_${L})
+ endif()
+ endforeach()
+
+endif()
diff --git a/cmake/FindWindowsSDK.cmake b/cmake/FindWindowsSDK.cmake
new file mode 100644
index 0000000000..6affcdb48e
--- /dev/null
+++ b/cmake/FindWindowsSDK.cmake
@@ -0,0 +1,322 @@
+# - Find the Windows SDK aka Platform SDK
+#
+# Relevant Wikipedia article: http://en.wikipedia.org/wiki/Microsoft_Windows_SDK
+#
+# Variables:
+# WINDOWSSDK_FOUND - if any version of the windows or platform SDK was found that is usable with the current version of visual studio
+# WINDOWSSDK_LATEST_DIR
+# WINDOWSSDK_LATEST_NAME
+# WINDOWSSDK_FOUND_PREFERENCE - if we found an entry indicating a "preferred" SDK listed for this visual studio version
+# WINDOWSSDK_PREFERRED_DIR
+# WINDOWSSDK_PREFERRED_NAME
+#
+# WINDOWSSDK_DIRS - contains no duplicates, ordered most recent first.
+# WINDOWSSDK_PREFERRED_FIRST_DIRS - contains no duplicates, ordered with preferred first, followed by the rest in descending recency
+#
+# Functions:
+# windowssdk_name_lookup(