├── .gitignore ├── .gitmodules ├── .travis.yml ├── Brewfile ├── CMakeLists.txt ├── CMakeModules └── FindGperftools.cmake ├── CMakeSettings.json ├── DCore.service ├── Doxyfile ├── LICENSE.md ├── LICENSES-3RD-PARTY.md ├── README.md ├── TERMS.md ├── _config.yml ├── appveyor.yml ├── libraries ├── CMakeLists.txt ├── app │ ├── CMakeLists.txt │ ├── api.cpp │ ├── application.cpp │ ├── balance.cpp │ ├── database_api.cpp │ ├── impacted.cpp │ ├── include │ │ └── graphene │ │ │ └── app │ │ │ ├── api.hpp │ │ │ ├── api_access.hpp │ │ │ ├── application.hpp │ │ │ ├── balance.hpp │ │ │ ├── database_api.hpp │ │ │ ├── exceptions.hpp │ │ │ ├── full_account.hpp │ │ │ ├── impacted.hpp │ │ │ └── plugin.hpp │ └── plugin.cpp ├── chain │ ├── CMakeLists.txt │ ├── account_evaluator.cpp │ ├── account_object.cpp │ ├── assert_evaluator.cpp │ ├── asset_evaluator.cpp │ ├── asset_object.cpp │ ├── block_database.cpp │ ├── content_object.cpp │ ├── custom_evaluator.cpp │ ├── db_balance.cpp │ ├── db_block.cpp │ ├── db_decent.cpp │ ├── db_getter.cpp │ ├── db_init.cpp │ ├── db_maint.cpp │ ├── db_management.cpp │ ├── db_miner_schedule.cpp │ ├── db_update.cpp │ ├── decent_evaluator.cpp │ ├── evaluator.cpp │ ├── fork_database.cpp │ ├── genesis_state.cpp │ ├── get_config.cpp │ ├── hardfork.cpp │ ├── include │ │ └── graphene │ │ │ └── chain │ │ │ ├── account_evaluator.hpp │ │ │ ├── account_object.hpp │ │ │ ├── assert_evaluator.hpp │ │ │ ├── asset_evaluator.hpp │ │ │ ├── asset_object.hpp │ │ │ ├── block_database.hpp │ │ │ ├── block_summary_object.hpp │ │ │ ├── budget_record_object.hpp │ │ │ ├── buying_object.hpp │ │ │ ├── chain_property_object.hpp │ │ │ ├── config.hpp │ │ │ ├── content_object.hpp │ │ │ ├── custom_evaluator.hpp │ │ │ ├── database.hpp │ │ │ ├── db_with.hpp │ │ │ ├── decent_evaluator.hpp │ │ │ ├── evaluator.hpp │ │ │ ├── exceptions.hpp │ │ │ ├── fork_database.hpp │ │ │ ├── genesis_state.hpp │ │ │ ├── get_config.hpp │ │ │ ├── global_property_object.hpp │ │ │ ├── hardfork.hpp │ │ │ ├── immutable_chain_parameters.hpp │ │ │ ├── message_object.hpp │ │ │ ├── miner_evaluator.hpp │ │ │ ├── miner_object.hpp │ │ │ ├── miner_schedule_object.hpp │ │ │ ├── node_property_object.hpp │ │ │ ├── non_fungible_token_evaluator.hpp │ │ │ ├── non_fungible_token_object.hpp │ │ │ ├── operation_history_object.hpp │ │ │ ├── proposal_evaluator.hpp │ │ │ ├── proposal_object.hpp │ │ │ ├── protocol │ │ │ ├── README.md │ │ │ ├── account.hpp │ │ │ ├── assert.hpp │ │ │ ├── asset.hpp │ │ │ ├── asset_ops.hpp │ │ │ ├── authority.hpp │ │ │ ├── base.hpp │ │ │ ├── block.hpp │ │ │ ├── chain_parameters.hpp │ │ │ ├── custom.hpp │ │ │ ├── decent.hpp │ │ │ ├── ext.hpp │ │ │ ├── fee_schedule.hpp │ │ │ ├── memo.hpp │ │ │ ├── miner.hpp │ │ │ ├── non_fungible_token.hpp │ │ │ ├── operations.hpp │ │ │ ├── proposal.hpp │ │ │ ├── subscription.hpp │ │ │ ├── transaction.hpp │ │ │ ├── transfer.hpp │ │ │ ├── types.hpp │ │ │ ├── vesting.hpp │ │ │ ├── vote.hpp │ │ │ └── withdraw_permission.hpp │ │ │ ├── pts_address.hpp │ │ │ ├── seeder_object.hpp │ │ │ ├── seeding_object.hpp │ │ │ ├── seeding_statistics_object.hpp │ │ │ ├── subscription_evaluator.hpp │ │ │ ├── subscription_object.hpp │ │ │ ├── transaction_detail_object.hpp │ │ │ ├── transaction_evaluation_state.hpp │ │ │ ├── transaction_history_object.hpp │ │ │ ├── transaction_object.hpp │ │ │ ├── transfer_evaluator.hpp │ │ │ ├── vesting_balance_evaluator.hpp │ │ │ ├── vesting_balance_object.hpp │ │ │ ├── vote_count.hpp │ │ │ ├── withdraw_permission_evaluator.hpp │ │ │ └── withdraw_permission_object.hpp │ ├── message_object.cpp │ ├── miner_evaluator.cpp │ ├── non_fungible_token_evaluator.cpp │ ├── proposal_evaluator.cpp │ ├── proposal_object.cpp │ ├── protocol │ │ ├── account.cpp │ │ ├── assert.cpp │ │ ├── asset.cpp │ │ ├── asset_ops.cpp │ │ ├── block.cpp │ │ ├── custom.cpp │ │ ├── decent.cpp │ │ ├── fee_schedule.cpp │ │ ├── memo.cpp │ │ ├── miner.cpp │ │ ├── non_fungible_token.cpp │ │ ├── operations.cpp │ │ ├── proposal.cpp │ │ ├── subscription.cpp │ │ ├── transaction.cpp │ │ ├── transfer.cpp │ │ ├── vote.cpp │ │ └── withdraw_permission.cpp │ ├── pts_address.cpp │ ├── subscription_evaluator.cpp │ ├── transaction_detail_object.cpp │ ├── transfer_evaluator.cpp │ ├── vesting_balance_evaluator.cpp │ ├── vesting_balance_object.cpp │ └── withdraw_permission_evaluator.cpp ├── contrib │ └── CMakeLists.txt ├── db │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── db │ │ │ ├── exceptions.hpp │ │ │ ├── flat_index.hpp │ │ │ ├── fwd.hpp │ │ │ ├── generic_index.hpp │ │ │ ├── index.hpp │ │ │ ├── object.hpp │ │ │ ├── object_database.hpp │ │ │ ├── object_id.hpp │ │ │ ├── simple_index.hpp │ │ │ └── undo_database.hpp │ ├── index.cpp │ ├── object_database.cpp │ └── undo_database.cpp ├── egenesis │ ├── CMakeLists.txt │ ├── egenesis_decent.cpp │ ├── egenesis_none.cpp │ └── include │ │ └── graphene │ │ └── egenesis │ │ └── egenesis.hpp ├── encrypt │ ├── CMakeLists.txt │ ├── custodyutils.cpp │ ├── encryptionutils.cpp │ └── include │ │ └── decent │ │ └── encrypt │ │ ├── crypto_types.hpp │ │ ├── custodyutils.hpp │ │ └── encryptionutils.hpp ├── net │ ├── CMakeLists.txt │ ├── core_messages.cpp │ ├── include │ │ └── graphene │ │ │ └── net │ │ │ ├── config.hpp │ │ │ ├── core_messages.hpp │ │ │ ├── exceptions.hpp │ │ │ ├── message.hpp │ │ │ ├── message_oriented_connection.hpp │ │ │ ├── node.hpp │ │ │ ├── peer_connection.hpp │ │ │ ├── peer_database.hpp │ │ │ └── stcp_socket.hpp │ ├── message_oriented_connection.cpp │ ├── node.cpp │ ├── peer_connection.cpp │ ├── peer_database.cpp │ └── stcp_socket.cpp ├── package │ ├── CMakeLists.txt │ ├── detail.cpp │ ├── detail.hpp │ ├── include │ │ └── decent │ │ │ ├── ipfs_check.hpp │ │ │ └── package │ │ │ ├── package.hpp │ │ │ └── package_config.hpp │ ├── ipfs_check.cpp │ ├── ipfs_transfer.cpp │ ├── ipfs_transfer.hpp │ └── package.cpp ├── plugins │ ├── CMakeLists.txt │ ├── account_history │ │ ├── CMakeLists.txt │ │ ├── account_history_plugin.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── account_history │ │ │ └── account_history_plugin.hpp │ ├── elasticsearch │ │ ├── CMakeLists.txt │ │ ├── adaptor.cpp │ │ ├── adaptor.hpp │ │ ├── elasticsearch_plugin.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── elasticsearch │ │ │ └── elasticsearch_plugin.hpp │ ├── miner │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── graphene │ │ │ │ └── miner │ │ │ │ └── miner.hpp │ │ └── miner.cpp │ ├── seeding │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── graphene │ │ │ │ └── seeding │ │ │ │ └── seeding.hpp │ │ └── seeding.cpp │ └── transaction_history │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── graphene │ │ │ └── transaction_history │ │ │ └── transaction_history_plugin.hpp │ │ └── transaction_history_plugin.cpp ├── utilities │ ├── CMakeLists.txt │ ├── about.cpp │ ├── decent_config.cpp │ ├── dirhelper.cpp │ ├── git_revision.cpp.in │ ├── include │ │ ├── decent │ │ │ ├── about.hpp │ │ │ └── decent_config.hpp │ │ └── graphene │ │ │ └── utilities │ │ │ ├── dirhelper.hpp │ │ │ ├── git_revision.hpp │ │ │ ├── key_conversion.hpp │ │ │ ├── keys_generator.hpp │ │ │ ├── padding_ostream.hpp │ │ │ ├── string_escape.hpp │ │ │ ├── time.hpp │ │ │ └── words.hpp │ ├── key_conversion.cpp │ ├── keys_generator.cpp │ ├── string_escape.cpp │ ├── time.cpp │ └── words.cpp └── wallet │ ├── CMakeLists.txt │ ├── Doxyfile.in │ ├── api_documentation_standin.cpp │ ├── generate_api_documentation.pl │ ├── include │ └── graphene │ │ └── wallet │ │ ├── api_documentation.hpp │ │ ├── exceptions.hpp │ │ ├── wallet.hpp │ │ └── wallet_utility.hpp │ ├── operation_printer.cpp │ ├── operation_printer.hpp │ ├── wallet.cpp │ ├── wallet_impl.cpp │ ├── wallet_impl.hpp │ └── wallet_utility.cpp ├── programs ├── CMakeLists.txt ├── build_helpers │ ├── CMakeLists.txt │ ├── cat-parts.cpp │ ├── check_reflect.py │ └── member_enumerator.cpp ├── cli_wallet │ ├── CMakeLists.txt │ └── main.cpp ├── decentd │ ├── CMakeLists.txt │ ├── main.cpp │ ├── saltpass.py │ ├── winsvc.cpp │ └── winsvc.hpp ├── delayed_node │ ├── CMakeLists.txt │ ├── delayed_node_plugin.cpp │ ├── delayed_node_plugin.hpp │ └── main.cpp ├── genesis_util │ ├── CMakeLists.txt │ ├── apply_patch.py │ ├── canonical_format.py │ ├── change_asset_symbol.py │ ├── change_bitasset_owners.py │ ├── change_key_prefix.py │ ├── create_bloom_filter.py │ ├── egenesis_brief.cpp.tmpl │ ├── egenesis_full.cpp.tmpl │ ├── embed_genesis.cpp │ ├── generate_account_patch.py │ ├── generate_init_config.py │ ├── generate_init_patch.py │ ├── genesis_update.cpp │ ├── get_dev_key.cpp │ ├── prefix_accounts.py │ ├── python_format.py │ ├── remove.py │ ├── sort_objects.py │ ├── unprefix_asset_owners.py │ ├── unprefix_names.py │ └── upgrade_members.py ├── js_operation_serializer │ ├── CMakeLists.txt │ └── main.cpp ├── size_checker │ ├── CMakeLists.txt │ └── main.cpp └── verify_sign │ ├── CMakeLists.txt │ └── main.cpp ├── scripts ├── Windows │ ├── Banner.bmp │ ├── DCore.ico │ ├── DCore.sln │ ├── DCore.wixproj │ ├── Dialog.bmp │ ├── LicenceAgreement.rtf │ └── Service.wxs ├── price_getter.sh └── uia_update_price.sh └── tests ├── CMakeLists.txt ├── app └── main.cpp ├── benchmarks ├── genesis_allocation.cpp └── main.cpp ├── common ├── database_fixture.cpp ├── database_fixture.hpp ├── tempdir.cpp └── tempdir.hpp ├── encrypt ├── test_encryption_utils.cpp └── test_pbc_benchmark.cpp ├── generate_empty_blocks ├── CMakeLists.txt └── main.cpp ├── intense ├── api_stress.py ├── block_tests.cpp └── main.cpp ├── package ├── main.cpp └── sandbox.cpp ├── performance └── performance_tests.cpp └── tests ├── authority_tests.cpp ├── basic_tests.cpp ├── block_tests.cpp ├── database_tests.cpp ├── fee_tests.cpp ├── main.cpp ├── messaging_tests.cpp ├── operation_tests.cpp ├── operation_tests2.cpp ├── serialization_tests.cpp └── uia_tests.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | .vs/ 2 | .vscode/ 3 | .idea/ 4 | build/ 5 | doxygen/ 6 | Debug/ 7 | Release/ 8 | 9 | CMakeCache.txt 10 | CMakeLists.txt.user 11 | 12 | *.qm 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libraries/contrib/fc"] 2 | path = libraries/contrib/fc 3 | url = https://github.com/DECENTfoundation/fc.git 4 | [submodule "libraries/contrib/cpp-ipfs-api"] 5 | path = libraries/contrib/cpp-ipfs-api 6 | url = https://github.com/DECENTfoundation/cpp-ipfs-api.git 7 | [submodule "scripts/Docker"] 8 | branch = master 9 | path = scripts/Docker 10 | url = https://github.com/DECENTfoundation/DCore-Docker 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | 3 | sudo: required 4 | 5 | language: cpp 6 | 7 | git: 8 | depth: false 9 | 10 | matrix: 11 | include: 12 | - os: linux 13 | compiler: gcc 14 | cache: 15 | directories: 16 | - $HOME/boost 17 | - $HOME/json 18 | 19 | - os: linux 20 | compiler: clang 21 | cache: 22 | directories: 23 | - $HOME/boost 24 | - $HOME/json 25 | 26 | - os: osx 27 | osx_image: xcode10.3 28 | compiler: clang 29 | cache: 30 | directories: 31 | - /usr/local/Cellar/cryptopp 32 | - $HOME/Library/Caches/Homebrew 33 | 34 | - os: osx 35 | osx_image: xcode11.3 36 | compiler: clang 37 | cache: 38 | directories: 39 | - /usr/local/Cellar/cryptopp 40 | - $HOME/Library/Caches/Homebrew 41 | 42 | addons: 43 | apt: 44 | sources: 45 | - sourceline: 'deb [arch=amd64] https://dl.bintray.com/decentfoundation/ubuntu xenial libpbc' 46 | key_url: 'https://bintray.com/user/downloadSubjectPublicKey?username=decentfoundation' 47 | packages: 48 | - doxygen 49 | - libcrypto++-dev 50 | - libcurl4-openssl-dev 51 | - libpbc-dev 52 | 53 | before_cache: 54 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 55 | brew cleanup; 56 | fi 57 | 58 | before_install: 59 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 60 | test -L /usr/local/opt/cryptopp || test ! -d /usr/local/Cellar/cryptopp || brew link cryptopp || true; 61 | fi 62 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 63 | brew update && 64 | brew bundle cleanup --force && 65 | brew bundle install --verbose && 66 | brew link --force readline; 67 | fi 68 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 69 | test -d $HOME/boost/lib || (wget -nv https://sourceforge.net/projects/boost/files/boost/1.65.1/boost_1_65_1.tar.gz && tar xf boost_1_65_1.tar.gz && cd boost_1_65_1 && ./bootstrap.sh --prefix=$HOME/boost && ./b2 -j$(nproc) install); 70 | fi 71 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 72 | test -d $HOME/json/include || (wget -nv https://github.com/nlohmann/json/archive/v3.7.3.tar.gz && tar xf v3.7.3.tar.gz && cd json-3.7.3 && cmake -DCMAKE_INSTALL_PREFIX=$HOME/json . && make -j$(nproc) install); 73 | fi 74 | 75 | script: 76 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 77 | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/DCore .; 78 | fi 79 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 80 | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/DCore -DCMAKE_PREFIX_PATH=$HOME/json -DBOOST_ROOT=$HOME/boost .; 81 | fi 82 | - make -j$(nproc) install 83 | 84 | notifications: 85 | email: 86 | on_success: never 87 | on_failure: always 88 | -------------------------------------------------------------------------------- /Brewfile: -------------------------------------------------------------------------------- 1 | brew "cmake" 2 | brew "coreutils" 3 | brew "cryptopp" 4 | brew "pbc" 5 | brew "openssl@1.1" 6 | brew "readline" 7 | brew "boost" 8 | brew "doxygen" 9 | brew "nlohmann-json" 10 | -------------------------------------------------------------------------------- /CMakeModules/FindGperftools.cmake: -------------------------------------------------------------------------------- 1 | # Tries to find Gperftools. 2 | # 3 | # Usage of this module as follows: 4 | # 5 | # find_package(Gperftools) 6 | # 7 | # Variables used by this module, they can change the default behaviour and need 8 | # to be set before calling find_package: 9 | # 10 | # Gperftools_ROOT_DIR Set this variable to the root installation of 11 | # Gperftools if the module has problems finding 12 | # the proper installation path. 13 | # 14 | # Variables defined by this module: 15 | # 16 | # GPERFTOOLS_FOUND System has Gperftools libs/headers 17 | # GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler) 18 | # GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers 19 | 20 | find_library(GPERFTOOLS_TCMALLOC 21 | NAMES tcmalloc 22 | HINTS ${Gperftools_ROOT_DIR}/lib) 23 | 24 | find_library(GPERFTOOLS_PROFILER 25 | NAMES profiler 26 | HINTS ${Gperftools_ROOT_DIR}/lib) 27 | 28 | find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER 29 | NAMES tcmalloc_and_profiler 30 | HINTS ${Gperftools_ROOT_DIR}/lib) 31 | 32 | find_path(GPERFTOOLS_INCLUDE_DIR 33 | NAMES gperftools/heap-profiler.h 34 | HINTS ${Gperftools_ROOT_DIR}/include) 35 | 36 | set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER}) 37 | 38 | include(FindPackageHandleStandardArgs) 39 | find_package_handle_standard_args( 40 | Gperftools 41 | DEFAULT_MSG 42 | GPERFTOOLS_LIBRARIES 43 | GPERFTOOLS_INCLUDE_DIR) 44 | 45 | mark_as_advanced( 46 | Gperftools_ROOT_DIR 47 | GPERFTOOLS_TCMALLOC 48 | GPERFTOOLS_PROFILER 49 | GPERFTOOLS_TCMALLOC_AND_PROFILER 50 | GPERFTOOLS_LIBRARIES 51 | GPERFTOOLS_INCLUDE_DIR) 52 | -------------------------------------------------------------------------------- /DCore.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=DCore node daemon 3 | Wants=network-online.target 4 | After=network-online.target 5 | 6 | [Service] 7 | Type=forking 8 | Restart=on-failure 9 | ExecStart=/usr/bin/decentd --daemon 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /libraries/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( contrib EXCLUDE_FROM_ALL ) 2 | add_subdirectory( db ) 3 | add_subdirectory( encrypt ) 4 | add_subdirectory( chain ) 5 | add_subdirectory( egenesis ) 6 | add_subdirectory( net ) 7 | add_subdirectory( utilities ) 8 | add_subdirectory( app ) 9 | add_subdirectory( package ) 10 | add_subdirectory( plugins ) 11 | add_subdirectory( wallet ) 12 | -------------------------------------------------------------------------------- /libraries/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/app/*.hpp") 2 | 3 | add_library( graphene_app 4 | api.cpp 5 | application.cpp 6 | database_api.cpp 7 | impacted.cpp 8 | balance.cpp 9 | plugin.cpp 10 | ${HEADERS} 11 | ) 12 | 13 | target_link_libraries( graphene_app PUBLIC graphene_net graphene_utilities PRIVATE package_manager graphene_egenesis_decent ) 14 | target_include_directories( graphene_app PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 15 | 16 | if(MSVC) 17 | set_source_files_properties( application.cpp api.cpp database_api.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 18 | endif(MSVC) 19 | 20 | #install( TARGETS 21 | # graphene_app 22 | # 23 | # RUNTIME DESTINATION bin 24 | # LIBRARY DESTINATION lib 25 | # ARCHIVE DESTINATION lib 26 | #) 27 | -------------------------------------------------------------------------------- /libraries/app/include/graphene/app/api_access.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | 29 | namespace graphene { namespace app { 30 | 31 | class api_access_info 32 | { 33 | public: 34 | api_access_info() {} 35 | api_access_info( std::string pw_hash, std::string pw_salt, std::vector apis) 36 | : password_hash_b64( pw_hash), password_salt_b64( pw_salt), allowed_apis( apis){} 37 | 38 | std::string password_hash_b64 = "*"; 39 | std::string password_salt_b64 = "*"; 40 | std::vector< std::string > allowed_apis = { database_api::get_api_name(), 41 | network_broadcast_api::get_api_name(), 42 | history_api::get_api_name(), 43 | crypto_api::get_api_name(), 44 | messaging_api::get_api_name() }; 45 | }; 46 | 47 | class api_access 48 | { 49 | public: 50 | api_access() {} 51 | api_access( std::string username, api_access_info access) 52 | { 53 | permission_map.insert( std::make_pair(username, access)); 54 | } 55 | 56 | std::map< std::string, api_access_info > permission_map = {{"*", api_access_info()}}; 57 | }; 58 | 59 | } } // graphene::app 60 | 61 | FC_REFLECT( graphene::app::api_access_info, 62 | (password_hash_b64) 63 | (password_salt_b64) 64 | (allowed_apis) 65 | ) 66 | 67 | FC_REFLECT( graphene::app::api_access, 68 | (permission_map) 69 | ) 70 | -------------------------------------------------------------------------------- /libraries/app/include/graphene/app/balance.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace graphene { namespace app { 7 | 8 | struct asset_array; 9 | 10 | void operation_get_balance_history(const graphene::chain::operation& op, graphene::chain::account_id_type account, asset_array& result, graphene::chain::asset& fee_result ); 11 | 12 | } } // graphene::app 13 | -------------------------------------------------------------------------------- /libraries/app/include/graphene/app/full_account.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | namespace graphene { namespace app { 31 | 32 | struct full_account 33 | { 34 | chain::account_object account; 35 | chain::account_statistics_object statistics; 36 | std::string registrar_name; 37 | std::vector> votes; 38 | fc::optional cashback_balance; 39 | std::vector balances; 40 | std::vector vesting_balances; 41 | std::vector proposals; 42 | }; 43 | 44 | } } 45 | 46 | FC_REFLECT( graphene::app::full_account, 47 | (account) 48 | (statistics) 49 | (registrar_name) 50 | (votes) 51 | (cashback_balance) 52 | (balances) 53 | (vesting_balances) 54 | (proposals) 55 | ) 56 | -------------------------------------------------------------------------------- /libraries/app/include/graphene/app/impacted.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | 29 | namespace graphene { namespace app { 30 | 31 | void operation_get_impacted_accounts( 32 | const graphene::chain::operation& op, 33 | boost::container::flat_set& result ); 34 | 35 | void transaction_get_impacted_accounts( 36 | const graphene::chain::transaction& tx, 37 | boost::container::flat_set& result ); 38 | 39 | } } // graphene::app 40 | -------------------------------------------------------------------------------- /libraries/app/plugin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | namespace graphene { namespace app { 29 | 30 | plugin::plugin(application* app) : _app(app) 31 | { 32 | } 33 | 34 | plugin::~plugin() 35 | { 36 | } 37 | 38 | std::string abstract_plugin::plugin_name() 39 | { 40 | return ""; 41 | } 42 | 43 | void abstract_plugin::plugin_set_program_options( 44 | boost::program_options::options_description& command_line_options, 45 | boost::program_options::options_description& config_file_options 46 | ) 47 | { 48 | } 49 | 50 | } } // graphene::app 51 | -------------------------------------------------------------------------------- /libraries/chain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/chain/*.hpp" "include/graphene/chain/protocol/*.hpp") 2 | 3 | add_library( graphene_chain 4 | db_balance.cpp 5 | db_block.cpp 6 | db_getter.cpp 7 | db_init.cpp 8 | db_maint.cpp 9 | db_management.cpp 10 | db_decent.cpp 11 | db_update.cpp 12 | db_miner_schedule.cpp 13 | block_database.cpp 14 | fork_database.cpp 15 | genesis_state.cpp 16 | get_config.cpp 17 | hardfork.cpp 18 | pts_address.cpp 19 | protocol/asset.cpp 20 | protocol/assert.cpp 21 | protocol/account.cpp 22 | protocol/transfer.cpp 23 | protocol/miner.cpp 24 | protocol/proposal.cpp 25 | protocol/withdraw_permission.cpp 26 | protocol/asset_ops.cpp 27 | protocol/memo.cpp 28 | protocol/custom.cpp 29 | protocol/operations.cpp 30 | protocol/transaction.cpp 31 | protocol/block.cpp 32 | protocol/fee_schedule.cpp 33 | protocol/non_fungible_token.cpp 34 | protocol/vote.cpp 35 | protocol/decent.cpp 36 | protocol/subscription.cpp 37 | evaluator.cpp 38 | account_evaluator.cpp 39 | assert_evaluator.cpp 40 | miner_evaluator.cpp 41 | asset_evaluator.cpp 42 | transfer_evaluator.cpp 43 | proposal_evaluator.cpp 44 | vesting_balance_evaluator.cpp 45 | withdraw_permission_evaluator.cpp 46 | decent_evaluator.cpp 47 | subscription_evaluator.cpp 48 | custom_evaluator.cpp 49 | non_fungible_token_evaluator.cpp 50 | account_object.cpp 51 | asset_object.cpp 52 | content_object.cpp 53 | proposal_object.cpp 54 | vesting_balance_object.cpp 55 | transaction_detail_object.cpp 56 | message_object.cpp 57 | ${HEADERS} 58 | ) 59 | 60 | target_link_libraries( graphene_chain PUBLIC decent_encrypt graphene_db ) 61 | target_include_directories( graphene_chain PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 62 | 63 | if(MSVC) 64 | set_source_files_properties( db_init.cpp db_block.cpp database.cpp block_database.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 65 | endif(MSVC) 66 | 67 | #install( TARGETS 68 | # graphene_chain 69 | # 70 | # RUNTIME DESTINATION bin 71 | # LIBRARY DESTINATION lib 72 | # ARCHIVE DESTINATION lib 73 | #) 74 | -------------------------------------------------------------------------------- /libraries/chain/content_object.cpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | #include 3 | #include 4 | 5 | namespace graphene { namespace chain { 6 | 7 | std::map RegionCodes::s_mapCodeToName; 8 | std::map RegionCodes::s_mapNameToCode; 9 | 10 | bool RegionCodes::bAuxillary = RegionCodes::InitCodeAndName(); 11 | 12 | fc::optional PriceRegions::GetPrice(uint32_t region_code) const 13 | { 14 | fc::optional op_price; 15 | auto it_single_price = map_price.find(uint32_t(RegionCodes::OO_none)); 16 | if (it_single_price != map_price.end()) 17 | { 18 | // content has one price for all regions 19 | op_price = it_single_price->second; 20 | return op_price; 21 | } 22 | 23 | auto it_region_price = map_price.find(region_code); 24 | if (it_region_price != map_price.end()) 25 | { 26 | // content has price corresponding to this region 27 | op_price = it_region_price->second; 28 | return op_price; 29 | } 30 | 31 | auto it_default_price = map_price.find(uint32_t(RegionCodes::OO_all)); 32 | if (it_default_price != map_price.end()) 33 | { 34 | // content has default price covering this and all other regions 35 | op_price = it_default_price->second; 36 | return op_price; 37 | } 38 | 39 | return op_price; 40 | } 41 | void PriceRegions::ClearPrices() 42 | { 43 | map_price.clear(); 44 | } 45 | void PriceRegions::SetSimplePrice(asset const& price) 46 | { 47 | map_price.clear(); 48 | map_price.insert(std::make_pair(uint32_t(RegionCodes::OO_none), price)); 49 | } 50 | void PriceRegions::SetRegionPrice(uint32_t region_code, asset const& price) 51 | { 52 | map_price.insert(std::make_pair(region_code, price)); 53 | } 54 | bool PriceRegions::Valid(uint32_t region_code) const 55 | { 56 | fc::optional op_price = GetPrice(region_code); 57 | return op_price.valid(); 58 | } 59 | bool PriceRegions::Valid(const std::string& region_code) const 60 | { 61 | fc::optional op_price; 62 | auto it = RegionCodes::s_mapNameToCode.find(region_code); 63 | if (it != RegionCodes::s_mapNameToCode.end()) 64 | return Valid(it->second); 65 | return false; 66 | } 67 | 68 | }} 69 | -------------------------------------------------------------------------------- /libraries/chain/custom_evaluator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | namespace graphene { namespace chain { 7 | 8 | operation_result custom_evaluator::do_evaluate(const operation_type& o) 9 | { 10 | if (o.id != operation_type::custom_operation_subtype_messaging) 11 | return void_result(); 12 | 13 | try { 14 | message_payload pl; 15 | o.get_messaging_payload(pl); 16 | const database& d = db(); 17 | const auto& idx = d.get_index_type().indices().get(); 18 | const auto itr = idx.find(pl.from); 19 | FC_ASSERT(itr != idx.end(), "Sender ${id} does not exist.", ("id", pl.from)); 20 | for (size_t i = 0; i < pl.receivers_data.size(); i++) { 21 | const auto itr = idx.find(pl.receivers_data[i].to); 22 | FC_ASSERT(itr != idx.end(), "Receiver ${id} does not exist.", ("id", pl.receivers_data[i].to)); 23 | } 24 | FC_ASSERT(pl.from == o.payer, "Sender must pay for the operation."); 25 | return void_result(); 26 | } FC_CAPTURE_AND_RETHROW((o)) 27 | } 28 | 29 | operation_result custom_evaluator::do_apply(const operation_type& o) 30 | { 31 | if (o.id != operation_type::custom_operation_subtype_messaging) 32 | return void_result(); 33 | 34 | message_payload pl; 35 | o.get_messaging_payload(pl); 36 | if(!is_account_tracked(pl.from) && std::all_of(pl.receivers_data.begin(), pl.receivers_data.end(), [](const auto& data) { return !is_account_tracked(data.to); } )) 37 | return void_result(); 38 | 39 | database &d = db(); 40 | return d.create([&](message_object& obj) 41 | { 42 | obj.created = d.head_block_time(); 43 | obj.sender_pubkey = pl.pub_from; 44 | obj.sender = pl.from; 45 | std::for_each(pl.receivers_data.begin(), pl.receivers_data.end(), [&obj](const message_payload_receivers_data& data) { 46 | obj.receivers_data.push_back({ data.to, data.pub_to, data.nonce, data.data }); 47 | }); 48 | }).id; 49 | } 50 | 51 | } } // graphene::chain 52 | -------------------------------------------------------------------------------- /libraries/chain/genesis_state.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | 27 | // these are required to serialize a genesis_state 28 | #include // required for gcc in release mode 29 | #include 30 | 31 | namespace graphene { namespace chain { 32 | 33 | chain_id_type genesis_state_type::compute_chain_id() const 34 | { 35 | return initial_chain_id; 36 | } 37 | 38 | } } // graphene::chain 39 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { namespace chain { 4 | 5 | fork_times_t fork_times = { 6 | fc::time_point_sec::from_iso_string("2017-11-08T12:00:00"), 7 | fc::time_point_sec::from_iso_string("2018-04-23T08:00:00"), 8 | fc::time_point_sec::from_iso_string("2018-09-13T08:00:00"), 9 | fc::time_point_sec::from_iso_string("2019-07-11T08:00:00") 10 | }; 11 | 12 | } } 13 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/account_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #pragma once 26 | #include 27 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class account_create_evaluator : public evaluator 32 | { 33 | public: 34 | operation_result do_evaluate( const operation_type& o ); 35 | operation_result do_apply( const operation_type& o ); 36 | }; 37 | 38 | class account_update_evaluator : public evaluator 39 | { 40 | public: 41 | operation_result do_evaluate( const operation_type& o ); 42 | operation_result do_apply( const operation_type& o ); 43 | 44 | private: 45 | const account_object* acnt; 46 | }; 47 | 48 | } } // graphene::chain 49 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/assert_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | #include 27 | 28 | namespace graphene { namespace chain { 29 | 30 | class assert_evaluator : public evaluator 31 | { 32 | public: 33 | operation_result do_evaluate( const operation_type& o ); 34 | operation_result do_apply( const operation_type& o ); 35 | }; 36 | 37 | } } // graphene::chain 38 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/block_database.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | #include 27 | 28 | namespace graphene { namespace chain { 29 | class block_database 30 | { 31 | public: 32 | void open( const boost::filesystem::path& dbdir ); 33 | bool is_open()const; 34 | void flush(); 35 | void close(); 36 | 37 | void store( const block_id_type& id, const signed_block& b ); 38 | void remove( const block_id_type& id ); 39 | 40 | bool contains( const block_id_type& id )const; 41 | block_id_type fetch_block_id( uint32_t block_num )const; 42 | fc::optional fetch_optional( const block_id_type& id )const; 43 | fc::optional fetch_by_number( uint32_t block_num )const; 44 | fc::optional last()const; 45 | fc::optional last_id()const; 46 | private: 47 | mutable boost::filesystem::fstream _blocks; 48 | mutable boost::filesystem::fstream _block_num_to_pos; 49 | }; 50 | } } 51 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/block_summary_object.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | 27 | namespace graphene { namespace chain { 28 | 29 | /** 30 | * @brief tracks minimal information about past blocks to implement TaPOS 31 | * @ingroup object 32 | * 33 | * When attempting to calculate the validity of a transaction we need to 34 | * lookup a past block and check its block hash and the time it occurred 35 | * so we can calculate whether the current transaction is valid and at 36 | * what time it should expire. 37 | */ 38 | class block_summary_object : public graphene::db::abstract_object 39 | { 40 | public: 41 | block_id_type block_id; 42 | }; 43 | 44 | } } 45 | 46 | FC_REFLECT_DERIVED( graphene::chain::block_summary_object, (graphene::db::object), (block_id) ) 47 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/chain_property_object.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { namespace chain { 29 | 30 | class chain_property_object; 31 | 32 | /** 33 | * Contains invariants which are set at genesis and never changed. 34 | */ 35 | class chain_property_object : public graphene::db::abstract_object 36 | { 37 | public: 38 | chain_id_type chain_id; 39 | immutable_chain_parameters immutable_parameters; 40 | }; 41 | 42 | } } 43 | 44 | FC_REFLECT_DERIVED( graphene::chain::chain_property_object, (graphene::db::object), 45 | (chain_id) 46 | (immutable_parameters) 47 | ) 48 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/custom_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | 27 | namespace graphene { namespace chain { 28 | 29 | class custom_evaluator : public evaluator 30 | { 31 | public: 32 | operation_result do_evaluate(const operation_type& o); 33 | operation_result do_apply(const operation_type& o); 34 | }; 35 | 36 | } } 37 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/hardfork.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace graphene { namespace chain { 7 | 8 | using fork_times_t = std::array; 9 | extern fork_times_t fork_times; 10 | 11 | } } 12 | 13 | // #1 - UIA introduced, seeder regions, instant messaging 14 | #ifndef HARDFORK_1_TIME 15 | #define HARDFORK_1_TIME graphene::chain::fork_times[0] 16 | #endif 17 | 18 | // #2 - simple content, payment to content, option to fix asset max supply, new wallet file format 19 | #ifndef HARDFORK_2_TIME 20 | #define HARDFORK_2_TIME graphene::chain::fork_times[1] 21 | #endif 22 | 23 | // #3 - UIA: the option to change the precision and to fix max supply 24 | #ifndef HARDFORK_3_TIME 25 | #define HARDFORK_3_TIME graphene::chain::fork_times[2] 26 | #endif 27 | 28 | // #4 - NFT and submit content: removed 10 co-authors constraint, allowed CDN expiration date change 29 | #ifndef HARDFORK_4_TIME 30 | #define HARDFORK_4_TIME graphene::chain::fork_times[3] 31 | #endif 32 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | 33 | namespace graphene { namespace chain { 34 | 35 | struct immutable_chain_parameters 36 | { 37 | uint16_t min_miner_count = GRAPHENE_DEFAULT_MIN_MINER_COUNT; 38 | uint32_t num_special_accounts = 0; 39 | uint32_t num_special_assets = 0; 40 | }; 41 | 42 | } } // graphene::chain 43 | 44 | FC_REFLECT( graphene::chain::immutable_chain_parameters, 45 | (min_miner_count) 46 | (num_special_accounts) 47 | (num_special_assets) 48 | ) 49 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/miner_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #pragma once 26 | #include 27 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class miner_create_evaluator : public evaluator 32 | { 33 | public: 34 | operation_result do_evaluate( const operation_type& o ); 35 | operation_result do_apply( const operation_type& o ); 36 | }; 37 | 38 | class miner_update_evaluator : public evaluator 39 | { 40 | public: 41 | operation_result do_evaluate( const operation_type& o ); 42 | operation_result do_apply( const operation_type& o ); 43 | }; 44 | 45 | class miner_update_global_parameters_evaluator : public evaluator 46 | { 47 | public: 48 | operation_result do_evaluate( const operation_type& o ); 49 | operation_result do_apply( const operation_type& o ); 50 | }; 51 | 52 | } } // graphene::chain 53 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/miner_schedule_object.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | #include 27 | 28 | namespace graphene { namespace chain { 29 | 30 | class miner_schedule_object : public graphene::db::abstract_object 31 | { 32 | public: 33 | std::vector current_shuffled_miners; 34 | }; 35 | 36 | } } 37 | 38 | FC_REFLECT_DERIVED( 39 | graphene::chain::miner_schedule_object, 40 | (graphene::db::object), 41 | (current_shuffled_miners) 42 | ) 43 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/node_property_object.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | 27 | namespace graphene { namespace chain { 28 | 29 | /** 30 | * @brief Contains per-node database configuration. 31 | * 32 | * Transactions are evaluated differently based on per-node state. 33 | * Settings here may change based on whether the node is syncing or up-to-date. 34 | * Or whether the node is a miner node. Or if we're processing a 35 | * transaction in a miner-signed block vs. a fresh transaction 36 | * from the p2p network. Or configuration-specified tradeoffs of 37 | * performance/hardfork resilience vs. paranoia. 38 | */ 39 | class node_property_object 40 | { 41 | public: 42 | node_property_object(){} 43 | ~node_property_object(){} 44 | 45 | uint32_t skip_flags = 0; 46 | }; 47 | } } // graphene::chain 48 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/non_fungible_token_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2019 DECENT Services. For details refers to LICENSE.txt */ 2 | #pragma once 3 | #include 4 | #include 5 | 6 | namespace graphene { namespace chain { 7 | 8 | class non_fungible_token_create_definition_evaluator : public evaluator 9 | { 10 | public: 11 | operation_result do_evaluate( const operation_type& op ); 12 | operation_result do_apply( const operation_type& op ); 13 | }; 14 | 15 | class non_fungible_token_update_definition_evaluator : public evaluator 16 | { 17 | public: 18 | operation_result do_evaluate( const operation_type& op ); 19 | operation_result do_apply( const operation_type& op ); 20 | 21 | private: 22 | const non_fungible_token_object* nft_to_update = nullptr; 23 | }; 24 | 25 | class non_fungible_token_issue_evaluator : public evaluator 26 | { 27 | public: 28 | operation_result do_evaluate( const operation_type& op ); 29 | operation_result do_apply( const operation_type& op ); 30 | 31 | private: 32 | const non_fungible_token_object* nft_to_update = nullptr; 33 | }; 34 | 35 | class non_fungible_token_transfer_evaluator : public evaluator 36 | { 37 | public: 38 | operation_result do_evaluate( const operation_type& op ); 39 | operation_result do_apply( const operation_type& op ); 40 | 41 | private: 42 | const non_fungible_token_data_object* nft_data_to_update = nullptr; 43 | }; 44 | 45 | class non_fungible_token_update_data_evaluator : public evaluator 46 | { 47 | public: 48 | operation_result do_evaluate( const operation_type& op ); 49 | operation_result do_apply( const operation_type& op ); 50 | 51 | private: 52 | const non_fungible_token_data_object* nft_data_to_update = nullptr; 53 | }; 54 | 55 | } } // graphene::chain 56 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/proposal_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace graphene { namespace chain { 32 | 33 | class proposal_create_evaluator : public evaluator 34 | { 35 | public: 36 | operation_result do_evaluate( const operation_type& o ); 37 | operation_result do_apply( const operation_type& o ); 38 | 39 | private: 40 | transaction _proposed_trx; 41 | }; 42 | 43 | class proposal_update_evaluator : public evaluator 44 | { 45 | public: 46 | operation_result do_evaluate( const operation_type& o ); 47 | operation_result do_apply( const operation_type& o ); 48 | 49 | private: 50 | const proposal_object* _proposal = nullptr; 51 | processed_transaction _processed_transaction; 52 | bool _executed_proposal = false; 53 | bool _proposal_failed = false; 54 | }; 55 | 56 | class proposal_delete_evaluator : public evaluator 57 | { 58 | public: 59 | operation_result do_evaluate( const operation_type& o ); 60 | operation_result do_apply(const operation_type&); 61 | 62 | private: 63 | const proposal_object* _proposal = nullptr; 64 | }; 65 | 66 | } } // graphene::chain 67 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/README.md: -------------------------------------------------------------------------------- 1 | Protocol Definition 2 | -------------------- 3 | 4 | The classes declared in these headers provide the complete definition of the 5 | Graphene protocol and are organized according to feature. Nothing in this 6 | directory should depend upon anything other than fc or other types defined 7 | in the protocol directory. 8 | 9 | To be more specific, implementation details such as the objects defined in 10 | the object database should not be required here. 11 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/seeder_object.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | #pragma once 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | namespace graphene { namespace chain { 12 | 13 | class seeder_object : public graphene::db::abstract_object 14 | { 15 | public: 16 | account_id_type seeder; 17 | uint64_t free_space; 18 | asset price; 19 | fc::time_point_sec expiration; 20 | decent::encrypt::DIntegerString pubKey; 21 | 22 | std::string ipfs_ID; 23 | // seeding stats used to compute seeder's rating 24 | seeding_statistics_id_type stats; 25 | // seeder's rating 26 | uint32_t rating = 0; 27 | // optional ISO 3166-1 alpha-2 two-letter region code 28 | std::string region_code; 29 | }; 30 | 31 | struct by_seeder; 32 | struct by_free_space; 33 | struct by_price; 34 | struct by_expiration; 35 | struct by_region; 36 | struct by_rating; 37 | 38 | typedef boost::multi_index_container< 39 | seeder_object, 40 | db::mi::indexed_by< 41 | db::object_id_index, 42 | db::mi::ordered_unique, 43 | db::mi::member 44 | >, 45 | db::mi::ordered_non_unique, 46 | db::mi::member 47 | >, 48 | db::mi::ordered_non_unique, 49 | db::mi::member 50 | >, 51 | db::mi::ordered_non_unique, 52 | db::mi::member 53 | >, 54 | db::mi::ordered_non_unique, 55 | db::mi::member 56 | >, 57 | db::mi::ordered_non_unique, 58 | db::mi::member,std::greater 59 | > 60 | > 61 | >seeder_object_multi_index_type; 62 | 63 | typedef graphene::db::generic_index< seeder_object, seeder_object_multi_index_type > seeder_index; 64 | 65 | }} // graphene::chain 66 | 67 | FC_REFLECT_DERIVED(graphene::chain::seeder_object, 68 | (graphene::db::object), 69 | (seeder)(free_space)(price)(expiration)(pubKey)(ipfs_ID)(stats)(rating)(region_code) ) 70 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/seeding_object.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | #pragma once 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace graphene { namespace chain { 10 | 11 | class seeding_object : public graphene::db::abstract_object 12 | { 13 | public: 14 | std::string URI; // cd; //, 34 | db::mi::member 35 | > 36 | > 37 | >seeding_object_multi_index_type; 38 | 39 | typedef graphene::db::generic_index< seeding_object, seeding_object_multi_index_type > seeding_index; 40 | 41 | }} // graphene::chain 42 | 43 | FC_REFLECT_DERIVED( graphene::chain::seeding_object, (graphene::db::object), (URI)(expiration)(cd)(seeder)(key)(size)(downloaded)(deleted)(_hash) ); 44 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/subscription_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | namespace graphene { namespace chain { 8 | 9 | class subscribe_evaluator : public evaluator 10 | { 11 | public: 12 | operation_result do_evaluate( const operation_type& o ); 13 | operation_result do_apply( const operation_type& o ); 14 | }; 15 | 16 | class subscribe_by_author_evaluator : public evaluator 17 | { 18 | public: 19 | operation_result do_evaluate( const operation_type& o ); 20 | operation_result do_apply( const operation_type& o ); 21 | }; 22 | 23 | class automatic_renewal_of_subscription_evaluator : public evaluator 24 | { 25 | public: 26 | operation_result do_evaluate( const operation_type& o ); 27 | operation_result do_apply( const operation_type& o ); 28 | }; 29 | 30 | using disallow_automatic_renewal_of_subscription_evaluator = virtual_evaluator_t; 31 | 32 | using renewal_of_subscription_evaluator = virtual_evaluator_t; 33 | 34 | } } // namespace::chain 35 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | 27 | namespace graphene { namespace chain { 28 | class database; 29 | struct signed_transaction; 30 | 31 | /** 32 | * Place holder for state tracked while processing a transaction. This class provides helper methods that are 33 | * common to many different operations and also tracks which keys have signed the transaction 34 | */ 35 | class transaction_evaluation_state 36 | { 37 | public: 38 | transaction_evaluation_state( database* db = nullptr ) : _db(db) {} 39 | 40 | database& db()const { assert( _db ); return *_db; } 41 | std::vector operation_results; 42 | 43 | const signed_transaction* _trx = nullptr; 44 | database* _db = nullptr; 45 | bool _is_proposed_trx = false; 46 | bool skip_fee = false; 47 | bool skip_fee_schedule_check = false; 48 | }; 49 | } } // namespace graphene::chain 50 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/transaction_history_object.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #pragma once 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace graphene { namespace chain { 32 | 33 | /** 34 | * @brief tracks the history of transactions 35 | * @ingroup object 36 | * @ingroup implementation 37 | * 38 | * @note By default these objects are not tracked, the transaction_history_plugin must 39 | * be loaded for these objects to be maintained. 40 | */ 41 | class transaction_history_object : public graphene::db::abstract_object 42 | { 43 | public: 44 | transaction_id_type tx_id; 45 | uint32_t block_num = 0; 46 | /** the transaction in the block */ 47 | uint16_t trx_in_block = 0; 48 | }; 49 | 50 | struct by_tx_id; 51 | typedef boost::multi_index_container< 52 | transaction_history_object, 53 | db::mi::indexed_by< 54 | db::object_id_index, 55 | db::mi::hashed_non_unique, 56 | BOOST_MULTI_INDEX_MEMBER(transaction_history_object, transaction_id_type, tx_id), std::hash 57 | > 58 | > 59 | > transaction_history_multi_index_type; 60 | 61 | typedef graphene::db::generic_index transaction_history_index; 62 | 63 | } } // graphene::chain 64 | 65 | FC_REFLECT_DERIVED( graphene::chain::transaction_history_object, (graphene::db::object), 66 | (tx_id)(block_num)(trx_in_block) ) 67 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/transaction_object.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | namespace graphene { namespace chain { 34 | /** 35 | * The purpose of this object is to enable the detection of duplicate transactions. When a transaction is included 36 | * in a block a transaction_object is added. At the end of block processing all transaction_objects that have 37 | * expired can be removed from the index. 38 | */ 39 | class transaction_object : public graphene::db::abstract_object 40 | { 41 | public: 42 | fc::time_point_sec expiration; 43 | transaction_id_type trx_id; 44 | }; 45 | 46 | struct by_expiration; 47 | struct by_trx_id; 48 | typedef boost::multi_index_container< 49 | transaction_object, 50 | db::mi::indexed_by< 51 | db::object_id_index, 52 | db::mi::hashed_unique, 53 | BOOST_MULTI_INDEX_MEMBER(transaction_object, transaction_id_type, trx_id), std::hash 54 | >, 55 | db::mi::ordered_non_unique, 56 | BOOST_MULTI_INDEX_MEMBER(transaction_object, fc::time_point_sec, expiration) 57 | > 58 | > 59 | > transaction_multi_index_type; 60 | 61 | typedef graphene::db::generic_index transaction_index; 62 | 63 | } } 64 | 65 | FC_REFLECT_DERIVED( graphene::chain::transaction_object, (graphene::db::object), (expiration)(trx_id) ) 66 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/transfer_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #pragma once 26 | #include 27 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class transfer_obsolete_evaluator : public evaluator 32 | { 33 | public: 34 | operation_result do_evaluate( const operation_type& o ); 35 | operation_result do_apply( const operation_type& o ); 36 | }; 37 | 38 | class transfer_evaluator : public evaluator 39 | { 40 | public: 41 | operation_result do_evaluate( const operation_type& o ); 42 | operation_result do_apply( const operation_type& o ); 43 | }; 44 | 45 | } } // graphene::chain 46 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/vesting_balance_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class vesting_balance_create_evaluator : public evaluator 32 | { 33 | public: 34 | operation_result do_evaluate( const operation_type& op ); 35 | operation_result do_apply( const operation_type& op ); 36 | }; 37 | 38 | class vesting_balance_withdraw_evaluator : public evaluator 39 | { 40 | public: 41 | operation_result do_evaluate( const operation_type& op ); 42 | operation_result do_apply( const operation_type& op ); 43 | }; 44 | 45 | } } // graphene::chain 46 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/vote_count.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | /** 32 | * Keep track of vote totals in internal authority object. See #533. 33 | */ 34 | struct vote_counter 35 | { 36 | template< typename Component > 37 | void add( Component who, uint64_t votes ) 38 | { 39 | if( votes == 0 ) 40 | return; 41 | assert( votes <= last_votes ); 42 | last_votes = votes; 43 | if( bitshift == -1 ) 44 | bitshift = std::max(int(boost::multiprecision::detail::find_msb( votes )) - 15, 0); 45 | uint64_t scaled_votes = std::max( votes >> bitshift, uint64_t(1) ); 46 | assert( scaled_votes <= std::numeric_limits::max() ); 47 | total_votes += scaled_votes; 48 | assert( total_votes <= std::numeric_limits::max() ); 49 | auth.add_authority( who, weight_type( scaled_votes ) ); 50 | } 51 | 52 | /** 53 | * Write into out_auth, but only if we have at least one member. 54 | */ 55 | void finish( authority& out_auth ) 56 | { 57 | if( total_votes == 0 ) 58 | return; 59 | assert( total_votes <= std::numeric_limits::max() ); 60 | uint32_t weight = uint32_t( total_votes ); 61 | weight = (weight >> 1)+1; 62 | auth.weight_threshold = weight; 63 | out_auth = auth; 64 | } 65 | 66 | bool is_empty()const 67 | { 68 | return (total_votes == 0); 69 | } 70 | 71 | uint64_t last_votes = std::numeric_limits::max(); 72 | uint64_t total_votes = 0; 73 | int bitshift = -1; 74 | authority auth; 75 | }; 76 | 77 | } } // graphene::chain 78 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/withdraw_permission_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class withdraw_permission_create_evaluator : public evaluator 32 | { 33 | public: 34 | operation_result do_evaluate( const operation_type& op ); 35 | operation_result do_apply( const operation_type& op ); 36 | }; 37 | 38 | class withdraw_permission_claim_evaluator : public evaluator 39 | { 40 | public: 41 | operation_result do_evaluate( const operation_type& op ); 42 | operation_result do_apply( const operation_type& op ); 43 | }; 44 | 45 | class withdraw_permission_update_evaluator : public evaluator 46 | { 47 | public: 48 | operation_result do_evaluate( const operation_type& op ); 49 | operation_result do_apply( const operation_type& op ); 50 | }; 51 | 52 | class withdraw_permission_delete_evaluator : public evaluator 53 | { 54 | public: 55 | operation_result do_evaluate( const operation_type& op ); 56 | operation_result do_apply( const operation_type& op ); 57 | }; 58 | 59 | } } // graphene::chain 60 | -------------------------------------------------------------------------------- /libraries/chain/message_object.cpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #include 26 | 27 | namespace graphene{ 28 | namespace chain { 29 | 30 | std::string message_object_receivers_data::get_message(const private_key_type& priv, const public_key_type& pub) const 31 | { 32 | if ( priv != private_key_type() && pub != public_key_type() ) 33 | { 34 | return memo_data::decrypt_message(data, priv, pub, nonce); 35 | } 36 | else 37 | { 38 | return memo_message::deserialize(std::string(data.begin(), data.end())).text; 39 | } 40 | } 41 | 42 | void message_receiver_index::object_inserted(const graphene::db::object &obj) { 43 | assert(dynamic_cast(&obj)); // for debug only 44 | const message_object &a = static_cast(obj); 45 | 46 | for( const auto &item : a.receivers_data ) 47 | message_to_receiver_memberships[ item.receiver ].insert(obj.id); 48 | } 49 | 50 | void message_receiver_index::object_removed(const graphene::db::object &obj) { 51 | assert(dynamic_cast(&obj)); // for debug only 52 | const message_object &a = static_cast(obj); 53 | 54 | for( const auto &item : a.receivers_data ) 55 | message_to_receiver_memberships[ item.receiver ].erase(obj.id); 56 | } 57 | 58 | void message_receiver_index::about_to_modify(const graphene::db::object &before) { 59 | } 60 | 61 | void message_receiver_index::object_modified(const graphene::db::object &after) { 62 | } 63 | 64 | }}//namespace 65 | -------------------------------------------------------------------------------- /libraries/chain/protocol/assert.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #include 25 | #include 26 | #include 27 | 28 | namespace graphene { namespace chain { 29 | 30 | bool account_name_eq_lit_predicate::validate()const 31 | { 32 | return is_valid_name( name ); 33 | } 34 | 35 | bool asset_symbol_eq_lit_predicate::validate()const 36 | { 37 | return is_valid_symbol( symbol ); 38 | } 39 | 40 | struct predicate_validator 41 | { 42 | typedef void result_type; 43 | 44 | template 45 | void operator()( const T& p )const 46 | { 47 | p.validate(); 48 | } 49 | }; 50 | 51 | void assert_operation::validate()const 52 | { 53 | FC_ASSERT( fee.amount >= 0 ); 54 | FC_ASSERT( required_auths.empty() ); 55 | 56 | for( const auto& item : predicates ) 57 | item.visit( predicate_validator() ); 58 | } 59 | 60 | /** 61 | * The fee for assert operations is proportional to their size, 62 | * but cheaper than a data fee because they require no storage 63 | */ 64 | share_type assert_operation::calculate_fee(const fee_parameters_type& k)const 65 | { 66 | return k.fee * predicates.size(); 67 | } 68 | 69 | } } // namespace graphene::chain 70 | -------------------------------------------------------------------------------- /libraries/chain/protocol/miner.cpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #include 26 | 27 | namespace graphene { namespace chain { 28 | 29 | void miner_create_operation::validate() const 30 | { 31 | FC_ASSERT(fee.amount >= 0); 32 | FC_ASSERT(url.size() < GRAPHENE_MAX_URL_LENGTH ); 33 | } 34 | 35 | void miner_update_operation::validate() const 36 | { 37 | FC_ASSERT(fee.amount >= 0); 38 | if( new_url.valid() ) 39 | FC_ASSERT(new_url->size() < GRAPHENE_MAX_URL_LENGTH ); 40 | } 41 | 42 | void miner_update_global_parameters_operation::validate() const 43 | { 44 | FC_ASSERT( fee.amount >= 0 ); 45 | new_parameters.validate(); 46 | } 47 | 48 | } } // graphene::chain 49 | -------------------------------------------------------------------------------- /libraries/chain/protocol/subscription.cpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | #include 3 | 4 | namespace graphene { namespace chain { 5 | 6 | void subscribe_operation::validate() const 7 | { 8 | FC_ASSERT( fee.amount >= 0 ); 9 | FC_ASSERT( price.amount >= 0 ); 10 | } 11 | 12 | void subscribe_by_author_operation::validate() const 13 | { 14 | FC_ASSERT( fee.amount >= 0 ); 15 | } 16 | 17 | } } // graphene::chain 18 | -------------------------------------------------------------------------------- /libraries/chain/protocol/transfer.cpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #include 26 | 27 | namespace graphene { namespace chain { 28 | 29 | void transfer_obsolete_operation::validate()const 30 | { 31 | FC_ASSERT( fee.amount >= 0 ); 32 | FC_ASSERT( from != to ); 33 | FC_ASSERT( amount.amount > 0 ); 34 | } 35 | 36 | bool transfer_obsolete_operation::is_partner_account_id(account_id_type acc_id) const 37 | { 38 | return (from == acc_id || to == acc_id) ? true : false; 39 | } 40 | 41 | void transfer_operation::validate()const 42 | { 43 | FC_ASSERT( fee.amount >= 0 ); 44 | FC_ASSERT( to.is() || to.is() ); 45 | FC_ASSERT( from != to ); 46 | FC_ASSERT( amount.amount > 0 ); 47 | } 48 | 49 | bool transfer_operation::is_partner_account_id(account_id_type acc_id) const 50 | { 51 | if (from == acc_id) 52 | return true; 53 | 54 | if (to.is() && to.as() == acc_id) 55 | return true; 56 | 57 | return false; 58 | } 59 | 60 | } } // graphene::chain 61 | -------------------------------------------------------------------------------- /libraries/chain/protocol/vote.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | vote_id_type get_next_vote_id( global_property_object& gpo, vote_id_type::vote_type type ) 32 | { 33 | return vote_id_type( type, gpo.next_available_vote_id++ ); 34 | } 35 | 36 | } } // graphene::chain 37 | 38 | namespace fc 39 | { 40 | 41 | void to_variant(const graphene::chain::vote_id_type& var, variant& vo) 42 | { 43 | vo = std::string(var); 44 | } 45 | 46 | void from_variant(const variant& var, graphene::chain::vote_id_type& vo) 47 | { 48 | vo = graphene::chain::vote_id_type(var.as_string()); 49 | } 50 | 51 | } // fc 52 | -------------------------------------------------------------------------------- /libraries/chain/protocol/withdraw_permission.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #include 25 | 26 | namespace graphene { namespace chain { 27 | 28 | void withdraw_permission_update_operation::validate()const 29 | { 30 | FC_ASSERT( withdrawal_limit.amount > 0 ); 31 | FC_ASSERT( fee.amount >= 0 ); 32 | FC_ASSERT( withdrawal_period_sec > 0 ); 33 | FC_ASSERT( withdraw_from_account != authorized_account ); 34 | FC_ASSERT( periods_until_expiration > 0 ); 35 | } 36 | 37 | void withdraw_permission_claim_operation::validate()const 38 | { 39 | FC_ASSERT( withdraw_to_account != withdraw_from_account ); 40 | FC_ASSERT( amount_to_withdraw.amount > 0 ); 41 | FC_ASSERT( fee.amount >= 0 ); 42 | } 43 | 44 | share_type withdraw_permission_claim_operation::calculate_fee(const fee_parameters_type& k)const 45 | { 46 | share_type core_fee_required = k.fee; 47 | if( memo ) 48 | core_fee_required += calculate_data_fee( fc::raw::pack_size(memo), k.price_per_kbyte ); 49 | return core_fee_required; 50 | } 51 | 52 | void withdraw_permission_create_operation::validate() const 53 | { 54 | FC_ASSERT( fee.amount >= 0 ); 55 | FC_ASSERT( withdraw_from_account != authorized_account ); 56 | FC_ASSERT( withdrawal_limit.amount > 0 ); 57 | //TODO: better bounds checking on these values 58 | FC_ASSERT( withdrawal_period_sec > 0 ); 59 | FC_ASSERT( periods_until_expiration > 0 ); 60 | } 61 | 62 | void withdraw_permission_delete_operation::validate() const 63 | { 64 | FC_ASSERT( fee.amount >= 0 ); 65 | FC_ASSERT( withdraw_from_account != authorized_account ); 66 | } 67 | 68 | 69 | } } // graphene::chain 70 | 71 | -------------------------------------------------------------------------------- /libraries/chain/transaction_detail_object.cpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | #include 3 | 4 | namespace graphene { namespace chain { 5 | 6 | share_type transaction_detail_object::get_transaction_amount() const 7 | { 8 | return m_transaction_amount.amount; 9 | } 10 | 11 | share_type transaction_detail_object::get_transaction_fee() const 12 | { 13 | return m_transaction_fee.amount; 14 | } 15 | 16 | non_fungible_token_data_id_type transaction_detail_object::get_non_fungible_token_id() const 17 | { 18 | return m_nft_data_id.valid() ? *m_nft_data_id : non_fungible_token_data_id_type(GRAPHENE_DB_MAX_INSTANCE_ID); 19 | } 20 | 21 | } } // graphene::chain 22 | -------------------------------------------------------------------------------- /libraries/contrib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( fc ) 2 | add_subdirectory( cpp-ipfs-api ) 3 | -------------------------------------------------------------------------------- /libraries/db/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/db/*.hpp") 2 | 3 | add_library( graphene_db 4 | undo_database.cpp 5 | index.cpp 6 | object_database.cpp 7 | ${HEADERS} 8 | ) 9 | 10 | target_link_libraries( graphene_db PUBLIC fc ) 11 | target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 12 | 13 | #install( TARGETS 14 | # graphene_db 15 | # 16 | # RUNTIME DESTINATION bin 17 | # LIBRARY DESTINATION lib 18 | # ARCHIVE DESTINATION lib 19 | #) 20 | -------------------------------------------------------------------------------- /libraries/db/include/graphene/db/exceptions.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { namespace db { 29 | 30 | enum db_exception_code 31 | { 32 | invalid_space_id_code = 1, 33 | invalid_type_id_code = 2, 34 | object_not_found_code = 3, 35 | invalid_index_code = 4 36 | }; 37 | 38 | FC_DECLARE_EXCEPTION(db_exception, 100, "database exception") 39 | 40 | #define FC_DECLARE_DB_EXCEPTION(TYPE, OFFSET, WHAT) \ 41 | FC_DECLARE_DERIVED_EXCEPTION(TYPE, db_exception, OFFSET, WHAT) 42 | 43 | FC_DECLARE_DB_EXCEPTION(invalid_space_id_exception, invalid_space_id_code, "Invalid space id in object identifier.") 44 | FC_DECLARE_DB_EXCEPTION(invalid_type_id_exception, invalid_type_id_code, "Invalid type id in object identifier.") 45 | FC_DECLARE_DB_EXCEPTION(object_not_found_exception, object_not_found_code, "Object not found in database.") 46 | FC_DECLARE_DB_EXCEPTION(invalid_index_exception, invalid_index_code, "Invalid database index type.") 47 | 48 | } } // graphene::db 49 | -------------------------------------------------------------------------------- /libraries/db/include/graphene/db/fwd.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | 27 | namespace graphene { namespace db { 28 | 29 | class peer; 30 | typedef std::shared_ptr peer_ptr; 31 | 32 | class peer_ram; 33 | typedef std::shared_ptr peer_ram_ptr; 34 | 35 | }} // namespace graphene::db 36 | -------------------------------------------------------------------------------- /libraries/egenesis/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/egenesis/*.hpp") 2 | 3 | add_library( graphene_egenesis_decent 4 | egenesis_decent.cpp 5 | ${HEADERS} 6 | ) 7 | 8 | target_link_libraries( graphene_egenesis_decent PRIVATE graphene_chain ) 9 | target_include_directories( graphene_egenesis_decent PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | add_library( graphene_egenesis_none 12 | egenesis_none.cpp 13 | ${HEADERS} 14 | ) 15 | 16 | target_link_libraries( graphene_egenesis_none PRIVATE graphene_chain ) 17 | target_include_directories( graphene_egenesis_none PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 18 | 19 | #install( TARGETS 20 | # graphene_egenesis_decent graphene_egenesis_none 21 | # 22 | # RUNTIME DESTINATION bin 23 | # LIBRARY DESTINATION lib 24 | # ARCHIVE DESTINATION lib 25 | #) 26 | -------------------------------------------------------------------------------- /libraries/egenesis/egenesis_none.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | 27 | namespace graphene { namespace egenesis { 28 | 29 | using namespace graphene::chain; 30 | 31 | chain_id_type get_egenesis_chain_id() 32 | { 33 | return chain_id_type(); 34 | } 35 | 36 | void compute_egenesis_json( std::string& result ) 37 | { 38 | result = ""; 39 | } 40 | 41 | fc::sha256 get_egenesis_json_hash() 42 | { 43 | return fc::sha256::hash( "" ); 44 | } 45 | 46 | } } 47 | -------------------------------------------------------------------------------- /libraries/egenesis/include/graphene/egenesis/egenesis.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace graphene { namespace egenesis { 34 | 35 | /** 36 | * Get the chain ID of the built-in egenesis, or chain_id_type() 37 | * if none was compiled in. 38 | */ 39 | graphene::chain::chain_id_type get_egenesis_chain_id(); 40 | 41 | /** 42 | * Get the egenesis JSON, or the empty string if none was compiled in. 43 | */ 44 | void compute_egenesis_json( std::string& result ); 45 | 46 | /** 47 | * The file returned by compute_egenesis_json() should have this hash. 48 | */ 49 | fc::sha256 get_egenesis_json_hash(); 50 | 51 | } } // graphene::egenesis 52 | -------------------------------------------------------------------------------- /libraries/encrypt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file( GLOB HEADERS "include/decent/encrypt/*.hpp" ) 2 | 3 | add_library( decent_encrypt 4 | encryptionutils.cpp 5 | custodyutils.cpp 6 | ${HEADERS} 7 | ) 8 | 9 | target_link_libraries( decent_encrypt PUBLIC ${CRYPTOPP_NAME} fc PRIVATE gmp pbc ) 10 | target_include_directories( decent_encrypt PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 11 | 12 | #install( TARGETS 13 | # decent_encrypt 14 | # 15 | # RUNTIME DESTINATION bin 16 | # LIBRARY DESTINATION lib 17 | # ARCHIVE DESTINATION lib 18 | #) 19 | -------------------------------------------------------------------------------- /libraries/net/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/net/*.hpp") 2 | 3 | add_library( graphene_net 4 | node.cpp 5 | stcp_socket.cpp 6 | core_messages.cpp 7 | peer_database.cpp 8 | peer_connection.cpp 9 | message_oriented_connection.cpp 10 | ${HEADERS} 11 | ) 12 | 13 | target_link_libraries( graphene_net PUBLIC graphene_chain ) 14 | target_include_directories( graphene_net PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 15 | 16 | if(MSVC) 17 | set_source_files_properties( node.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 18 | endif(MSVC) 19 | 20 | #install( TARGETS 21 | # graphene_net 22 | # 23 | # RUNTIME DESTINATION bin 24 | # LIBRARY DESTINATION lib 25 | # ARCHIVE DESTINATION lib 26 | #) 27 | -------------------------------------------------------------------------------- /libraries/net/include/graphene/net/exceptions.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { namespace net { 29 | 30 | enum net_exception_code 31 | { 32 | already_connected_to_requested_peer_code = 1, 33 | block_older_than_undo_history_code = 2, 34 | peer_is_on_an_unreachable_fork_code = 3, 35 | unlinkable_block_resync_peer_code = 4 36 | }; 37 | 38 | FC_DECLARE_EXCEPTION(net_exception, 300, "P2P Networking Exception") 39 | 40 | #define FC_DECLARE_NET_EXCEPTION(TYPE, OFFSET, WHAT) \ 41 | FC_DECLARE_DERIVED_EXCEPTION(TYPE, net_exception, OFFSET, WHAT) 42 | 43 | FC_DECLARE_NET_EXCEPTION(already_connected_to_requested_peer_exception, already_connected_to_requested_peer_code, "Already connected to requested peer.") 44 | FC_DECLARE_NET_EXCEPTION(block_older_than_undo_history_exception, block_older_than_undo_history_code, "Block is older than our undo history allows us to process.") 45 | FC_DECLARE_NET_EXCEPTION(peer_is_on_an_unreachable_fork_exception, peer_is_on_an_unreachable_fork_code, "Peer is on another fork.") 46 | FC_DECLARE_NET_EXCEPTION(unlinkable_block_resync_peer_exception, unlinkable_block_resync_peer_code, "Need of resync with peer due to unlinkable block.") 47 | 48 | } } // graphene::net 49 | -------------------------------------------------------------------------------- /libraries/package/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file( GLOB_RECURSE HEADERS "*.hpp" ) 2 | 3 | add_library( package_manager 4 | package.cpp 5 | detail.cpp 6 | ipfs_check.cpp 7 | ipfs_transfer.cpp 8 | ${HEADERS} 9 | ) 10 | 11 | target_link_libraries( package_manager PUBLIC graphene_utilities decent_encrypt PRIVATE ipfs-api ) 12 | target_include_directories( package_manager PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 13 | 14 | #install( TARGETS 15 | # package_manager 16 | # 17 | # RUNTIME DESTINATION bin 18 | # LIBRARY DESTINATION lib 19 | # ARCHIVE DESTINATION lib 20 | #) 21 | -------------------------------------------------------------------------------- /libraries/package/include/decent/ipfs_check.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | 3 | #pragma once 4 | 5 | namespace decent { 6 | 7 | /** 8 | * @brief checks IPFS version and compares with minimal supported 9 | * @param host [in] Hostname or IP address of the server to connect to. 10 | * @param port [in] Port to connect to. 11 | * @return returns true when check is OK, otherwise false 12 | */ 13 | void check_ipfs_minimal_version(const std::string& host, int port); 14 | 15 | } //namespace decent 16 | -------------------------------------------------------------------------------- /libraries/package/include/decent/package/package_config.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | #pragma once 3 | #include 4 | 5 | namespace decent { namespace package { 6 | 7 | class PackageManagerConfigurator { 8 | PackageManagerConfigurator() = default; 9 | std::string _ipfs_host = "localhost"; 10 | uint32_t _ipfs_port = 5001; 11 | 12 | public: 13 | /** 14 | * Returns singleton instance. The instance is created when the method is called the first time 15 | * @return singleton instance 16 | */ 17 | static PackageManagerConfigurator& instance() { 18 | static PackageManagerConfigurator the_configurator; 19 | return the_configurator; 20 | } 21 | 22 | void set_ipfs_endpoint(const std::string &host, uint32_t port) { _ipfs_host = host; _ipfs_port = port; } 23 | 24 | uint32_t get_ipfs_port() const { return _ipfs_port; } 25 | const std::string& get_ipfs_host() const { return _ipfs_host; } 26 | 27 | PackageManagerConfigurator(const PackageManagerConfigurator&) = delete; 28 | PackageManagerConfigurator(PackageManagerConfigurator&&) = delete; 29 | PackageManagerConfigurator& operator=(const PackageManagerConfigurator&) = delete; 30 | PackageManagerConfigurator& operator=(PackageManagerConfigurator&&) = delete; 31 | }; 32 | 33 | }} //namespace decent::package 34 | -------------------------------------------------------------------------------- /libraries/package/ipfs_check.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace decent { 11 | 12 | const unsigned int g_minimalIpfsVersion = 0x00040c00; //minimal version 0.4.12 13 | 14 | void check_ipfs_minimal_version(const std::string& host, int port) 15 | { 16 | ilog("Checking IPFS version on ${host}:${port}", ("host", host)("port", port)); 17 | ipfs::Client client(host, port); 18 | 19 | ipfs::Json version_info; 20 | client.Version(&version_info); 21 | const std::string& ver_text = version_info["Version"]; 22 | 23 | std::vector data_split; 24 | boost::split( data_split, ver_text, boost::is_any_of("."), boost::token_compress_off); 25 | if (data_split.size() != 3) 26 | FC_THROW("Invalid IPFS version \"${v}\"", ("v", ver_text)); 27 | 28 | unsigned int version = 0; 29 | version |= (boost::lexical_cast(data_split[0])) << 24; 30 | version |= (boost::lexical_cast(data_split[1])) << 16; 31 | version |= (boost::lexical_cast(data_split[2])) << 8; 32 | 33 | FC_ASSERT(version >= g_minimalIpfsVersion, "Unsupported IPFS version \"${v}\" is used. Minimal version is 0.4.12", ("v", ver_text)); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /libraries/package/ipfs_transfer.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | 3 | #pragma once 4 | 5 | #include "detail.hpp" 6 | 7 | #include 8 | 9 | #include 10 | 11 | namespace decent { namespace package { 12 | 13 | class IPFSDownloadPackageTask : public detail::PackageTask { 14 | public: 15 | explicit IPFSDownloadPackageTask(PackageInfo& package); 16 | 17 | protected: 18 | virtual void task() override; 19 | 20 | private: 21 | uint64_t ipfs_recursive_get_size(const std::string &url); 22 | void ipfs_recursive_get(const std::string &url, const boost::filesystem::path &dest_path); 23 | ipfs::Client _client; 24 | }; 25 | 26 | class IPFSStartSeedingPackageTask : public detail::PackageTask { 27 | public: 28 | explicit IPFSStartSeedingPackageTask(PackageInfo& package); 29 | 30 | protected: 31 | virtual void task() override; 32 | 33 | private: 34 | ipfs::Client _client; 35 | }; 36 | 37 | class IPFSStopSeedingPackageTask : public detail::PackageTask { 38 | public: 39 | explicit IPFSStopSeedingPackageTask(PackageInfo& package); 40 | 41 | protected: 42 | virtual void task() override; 43 | 44 | private: 45 | ipfs::Client _client; 46 | }; 47 | 48 | class IPFSTransferEngine : public TransferEngineInterface { 49 | public: 50 | virtual std::shared_ptr create_download_task(PackageInfo& package) override; 51 | virtual std::shared_ptr create_start_seeding_task(PackageInfo& package) override; 52 | virtual std::shared_ptr create_stop_seeding_task(PackageInfo& package) override; 53 | }; 54 | 55 | } } // namespace decent::package 56 | -------------------------------------------------------------------------------- /libraries/plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( miner ) 2 | add_subdirectory( account_history ) 3 | add_subdirectory( seeding ) 4 | add_subdirectory( transaction_history ) 5 | add_subdirectory( elasticsearch ) 6 | -------------------------------------------------------------------------------- /libraries/plugins/account_history/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/account_history/*.hpp") 2 | 3 | add_library( graphene_account_history 4 | account_history_plugin.cpp 5 | ${HEADERS} 6 | ) 7 | 8 | target_link_libraries( graphene_account_history PUBLIC graphene_app ) 9 | target_include_directories( graphene_account_history PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | if(MSVC) 12 | set_source_files_properties( account_history_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 13 | endif(MSVC) 14 | 15 | #install( TARGETS 16 | # graphene_account_history 17 | # 18 | # RUNTIME DESTINATION bin 19 | # LIBRARY DESTINATION lib 20 | # ARCHIVE DESTINATION lib 21 | #) 22 | -------------------------------------------------------------------------------- /libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { namespace account_history { 29 | 30 | class account_history_plugin : public graphene::app::plugin 31 | { 32 | public: 33 | account_history_plugin(graphene::app::application* app); 34 | virtual ~account_history_plugin(); 35 | 36 | static std::string plugin_name(); 37 | static void plugin_set_program_options( 38 | boost::program_options::options_description& cli, 39 | boost::program_options::options_description& cfg); 40 | 41 | virtual void plugin_initialize(const boost::program_options::variables_map& options) override; 42 | 43 | struct impl; 44 | std::unique_ptr my; 45 | }; 46 | 47 | } } //graphene::account_history 48 | -------------------------------------------------------------------------------- /libraries/plugins/elasticsearch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(CURL REQUIRED) 2 | 3 | file(GLOB_RECURSE HEADERS "*.hpp") 4 | 5 | add_library( decent_elasticsearch 6 | adaptor.cpp 7 | elasticsearch_plugin.cpp 8 | ${HEADERS} 9 | ) 10 | 11 | target_link_libraries( decent_elasticsearch PUBLIC graphene_app PRIVATE ${CURL_LIBRARIES} ) 12 | target_include_directories( decent_elasticsearch PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" PRIVATE ${CURL_INCLUDE_DIRS} ) 13 | 14 | if(MSVC) 15 | set_source_files_properties(elasticsearch_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 16 | endif(MSVC) 17 | 18 | #install( TARGETS 19 | # decent_elasticsearch 20 | 21 | # RUNTIME DESTINATION bin 22 | # LIBRARY DESTINATION lib 23 | # ARCHIVE DESTINATION lib 24 | #) 25 | -------------------------------------------------------------------------------- /libraries/plugins/elasticsearch/include/graphene/elasticsearch/elasticsearch_plugin.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 oxarbitrage, and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace decent { namespace elasticsearch { 29 | 30 | class elasticsearch_plugin : public graphene::app::plugin 31 | { 32 | public: 33 | elasticsearch_plugin(graphene::app::application* app); 34 | virtual ~elasticsearch_plugin(); 35 | 36 | static std::string plugin_name(); 37 | static void plugin_set_program_options( 38 | boost::program_options::options_description &command_line_options, 39 | boost::program_options::options_description &config_file_options 40 | ); 41 | 42 | virtual void plugin_initialize( const boost::program_options::variables_map& options ) override; 43 | virtual void plugin_shutdown() override; 44 | 45 | struct impl; 46 | std::unique_ptr my; 47 | }; 48 | 49 | } } //decent::elasticsearch 50 | -------------------------------------------------------------------------------- /libraries/plugins/miner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/miner/*.hpp") 2 | 3 | add_library( graphene_miner 4 | miner.cpp 5 | ${HEADERS} 6 | ) 7 | 8 | target_link_libraries( graphene_miner PUBLIC graphene_app ) 9 | target_include_directories( graphene_miner PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | #install( TARGETS 12 | # graphene_miner 13 | # 14 | # RUNTIME DESTINATION bin 15 | # LIBRARY DESTINATION lib 16 | # ARCHIVE DESTINATION lib 17 | #) 18 | -------------------------------------------------------------------------------- /libraries/plugins/seeding/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/seeding/*.hpp") 2 | 3 | add_library( decent_seeding 4 | seeding.cpp 5 | ${HEADERS} 6 | ) 7 | 8 | target_link_libraries( decent_seeding PUBLIC graphene_app PRIVATE package_manager ipfs-api ) 9 | target_include_directories( decent_seeding PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | #install( TARGETS 12 | # decent_seeding 13 | # 14 | # RUNTIME DESTINATION bin 15 | # LIBRARY DESTINATION lib 16 | # ARCHIVE DESTINATION lib 17 | #) 18 | -------------------------------------------------------------------------------- /libraries/plugins/seeding/include/graphene/seeding/seeding.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace decent { namespace seeding { 7 | 8 | struct seeding_plugin_impl; 9 | 10 | class seeding_plugin : public graphene::app::plugin 11 | { 12 | public: 13 | seeding_plugin(graphene::app::application* app); 14 | virtual ~seeding_plugin(); 15 | 16 | static std::string plugin_name(); 17 | 18 | /** 19 | * Extend program options with our option list 20 | * @param cli CLI parameters 21 | * @param cfg Config file parameters 22 | */ 23 | static void plugin_set_program_options( 24 | boost::program_options::options_description& cli, 25 | boost::program_options::options_description& cfg); 26 | 27 | /** 28 | * Initialize plugin based on config parameters 29 | * @param options 30 | */ 31 | void plugin_initialize(const boost::program_options::variables_map& options) override; 32 | /** 33 | * Start the plugin and begin work. 34 | */ 35 | void plugin_startup() override; 36 | 37 | std::unique_ptr my; 38 | }; 39 | 40 | }} 41 | -------------------------------------------------------------------------------- /libraries/plugins/transaction_history/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/transaction_history/*.hpp") 2 | 3 | add_library( graphene_transaction_history 4 | transaction_history_plugin.cpp 5 | ${HEADERS} 6 | ) 7 | 8 | target_link_libraries( graphene_transaction_history PUBLIC graphene_app ) 9 | target_include_directories( graphene_transaction_history PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | if(MSVC) 12 | set_source_files_properties( transaction_history_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 13 | endif(MSVC) 14 | 15 | #install( TARGETS 16 | # graphene_transaction_history 17 | # 18 | # RUNTIME DESTINATION bin 19 | # LIBRARY DESTINATION lib 20 | # ARCHIVE DESTINATION lib 21 | #) 22 | -------------------------------------------------------------------------------- /libraries/plugins/transaction_history/include/graphene/transaction_history/transaction_history_plugin.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { namespace transaction_history { 29 | 30 | class transaction_history_plugin : public graphene::app::plugin 31 | { 32 | public: 33 | transaction_history_plugin(graphene::app::application* app); 34 | virtual ~transaction_history_plugin(); 35 | 36 | static std::string plugin_name(); 37 | static void plugin_set_program_options( 38 | boost::program_options::options_description& cli, 39 | boost::program_options::options_description& cfg); 40 | 41 | virtual void plugin_initialize(const boost::program_options::variables_map& options) override; 42 | 43 | struct impl; 44 | std::unique_ptr my; 45 | }; 46 | 47 | } } //graphene::transaction_history 48 | -------------------------------------------------------------------------------- /libraries/utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../contrib/fc/GitVersionGen" ) 2 | include( GetGitRevisionDescription ) 3 | git_describe(GRAPHENE_GIT_REVISION_DESCRIPTION --tags) 4 | if(NOT GRAPHENE_GIT_REVISION_DESCRIPTION) 5 | message( FATAL_ERROR "Could not get Git revision" ) 6 | endif() 7 | 8 | file(GLOB HEADERS "include/decent/*.hpp" "include/graphene/utilities/*.hpp") 9 | 10 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" @ONLY) 11 | 12 | add_library( graphene_utilities 13 | decent_config.cpp 14 | key_conversion.cpp 15 | keys_generator.cpp 16 | string_escape.cpp 17 | dirhelper.cpp 18 | time.cpp 19 | words.cpp 20 | about.cpp 21 | ${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp 22 | ${HEADERS} 23 | ) 24 | 25 | target_link_libraries( graphene_utilities PUBLIC fc ) 26 | target_include_directories( graphene_utilities PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 27 | 28 | #install( TARGETS 29 | # graphene_utilities 30 | # 31 | # RUNTIME DESTINATION bin 32 | # LIBRARY DESTINATION lib 33 | # ARCHIVE DESTINATION lib 34 | #) 35 | -------------------------------------------------------------------------------- /libraries/utilities/about.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | #if OPENSSL_VERSION_NUMBER >= 0x10100000L 8 | #include 9 | #endif 10 | #include 11 | 12 | #include 13 | 14 | namespace decent { 15 | 16 | std::string get_boost_version() 17 | { 18 | return boost::replace_all_copy(std::string(BOOST_LIB_VERSION), "_", "."); 19 | } 20 | 21 | std::string get_openssl_version() 22 | { 23 | #if OPENSSL_VERSION_NUMBER >= 0x10100000L 24 | return OpenSSL_version(OPENSSL_VERSION); 25 | #else 26 | return OPENSSL_VERSION_TEXT; 27 | #endif 28 | } 29 | 30 | std::string get_cryptopp_version() 31 | { 32 | return std::to_string(CRYPTOPP_VERSION / 100).append(1, '.') 33 | .append(std::to_string(CRYPTOPP_VERSION % 100 / 10)).append(1, '.') 34 | .append(std::to_string(CRYPTOPP_VERSION % 10)); 35 | } 36 | 37 | about_info get_about_info() 38 | { 39 | return { 40 | graphene::utilities::git_version(), 41 | get_boost_version(), 42 | get_openssl_version(), 43 | get_cryptopp_version(), 44 | #if defined(__APPLE__) 45 | "osx " 46 | #elif defined(__linux__) 47 | "linux " 48 | #elif defined(_MSC_VER) 49 | "win32 " 50 | #else 51 | "other " 52 | #endif 53 | + std::to_string(8 * sizeof(int*)) + "-bit" 54 | }; 55 | } 56 | 57 | void dump_version_info(const char *caption) 58 | { 59 | std::cout << caption << ' ' << graphene::utilities::git_version(); 60 | #ifndef NDEBUG 61 | std::cout << " (debug)"; 62 | #endif 63 | std::cout << "\nBoost " << get_boost_version() << "\n" << get_openssl_version() << "\nCryptopp " << get_cryptopp_version() << std::endl; 64 | } 65 | 66 | bool check_unrecognized(const boost::program_options::parsed_options& optparsed) 67 | { 68 | std::vector unrecognized_args = boost::program_options::collect_unrecognized(optparsed.options, boost::program_options::include_positional); 69 | if(unrecognized_args.empty()) 70 | return false; 71 | 72 | std::cerr << "Unrecognized argument(s):"; 73 | for(auto const& item : unrecognized_args) 74 | std::cerr << ' ' << item; 75 | 76 | std::cerr << std::endl; 77 | return true; 78 | } 79 | 80 | } //namespace decent 81 | -------------------------------------------------------------------------------- /libraries/utilities/dirhelper.cpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | 3 | #include 4 | #include 5 | 6 | #if defined( _MSC_VER ) 7 | #include 8 | #else 9 | #include 10 | #include 11 | #include 12 | #endif 13 | #include 14 | 15 | namespace graphene { namespace utilities { 16 | 17 | decent_path_finder::decent_path_finder() 18 | { 19 | #if defined( _MSC_VER ) 20 | PWSTR path = NULL; 21 | HRESULT hr = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &path); 22 | if (SUCCEEDED(hr)) { 23 | _user_home = std::wstring(path); 24 | CoTaskMemFree(path); 25 | } 26 | #else 27 | passwd *pw = getpwuid(getuid()); 28 | if (pw && pw->pw_dir) { 29 | _user_home = pw->pw_dir; 30 | } 31 | #endif 32 | 33 | const char* decent_home = getenv("DECENT_HOME"); 34 | if (decent_home == NULL) { 35 | _decent_home = _user_home / ".decent"; 36 | } else { 37 | _decent_home = decent_home; 38 | } 39 | 40 | const char* decent_logs = getenv("DECENT_LOGS"); 41 | if (decent_logs == NULL) { 42 | _decent_logs = _decent_home / "logs"; 43 | } else { 44 | _decent_logs = decent_logs; 45 | } 46 | 47 | const char* decent_temp = getenv("DECENT_TEMP"); 48 | if (decent_temp == NULL) { 49 | _decent_temp = _decent_home / "temp"; 50 | } else { 51 | _decent_temp = decent_temp; 52 | } 53 | 54 | const char* decent_data = getenv("DECENT_DATA"); 55 | if (decent_data == NULL) { 56 | _decent_data = _decent_home / "data"; 57 | } else { 58 | _decent_data = decent_data; 59 | } 60 | 61 | const char* ipfs_bin_dir = getenv("IPFS_BIN"); 62 | if (ipfs_bin_dir != NULL) { 63 | _ipfs_bin = ipfs_bin_dir; 64 | } 65 | 66 | const char* ipfs_path_dir = getenv("IPFS_PATH"); 67 | if (ipfs_path_dir != NULL) { 68 | _ipfs_path = ipfs_path_dir; 69 | } 70 | 71 | create_directories(_decent_home); 72 | create_directories(_decent_data); 73 | create_directories(_decent_logs); 74 | create_directories(_decent_temp); 75 | } 76 | 77 | } } // graphene::utilities 78 | -------------------------------------------------------------------------------- /libraries/utilities/git_revision.cpp.in: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { namespace utilities { 4 | 5 | std::string git_version() 6 | { 7 | std::string version("@GRAPHENE_GIT_REVISION_DESCRIPTION@"); 8 | const size_t pos = version.find( '/' ); 9 | return pos != std::string::npos && version.size() > pos ? version.substr( pos + 1 ) : version; 10 | } 11 | 12 | } } // end namespace graphene::utilities 13 | -------------------------------------------------------------------------------- /libraries/utilities/include/decent/about.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace decent { 6 | 7 | struct about_info { 8 | std::string version; 9 | std::string boost_version; 10 | std::string openssl_version; 11 | std::string cryptopp_version; 12 | std::string build; 13 | }; 14 | 15 | about_info get_about_info(); 16 | 17 | void dump_version_info(const char *caption); 18 | 19 | bool check_unrecognized(const boost::program_options::parsed_options& optparsed); 20 | 21 | } 22 | 23 | FC_REFLECT( decent::about_info, 24 | (version) 25 | (boost_version) 26 | (openssl_version) 27 | (cryptopp_version) 28 | (build) 29 | ) 30 | -------------------------------------------------------------------------------- /libraries/utilities/include/decent/decent_config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace boost { 8 | namespace filesystem { 9 | class path; 10 | } 11 | namespace program_options { 12 | class options_description; 13 | } 14 | } 15 | namespace decent { 16 | 17 | void write_default_config_file(boost::filesystem::path config_ini_filename, const boost::program_options::options_description &cfg_options, bool is_daemon); 18 | 19 | fc::optional load_logging_config_from_ini_file(boost::filesystem::path config_ini_filename, const boost::filesystem::path& logs_dir); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/dirhelper.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | namespace graphene { namespace utilities { 9 | 10 | class decent_path_finder { 11 | private: 12 | // Constructor may throw exceptions. Which is bad in general, but if it fails program execution must be terminated 13 | decent_path_finder(); 14 | decent_path_finder(const decent_path_finder&) = delete; 15 | 16 | public: 17 | static decent_path_finder& instance() { 18 | static decent_path_finder theChoosenOne; 19 | return theChoosenOne; 20 | } 21 | 22 | public: 23 | boost::filesystem::path get_user_home() const { return _user_home; } 24 | 25 | boost::filesystem::path get_decent_home() const { return _decent_home; } 26 | boost::filesystem::path get_decent_data() const { return _decent_data; } 27 | boost::filesystem::path get_decent_logs() const { return _decent_logs; } 28 | boost::filesystem::path get_decent_temp() const { return _decent_temp; } 29 | boost::filesystem::path get_ipfs_bin() const { return _ipfs_bin; } 30 | boost::filesystem::path get_ipfs_path() const { return _ipfs_path; } 31 | boost::filesystem::path get_decent_packages() const { return _packages_path.valid() ? *_packages_path : _decent_data / "packages"; } 32 | 33 | void set_decent_data_path(const boost::filesystem::path& path) { _decent_data = path; } 34 | void set_decent_logs_path(const boost::filesystem::path& path) { _decent_logs = path; } 35 | void set_decent_temp_path(const boost::filesystem::path& path) { _decent_temp = path; } 36 | void set_packages_path(const boost::filesystem::path& path) { _packages_path = path; } 37 | 38 | private: 39 | boost::filesystem::path _user_home; 40 | boost::filesystem::path _decent_home; 41 | boost::filesystem::path _decent_data; 42 | boost::filesystem::path _decent_logs; 43 | boost::filesystem::path _decent_temp; 44 | boost::filesystem::path _ipfs_bin; 45 | boost::filesystem::path _ipfs_path; 46 | fc::optional _packages_path; 47 | }; 48 | 49 | } } // graphene::utilities 50 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/git_revision.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | 27 | namespace graphene { namespace utilities { 28 | 29 | std::string git_version(); 30 | 31 | } } // end namespace graphene::utilities 32 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/key_conversion.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace graphene { namespace utilities { 31 | 32 | std::string key_to_wif(const fc::sha256& private_secret ); 33 | std::string key_to_wif(const fc::ecc::private_key& key); 34 | fc::optional wif_to_key( const std::string& wif_key ); 35 | 36 | } } // end namespace graphene::utilities 37 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/keys_generator.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #pragma once 26 | 27 | #include 28 | 29 | namespace graphene { namespace utilities { 30 | 31 | fc::ecc::private_key derive_private_key(const std::string& brain_key, int sequence_number = 0); 32 | std::string normalize_brain_key(const std::string &brain_key); 33 | std::string generate_brain_key(); 34 | 35 | } } // end namespace graphene::utilities 36 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/padding_ostream.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | namespace graphene { namespace utilities { 27 | 28 | template 29 | class padding_ostream : public fc::buffered_ostream { 30 | public: 31 | padding_ostream( fc::ostream_ptr o, size_t bufsize = 4096 ) : buffered_ostream(o, bufsize) {} 32 | virtual ~padding_ostream() {} 33 | 34 | virtual size_t writesome( const char* buffer, size_t len ) { 35 | auto out = buffered_ostream::writesome(buffer, len); 36 | bytes_out += out; 37 | bytes_out %= BlockSize; 38 | return out; 39 | } 40 | virtual size_t writesome( const std::shared_ptr& buf, size_t len, size_t offset ) { 41 | auto out = buffered_ostream::writesome(buf, len, offset); 42 | bytes_out += out; 43 | bytes_out %= BlockSize; 44 | return out; 45 | } 46 | virtual void flush() { 47 | static const char pad = PaddingChar; 48 | while( bytes_out % BlockSize ) 49 | writesome(&pad, 1); 50 | buffered_ostream::flush(); 51 | } 52 | 53 | private: 54 | size_t bytes_out = 0; 55 | }; 56 | 57 | } } //graphene::utilities 58 | 59 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/string_escape.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | /* 3 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 4 | * 5 | * The MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | #pragma once 26 | 27 | #include 28 | 29 | namespace graphene { namespace utilities { 30 | 31 | std::string escape_string_for_c_source_code(const std::string& input); 32 | std::string json_unescape_string(const std::string& s); 33 | std::string json_escape_string(const std::string& s); 34 | 35 | } } // end namespace graphene::utilities 36 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/time.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace graphene { namespace utilities { 31 | 32 | typedef boost::signals2::signal time_discontinuity_signal_type; 33 | extern time_discontinuity_signal_type time_discontinuity_signal; 34 | 35 | fc::optional ntp_time(); 36 | fc::time_point now(); 37 | fc::time_point nonblocking_now(); // identical to now() but guaranteed not to block 38 | void update_ntp_time(); 39 | fc::microseconds ntp_error(); 40 | void shutdown_ntp_time(); 41 | 42 | void start_simulated_time( const fc::time_point sim_time ); 43 | void advance_simulated_time_to( const fc::time_point sim_time ); 44 | void advance_time( int32_t delta_seconds ); 45 | 46 | } } // graphene::utilities 47 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/words.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | namespace graphene { namespace words { 27 | 28 | typedef const char* const_char_ptr; 29 | extern const const_char_ptr word_list[]; 30 | extern const uint32_t word_list_size; 31 | 32 | } } 33 | -------------------------------------------------------------------------------- /libraries/wallet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE HEADERS "*.hpp") 2 | 3 | find_package( Perl ) 4 | find_package( Doxygen ) 5 | 6 | if( PERL_FOUND AND DOXYGEN_FOUND ) 7 | configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ) 8 | add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doxygen/perlmod/DoxyDocs.pm 9 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 10 | COMMAND ${DOXYGEN_EXECUTABLE} 11 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${CMAKE_CURRENT_SOURCE_DIR}/include/graphene/wallet/wallet.hpp ) 12 | add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp 13 | COMMAND ${PERL_EXECUTABLE} -I${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new 14 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp 15 | COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new 16 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/doxygen/perlmod/DoxyDocs.pm ) 17 | else() 18 | # no perl and doxygen, generate the best docs we can at runtime from reflection 19 | add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp 20 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/api_documentation_standin.cpp ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp 21 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/api_documentation_standin.cpp ) 22 | endif() 23 | 24 | add_library( graphene_wallet 25 | wallet.cpp 26 | wallet_impl.cpp 27 | wallet_utility.cpp 28 | operation_printer.cpp 29 | ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp 30 | ${HEADERS} 31 | ) 32 | 33 | target_link_libraries( graphene_wallet PUBLIC graphene_app PRIVATE package_manager ipfs-api ) 34 | target_include_directories( graphene_wallet PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 35 | 36 | if(MSVC) 37 | set_source_files_properties( wallet.cpp wallet_impl.cpp wallet_utility.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 38 | endif(MSVC) 39 | 40 | #install( TARGETS 41 | # graphene_wallet 42 | # 43 | # RUNTIME DESTINATION bin 44 | # LIBRARY DESTINATION lib 45 | # ARCHIVE DESTINATION lib 46 | #) 47 | -------------------------------------------------------------------------------- /libraries/wallet/include/graphene/wallet/wallet_utility.hpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace boost { namespace filesystem { class path; } } 10 | 11 | namespace graphene { namespace wallet { 12 | struct server_data; 13 | class wallet_api; 14 | 15 | typedef typename fc::api::vtable_type db_api; 16 | typedef typename fc::api::vtable_type net_api; 17 | 18 | class WalletAPI 19 | { 20 | public: 21 | WalletAPI(); 22 | ~WalletAPI(); 23 | 24 | void Connect(const boost::filesystem::path &wallet_file, const graphene::wallet::server_data &ws); 25 | std::string RunTask(std::string const& str_command); 26 | 27 | bool is_connected() { std::lock_guard lock(m_mutex); return m_pimpl != nullptr; } 28 | 29 | template 30 | auto query(std::function db_api::* func, Values... values) 31 | { 32 | std::lock_guard lock(m_mutex); 33 | return m_pthread->async([=, api = get_db_api()]() -> Result { return ((*api).*func)(values...); }); 34 | } 35 | 36 | template 37 | auto broadcast(std::function net_api::* func, Values... values) 38 | { 39 | std::lock_guard lock(m_mutex); 40 | return m_pthread->async([=, api = get_net_api()]() -> Result { return ((*api).*func)(values...); }); 41 | } 42 | 43 | template 44 | auto exec(Result (wallet_api::* func)(Args...), Values... values) 45 | { 46 | std::lock_guard lock(m_mutex); 47 | return m_pthread->async([=, api = get_api()]() -> Result { return (api.get()->*func)(values...); }); 48 | } 49 | 50 | template 51 | auto exec(Result (wallet_api::* func)(Args...) const, Values... values) 52 | { 53 | std::lock_guard lock(m_mutex); 54 | return m_pthread->async([=, api = get_api()]() -> Result { return (api.get()->*func)(values...); }); 55 | } 56 | 57 | private: 58 | fc::api get_db_api() const; 59 | fc::api get_net_api() const; 60 | std::shared_ptr get_api() const; 61 | 62 | // wallet_api does not like to be accessed from several threads 63 | // so all the access is encapsulated inside m_pthread :( 64 | std::mutex m_mutex; 65 | std::unique_ptr m_pthread; 66 | 67 | struct Impl; 68 | std::unique_ptr m_pimpl; 69 | }; 70 | 71 | } } 72 | -------------------------------------------------------------------------------- /programs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(cli_wallet) 2 | add_subdirectory(decentd) 3 | -------------------------------------------------------------------------------- /programs/build_helpers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | file( GLOB HEADERS "*.hpp" ) 3 | 4 | # We only actually need Boost, but link against FC for now so we don't duplicate it. 5 | 6 | add_executable( cat-parts 7 | cat-parts.cpp 8 | ${HEADERS} ) 9 | target_link_libraries( cat-parts 10 | PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 11 | 12 | add_executable( member_enumerator 13 | member_enumerator.cpp 14 | ${HEADERS} ) 15 | target_link_libraries( member_enumerator 16 | PRIVATE graphene_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 17 | -------------------------------------------------------------------------------- /programs/build_helpers/cat-parts.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | int main( int argc, char** argv, char** envp ) 12 | { 13 | if( argc != 3 ) 14 | { 15 | std::cerr << "syntax: cat-parts DIR OUTFILE" << std::endl; 16 | return 1; 17 | } 18 | 19 | boost::filesystem::path p(argv[1]); 20 | 21 | try 22 | { 23 | std::vector< boost::filesystem::path > v; 24 | 25 | for( boost::filesystem::directory_iterator it(p); 26 | it != boost::filesystem::directory_iterator(); 27 | ++it ) 28 | { 29 | boost::filesystem::path pit = it->path(); 30 | std::string spit = pit.generic_string(); 31 | size_t n = spit.length(); 32 | if( n <= 3 ) 33 | continue; 34 | if( spit.substr(n-3, 3) != ".hf" ) 35 | continue; 36 | v.push_back( pit ); 37 | } 38 | std::sort( v.begin(), v.end() ); 39 | 40 | // open each file and grab its contents, concatenating into single stringstream 41 | std::stringstream ss_data; 42 | for( const boost::filesystem::path& p : v ) 43 | { 44 | boost::filesystem::ifstream ifs(p); 45 | ss_data << ifs.rdbuf(); 46 | } 47 | std::string new_data = ss_data.str(); 48 | 49 | boost::filesystem::path opath(argv[2]); 50 | 51 | if( boost::filesystem::exists( opath ) ) 52 | { 53 | boost::filesystem::ifstream ifs(opath); 54 | std::stringstream ss_old_data; 55 | ss_old_data << ifs.rdbuf(); 56 | std::string old_data = ss_old_data.str(); 57 | if( old_data == new_data ) 58 | { 59 | std::cerr << "File " << opath << " up-to-date with .d directory" << std::endl; 60 | return 0; 61 | } 62 | } 63 | 64 | { 65 | boost::filesystem::create_directories(opath.parent_path()); 66 | boost::filesystem::ofstream ofs(opath); 67 | ofs.write( new_data.c_str(), new_data.length() ); 68 | } 69 | 70 | std::cerr << "Built " << opath << " from .d directory" << std::endl; 71 | } 72 | catch( const boost::filesystem::filesystem_error& e ) 73 | { 74 | std::cout << e.what() << std::endl; 75 | return 1; 76 | } 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /programs/cli_wallet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( cli_wallet main.cpp ) 2 | target_link_libraries( cli_wallet PRIVATE package_manager graphene_wallet ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 3 | 4 | if(MSVC) 5 | set_source_files_properties( main.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 6 | endif(MSVC) 7 | 8 | install( TARGETS 9 | cli_wallet 10 | 11 | RUNTIME DESTINATION bin 12 | LIBRARY DESTINATION lib 13 | ARCHIVE DESTINATION lib 14 | ) 15 | -------------------------------------------------------------------------------- /programs/decentd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( decentd main.cpp ) 2 | if( WIN32 ) 3 | target_sources( decentd PRIVATE winsvc.cpp winsvc.hpp ) 4 | endif() 5 | 6 | target_link_libraries( decentd PRIVATE 7 | graphene_app 8 | graphene_account_history 9 | graphene_transaction_history 10 | decent_seeding 11 | decent_elasticsearch 12 | graphene_miner 13 | ${CMAKE_DL_LIBS} 14 | ${PLATFORM_SPECIFIC_LIBS} 15 | ) 16 | 17 | install( TARGETS 18 | decentd 19 | 20 | RUNTIME DESTINATION bin 21 | LIBRARY DESTINATION lib 22 | ARCHIVE DESTINATION lib 23 | ) 24 | -------------------------------------------------------------------------------- /programs/decentd/saltpass.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import base64 4 | import getpass 5 | import hashlib 6 | import json 7 | import os 8 | 9 | pw = getpass.getpass("enter your password: ") 10 | pw_bytes = pw.encode("utf-8") 11 | salt_bytes = os.urandom(8) 12 | salt_b64 = base64.b64encode( salt_bytes ) 13 | pw_hash = hashlib.sha256( pw_bytes + salt_bytes ).digest() 14 | pw_hash_b64 = base64.b64encode( pw_hash ) 15 | 16 | print(json.dumps( 17 | { 18 | "password_hash_b64" : pw_hash_b64.decode("ascii"), 19 | "password_salt_b64" : salt_b64.decode("ascii"), 20 | }, 21 | sort_keys=True, 22 | indent=3, separators=(',', ' : ') 23 | )) 24 | -------------------------------------------------------------------------------- /programs/decentd/winsvc.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #define SVCNAME "DCore" 5 | #define SVCDISPLAYNAME "DCore Network Node" 6 | #define SVCDESCRIPTION "Fast, powerful and cost-efficient blockchain" 7 | 8 | DWORD install_win_service(); 9 | DWORD remove_win_service(); 10 | -------------------------------------------------------------------------------- /programs/delayed_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( delayed_node 2 | delayed_node_plugin.cpp 3 | delayed_node_plugin.hpp 4 | main.cpp 5 | ) 6 | 7 | target_link_libraries( delayed_node PRIVATE 8 | graphene_app 9 | graphene_account_history 10 | graphene_transaction_history 11 | ${CMAKE_DL_LIBS} 12 | ${PLATFORM_SPECIFIC_LIBS} 13 | ) 14 | 15 | if(MSVC) 16 | set_source_files_properties( delayed_node_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 17 | endif(MSVC) 18 | 19 | #install( TARGETS 20 | # delayed_node 21 | # 22 | # RUNTIME DESTINATION bin 23 | # LIBRARY DESTINATION lib 24 | # ARCHIVE DESTINATION lib 25 | #) 26 | -------------------------------------------------------------------------------- /programs/delayed_node/delayed_node_plugin.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { namespace delayed_node { 29 | namespace detail { struct delayed_node_plugin_impl; } 30 | 31 | class delayed_node_plugin : public graphene::app::plugin 32 | { 33 | std::unique_ptr my; 34 | public: 35 | delayed_node_plugin(graphene::app::application* app); 36 | virtual ~delayed_node_plugin(); 37 | 38 | static std::string plugin_name() { return "delayed_node"; } 39 | static void plugin_set_program_options(boost::program_options::options_description&, 40 | boost::program_options::options_description& cfg); 41 | 42 | virtual void plugin_initialize(const boost::program_options::variables_map& options) override; 43 | virtual void plugin_startup() override; 44 | void mainloop(); 45 | 46 | protected: 47 | void connection_failed(); 48 | void connect(); 49 | void sync_with_trusted_node(); 50 | }; 51 | 52 | } } //graphene::account_history 53 | 54 | -------------------------------------------------------------------------------- /programs/genesis_util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( embed_genesis embed_genesis.cpp ) 2 | 3 | target_link_libraries( embed_genesis PRIVATE graphene_chain graphene_db graphene_app graphene_egenesis_none decent_encrypt ) 4 | 5 | set( embed_genesis_args 6 | -t "${CMAKE_CURRENT_SOURCE_DIR}/egenesis_brief.cpp.tmpl---${CMAKE_CURRENT_BINARY_DIR}/egenesis_brief.cpp" 7 | -t "${CMAKE_CURRENT_SOURCE_DIR}/egenesis_full.cpp.tmpl---${CMAKE_CURRENT_BINARY_DIR}/egenesis_full.cpp" 8 | ) 9 | 10 | if( GRAPHENE_EGENESIS_JSON ) 11 | MESSAGE( STATUS "egenesis: " ${GRAPHENE_EGENESIS_JSON} ) 12 | list( APPEND embed_genesis_args --genesis-json "${GRAPHENE_EGENESIS_JSON}" ) 13 | else( GRAPHENE_EGENESIS_JSON ) 14 | MESSAGE( STATUS "egenesis: none" ) 15 | endif( GRAPHENE_EGENESIS_JSON ) 16 | 17 | MESSAGE( STATUS "embed_genesis_args: " ${embed_genesis_args} ) 18 | 19 | add_custom_command( 20 | OUTPUT 21 | "${CMAKE_CURRENT_BINARY_DIR}/egenesis_brief.cpp" 22 | "${CMAKE_CURRENT_BINARY_DIR}/egenesis_full.cpp" 23 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 24 | COMMAND embed_genesis ${embed_genesis_args} 25 | DEPENDS 26 | "${GRAPHENE_EGENESIS_JSON}" 27 | "${CMAKE_CURRENT_SOURCE_DIR}/egenesis_brief.cpp.tmpl" 28 | "${CMAKE_CURRENT_SOURCE_DIR}/egenesis_full.cpp.tmpl" 29 | embed_genesis ) 30 | 31 | add_library( graphene_egenesis_brief "${CMAKE_CURRENT_BINARY_DIR}/egenesis_brief.cpp" ${HEADERS} ) 32 | add_library( graphene_egenesis_full "${CMAKE_CURRENT_BINARY_DIR}/egenesis_full.cpp" ${HEADERS} ) 33 | 34 | target_link_libraries( graphene_egenesis_brief PRIVATE graphene_chain graphene_db decent_encrypt ) 35 | target_link_libraries( graphene_egenesis_full PRIVATE graphene_chain graphene_db decent_encrypt ) 36 | 37 | target_include_directories( graphene_egenesis_brief 38 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 39 | target_include_directories( graphene_egenesis_full 40 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 41 | 42 | add_executable( genesis_update genesis_update.cpp ) 43 | 44 | target_link_libraries( genesis_update 45 | PRIVATE graphene_app graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 46 | 47 | install( TARGETS 48 | genesis_update 49 | 50 | RUNTIME DESTINATION bin 51 | LIBRARY DESTINATION lib 52 | ARCHIVE DESTINATION lib 53 | ) 54 | 55 | add_executable( get_dev_key get_dev_key.cpp ) 56 | 57 | target_link_libraries( get_dev_key 58 | PRIVATE graphene_app graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 59 | 60 | #install( TARGETS 61 | # embed_genesis graphene_egenesis_brief graphene_egenesis_full get_dev_key 62 | # 63 | # RUNTIME DESTINATION bin 64 | # LIBRARY DESTINATION lib 65 | # ARCHIVE DESTINATION lib 66 | #) 67 | -------------------------------------------------------------------------------- /programs/genesis_util/apply_patch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Apply a patch file to a JSON object") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-d", "--delta", metavar="DELTA", nargs="+", help="list of delta file(s) to apply") 19 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 20 | opts = parser.parse_args() 21 | 22 | if opts.input == "-": 23 | genesis = json.load(sys.stdin) 24 | else: 25 | with open(opts.input, "r") as f: 26 | genesis = json.load(f) 27 | 28 | if opts.delta is None: 29 | opts.delta = [] 30 | for filename in opts.delta: 31 | with open(filename, "r") as f: 32 | patch = json.load(f) 33 | for k, v in patch.get("append", {}).items(): 34 | if k not in genesis: 35 | genesis[k] = [] 36 | sys.stderr.write("[WARN] item {k} was created\n".format(k=k)) 37 | genesis[k].extend(v) 38 | sys.stderr.write("appended {n} items to {k}\n".format(n=len(v), k=k)) 39 | for k, v in patch.get("replace", {}).items(): 40 | genesis[k] = v 41 | sys.stderr.write("replaced item {k}\n".format(k=k)) 42 | 43 | if opts.output == "-": 44 | dump_json( genesis, sys.stdout, opts.pretty ) 45 | sys.stdout.flush() 46 | else: 47 | with open(opts.output, "w") as f: 48 | dump_json( genesis, f, opts.pretty ) 49 | return 50 | 51 | if __name__ == "__main__": 52 | main() 53 | -------------------------------------------------------------------------------- /programs/genesis_util/canonical_format.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | if len(sys.argv) < 3: 8 | print("syntax: "+sys.argv[0]+" INFILE OUTFILE") 9 | sys.exit(0) 10 | 11 | with open(sys.argv[1], "r") as infile: 12 | genesis = json.load(infile) 13 | with open(sys.argv[2], "w") as outfile: 14 | json.dump(genesis, outfile, separators=(',', ':'), sort_keys=True) 15 | -------------------------------------------------------------------------------- /programs/genesis_util/change_asset_symbol.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Change an asset's symbol with referential integrity") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-f", "--from", metavar="PREFIX", default="", help="initial prefix") 19 | parser.add_argument("-t", "--to", metavar="PREFIX", default="", help="new prefix") 20 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 21 | opts = parser.parse_args() 22 | 23 | if opts.input == "-": 24 | genesis = json.load(sys.stdin) 25 | else: 26 | with open(opts.input, "r") as f: 27 | genesis = json.load(f) 28 | 29 | frum = opts.__dict__["from"] # from is a language keyword and cannot be an attribute name 30 | 31 | for asset in genesis["initial_assets"]: 32 | if asset["symbol"] == frum: 33 | asset["symbol"] = opts.to 34 | 35 | for balance in genesis["initial_balances"]: 36 | if balance["asset_symbol"] == frum: 37 | balance["asset_symbol"] = opts.to 38 | 39 | for vb in genesis["initial_vesting_balances"]: 40 | if balance["asset_symbol"] == frum: 41 | balance["asset_symbol"] = opts.to 42 | 43 | if opts.output == "-": 44 | dump_json( genesis, sys.stdout, opts.pretty ) 45 | sys.stdout.flush() 46 | else: 47 | with open(opts.output, "w") as f: 48 | dump_json( genesis, f, opts.pretty ) 49 | return 50 | 51 | if __name__ == "__main__": 52 | main() 53 | -------------------------------------------------------------------------------- /programs/genesis_util/change_bitasset_owners.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Change initial_assets owned by the witness-account to the committee-account") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 19 | opts = parser.parse_args() 20 | 21 | if opts.input == "-": 22 | genesis = json.load(sys.stdin) 23 | else: 24 | with open(opts.input, "r") as f: 25 | genesis = json.load(f) 26 | 27 | for asset in genesis["initial_assets"]: 28 | if asset["issuer_name"] == "witness-account": 29 | asset["issuer_name"] = "committee-account" 30 | 31 | if opts.output == "-": 32 | dump_json( genesis, sys.stdout, opts.pretty ) 33 | sys.stdout.flush() 34 | else: 35 | with open(opts.output, "w") as f: 36 | dump_json( genesis, f, opts.pretty ) 37 | return 38 | 39 | if __name__ == "__main__": 40 | main() 41 | -------------------------------------------------------------------------------- /programs/genesis_util/change_key_prefix.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Set is_prefixed=false for all asset owners") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-f", "--from", metavar="PREFIX", default="", help="initial prefix") 19 | parser.add_argument("-t", "--to", metavar="PREFIX", default="", help="new prefix") 20 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 21 | opts = parser.parse_args() 22 | 23 | if opts.input == "-": 24 | genesis = json.load(sys.stdin) 25 | else: 26 | with open(opts.input, "r") as f: 27 | genesis = json.load(f) 28 | 29 | frum = opts.__dict__["from"] # from is a language keyword and cannot be an attribute name 30 | 31 | def convert(k): 32 | if not k.startswith(frum): 33 | print("key {k} does not start with prefix {p}".format(k=repr(k), p=repr(frum))) 34 | raise RuntimeError() 35 | return opts.to + k[len(frum):] 36 | 37 | for account in genesis["initial_accounts"]: 38 | account["owner_key"] = convert(account["owner_key"]) 39 | account["active_key"] = convert(account["active_key"]) 40 | 41 | for asset in genesis["initial_assets"]: 42 | for cr in asset.get("collateral_records", []): 43 | cr["owner"] = convert(cr["owner"]) 44 | 45 | for balance in genesis["initial_balances"]: 46 | balance["owner"] = convert(balance["owner"]) 47 | 48 | for vb in genesis["initial_vesting_balances"]: 49 | vb["owner"] = convert(vb["owner"]) 50 | 51 | for witness in genesis["initial_witness_candidates"]: 52 | witness["block_signing_key"] = convert(witness["block_signing_key"]) 53 | 54 | if opts.output == "-": 55 | dump_json( genesis, sys.stdout, opts.pretty ) 56 | sys.stdout.flush() 57 | else: 58 | with open(opts.output, "w") as f: 59 | dump_json( genesis, f, opts.pretty ) 60 | return 61 | 62 | if __name__ == "__main__": 63 | main() 64 | -------------------------------------------------------------------------------- /programs/genesis_util/create_bloom_filter.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import hashlib 5 | import json 6 | import sys 7 | 8 | def main(): 9 | parser = argparse.ArgumentParser(description="Set is_prefixed=false for all asset owners") 10 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 11 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 12 | parser.add_argument("-n", "--num", metavar="N", default=3, type=int, help="number of hashes per key (default: 3)") 13 | parser.add_argument("-s", "--size", metavar="BITS", default=8*1048576, type=int, help="number of bits in filter") 14 | parser.add_argument("-a", "--algorithm", metavar="NAME", default="sha256", type=str, help="hash algorithm (must exist in hashlib)") 15 | opts = parser.parse_args() 16 | 17 | if opts.input == "-": 18 | genesis = json.load(sys.stdin) 19 | else: 20 | with open(opts.input, "r") as f: 21 | genesis = json.load(f) 22 | 23 | keys = set() 24 | 25 | for account in genesis["initial_accounts"]: 26 | keys.add(account["owner_key"]) 27 | keys.add(account["active_key"]) 28 | 29 | for asset in genesis["initial_assets"]: 30 | for cr in asset.get("collateral_records", []): 31 | keys.add(cr["owner"]) 32 | 33 | for balance in genesis["initial_balances"]: 34 | keys.add(balance["owner"]) 35 | 36 | for vb in genesis["initial_vesting_balances"]: 37 | keys.add(vb["owner"]) 38 | 39 | for witness in genesis["initial_witness_candidates"]: 40 | keys.add(witness["block_signing_key"]) 41 | 42 | sys.stderr.write("got {n} distinct keys\n".format(n=len(keys))) 43 | 44 | keys = [(str(i) + ":" + k).encode("UTF-8") for k in sorted(keys) for i in range(opts.num)] 45 | 46 | data = bytearray((opts.size + 7) >> 3) 47 | 48 | h = getattr(hashlib, opts.algorithm) 49 | for k in keys: 50 | address = int(h(k).hexdigest(), 16) % opts.size 51 | data[address >> 3] |= (1 << (address & 7)) 52 | 53 | popcount = [bin(i).count("1") for i in range(256)] 54 | w = sum(popcount[x] for x in data) 55 | sys.stderr.write("""w={w} o={o:.3%} p={p:.3%} 56 | w: Hamming weight o: Occupancy p: False positive probability 57 | """.format( 58 | w=w, 59 | o=float(w) / float(opts.size), 60 | p=(float(w) / float(opts.size))**opts.num, 61 | )) 62 | 63 | if opts.output == "-": 64 | sys.stdout.write(data) 65 | sys.stdout.flush() 66 | else: 67 | with open(opts.output, "wb") as f: 68 | f.write(data) 69 | return 70 | 71 | if __name__ == "__main__": 72 | main() 73 | -------------------------------------------------------------------------------- /programs/genesis_util/egenesis_brief.cpp.tmpl: -------------------------------------------------------------------------------- 1 | ${generated_file_banner} 2 | /* 3 | * Copyright (c) 2015, Cryptonomex, Inc. 4 | * All rights reserved. 5 | * 6 | * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and 7 | * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted until September 8, 2015, provided that the following conditions are met: 9 | * 10 | * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. 11 | * 12 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 13 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 14 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 15 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 16 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 17 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | namespace graphene { namespace egenesis { 24 | 25 | using namespace graphene::chain; 26 | 27 | chain_id_type get_egenesis_chain_id() 28 | { 29 | return chain_id_type( "${chain_id}$" ); 30 | } 31 | 32 | void compute_egenesis_json( std::string& result ) 33 | { 34 | result = ""; 35 | } 36 | 37 | fc::sha256 get_egenesis_json_hash() 38 | { 39 | return fc::sha256( "${genesis_json_hash}" ); 40 | } 41 | 42 | } } 43 | -------------------------------------------------------------------------------- /programs/genesis_util/egenesis_full.cpp.tmpl: -------------------------------------------------------------------------------- 1 | ${generated_file_banner} 2 | /* 3 | * Copyright (c) 2015, Cryptonomex, Inc. 4 | * All rights reserved. 5 | * 6 | * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and 7 | * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted until September 8, 2015, provided that the following conditions are met: 9 | * 10 | * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. 11 | * 12 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 13 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 14 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 15 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 16 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 17 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | namespace graphene { namespace egenesis { 24 | 25 | using namespace graphene::chain; 26 | 27 | static const char genesis_json_array[${genesis_json_array_height}$][${genesis_json_array_width}$+1] = 28 | { 29 | ${genesis_json_array}$ 30 | }; 31 | 32 | chain_id_type get_egenesis_chain_id() 33 | { 34 | return chain_id_type( "${chain_id}$" ); 35 | } 36 | 37 | void compute_egenesis_json( std::string& result ) 38 | { 39 | result.reserve( ${genesis_json_length}$ ); 40 | result.resize(0); 41 | for( size_t i=0; i<${genesis_json_array_height}$-1; i++ ) 42 | { 43 | result.append( genesis_json_array[i], ${genesis_json_array_width}$ ); 44 | } 45 | result.append( std::string( genesis_json_array[ ${genesis_json_array_height}$-1 ] ) ); 46 | return; 47 | } 48 | 49 | fc::sha256 get_egenesis_json_hash() 50 | { 51 | return fc::sha256( "${genesis_json_hash}" ); 52 | } 53 | 54 | } } 55 | -------------------------------------------------------------------------------- /programs/genesis_util/generate_account_patch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import subprocess 6 | import sys 7 | 8 | def dump_json(obj, out, pretty): 9 | if pretty: 10 | json.dump(obj, out, indent=2, sort_keys=True) 11 | else: 12 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 13 | return 14 | 15 | def main(): 16 | parser = argparse.ArgumentParser(description="Generate a patch file that adds init accounts") 17 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 18 | parser.add_argument("-a", "--accounts", metavar="ACCOUNTS", default="-", help="file containing name, balances to create") 19 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 20 | parser.add_argument("-s", "--secret", metavar="SECRET", default=None, help="private key generation secret") 21 | opts = parser.parse_args() 22 | 23 | if opts.secret is None: 24 | sys.stderr.write("missing required parameter --secret\n") 25 | sys.stderr.flush() 26 | sys.exit(1) 27 | 28 | with open(opts.accounts, "r") as f: 29 | accounts = json.load(f) 30 | 31 | initial_accounts = [] 32 | initial_balances = [] 33 | for e in accounts: 34 | name = e["name"] 35 | owner_str = subprocess.check_output(["programs/genesis_util/get_dev_key", opts.secret, "owner-"+name]).decode("utf-8") 36 | active_str = subprocess.check_output(["programs/genesis_util/get_dev_key", opts.secret, "active-"+name]).decode("utf-8") 37 | owner = json.loads(owner_str) 38 | active = json.loads(active_str) 39 | initial_accounts.append({ 40 | "name" : name, 41 | "owner_key" : owner[0]["public_key"], 42 | "active_key" : active[0]["public_key"], 43 | "is_lifetime_member" : True, 44 | }) 45 | for bal in e.get("balances", []): 46 | bal = dict(bal) 47 | bal["owner"] = active[0]["address"] 48 | initial_balances.append(bal) 49 | result = { 50 | "append" : { 51 | "initial_accounts" : initial_accounts }, 52 | } 53 | if len(initial_balances) > 0: 54 | result["append"]["initial_balances"] = initial_balances 55 | 56 | if opts.output == "-": 57 | dump_json( result, sys.stdout, opts.pretty ) 58 | sys.stdout.flush() 59 | else: 60 | with open(opts.output, "w") as f: 61 | dump_json( result, f, opts.pretty ) 62 | return 63 | 64 | if __name__ == "__main__": 65 | main() 66 | -------------------------------------------------------------------------------- /programs/genesis_util/generate_init_config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import subprocess 6 | import sys 7 | 8 | def dump_json(obj, out, pretty): 9 | if pretty: 10 | json.dump(obj, out, indent=2, sort_keys=True) 11 | else: 12 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 13 | return 14 | 15 | def main(): 16 | parser = argparse.ArgumentParser(description="Generate a patch file that adds init accounts") 17 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 18 | parser.add_argument("-n", "--num", metavar="N", default=11, type=int, help="number of init witnesses") 19 | parser.add_argument("-w", "--witness", metavar="N", default=1, type=int, help="starting witness ID") 20 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 21 | parser.add_argument("-m", "--mname", metavar="HOSTNAME", default="", help="machine name of target machine") 22 | parser.add_argument("-s", "--secret", metavar="SECRET", default=None, help="private key generation secret") 23 | opts = parser.parse_args() 24 | 25 | if opts.secret is None: 26 | sys.stderr.write("missing required parameter --secret\n") 27 | sys.stderr.flush() 28 | sys.exit(1) 29 | 30 | out_wits = [] 31 | out_keys = [] 32 | 33 | for i in range(opts.num): 34 | if opts.mname != "": 35 | istr = "wit-block-signing-"+opts.mname+"-"+str(i) 36 | else: 37 | istr = "wit-block-signing-"+str(i) 38 | prod_str = subprocess.check_output(["programs/genesis_util/get_dev_key", opts.secret, istr]).decode("utf-8") 39 | prod = json.loads(prod_str) 40 | out_wits.append('witness-id = "1.6.'+str(opts.witness+i)+'"\n') 41 | out_keys.append("private-key = "+json.dumps([prod[0]["public_key"], prod[0]["private_key"]])+"\n") 42 | 43 | out_data = "".join(out_wits + ["\n"] + out_keys) 44 | 45 | if opts.output == "-": 46 | sys.stdout.write(out_data) 47 | sys.stdout.flush() 48 | else: 49 | with open(opts.output, "w") as f: 50 | f.write(out_data) 51 | return 52 | 53 | if __name__ == "__main__": 54 | main() 55 | -------------------------------------------------------------------------------- /programs/genesis_util/generate_init_patch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import subprocess 6 | import sys 7 | 8 | def dump_json(obj, out, pretty): 9 | if pretty: 10 | json.dump(obj, out, indent=2, sort_keys=True) 11 | else: 12 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 13 | return 14 | 15 | def main(): 16 | parser = argparse.ArgumentParser(description="Generate a patch file that adds init accounts") 17 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 18 | parser.add_argument("-n", "--num", metavar="N", default=11, type=int, help="number of init witnesses") 19 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 20 | parser.add_argument("-s", "--secret", metavar="SECRET", default=None, help="private key generation secret") 21 | opts = parser.parse_args() 22 | 23 | if opts.secret is None: 24 | sys.stderr.write("missing required parameter --secret\n") 25 | sys.stderr.flush() 26 | sys.exit(1) 27 | 28 | wit_accounts = [] 29 | wit_wits = [] 30 | committee = [] 31 | 32 | for i in range(opts.num): 33 | owner_str = subprocess.check_output(["programs/genesis_util/get_dev_key", opts.secret, "wit-owner-"+str(i)]).decode("utf-8") 34 | active_str = subprocess.check_output(["programs/genesis_util/get_dev_key", opts.secret, "wit-active-"+str(i)]).decode("utf-8") 35 | prod_str = subprocess.check_output(["programs/genesis_util/get_dev_key", opts.secret, "wit-block-signing-"+str(i)]).decode("utf-8") 36 | owner = json.loads(owner_str) 37 | active = json.loads(active_str) 38 | prod = json.loads(prod_str) 39 | wit_accounts.append({ 40 | "name" : "init"+str(i), 41 | "owner_key" : owner[0]["public_key"], 42 | "active_key" : active[0]["public_key"], 43 | "is_lifetime_member" : True, 44 | }) 45 | wit_wits.append({ 46 | "owner_name" : "init"+str(i), 47 | "block_signing_key" : prod[0]["public_key"], 48 | }) 49 | committee.append({"owner_name" : "init"+str(i)}) 50 | result = { 51 | "append" : { 52 | "initial_accounts" : wit_accounts }, 53 | "replace" : { 54 | "initial_active_witnesses" : opts.num, 55 | "initial_worker_candidates" : [], 56 | "initial_witness_candidates" : wit_wits, 57 | "initial_committee_candidates" : committee, 58 | } 59 | } 60 | 61 | if opts.output == "-": 62 | dump_json( result, sys.stdout, opts.pretty ) 63 | sys.stdout.flush() 64 | else: 65 | with open(opts.output, "w") as f: 66 | dump_json( result, f, opts.pretty ) 67 | 68 | return 69 | 70 | if __name__ == "__main__": 71 | main() 72 | -------------------------------------------------------------------------------- /programs/genesis_util/python_format.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | if len(sys.argv) < 3: 8 | print("syntax: "+sys.argv[0]+" INFILE OUTFILE") 9 | sys.exit(0) 10 | 11 | with open(sys.argv[1], "r") as infile: 12 | genesis = json.load(infile) 13 | with open(sys.argv[2], "w") as outfile: 14 | json.dump(genesis, outfile, indent=2, sort_keys=True) 15 | -------------------------------------------------------------------------------- /programs/genesis_util/remove.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Remove entities from snapshot") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-a", "--asset", metavar="ASSETS", nargs="+", help="list of asset(s) to delete") 19 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 20 | opts = parser.parse_args() 21 | 22 | if opts.input == "-": 23 | genesis = json.load(sys.stdin) 24 | else: 25 | with open(opts.input, "r") as f: 26 | genesis = json.load(f) 27 | 28 | if opts.asset is None: 29 | opts.asset = [] 30 | rm_asset_set = set(opts.asset) 31 | 32 | removed_asset_entries = {aname : 0 for aname in opts.asset} 33 | new_initial_assets = [] 34 | for asset in genesis["initial_assets"]: 35 | symbol = asset["symbol"] 36 | if symbol not in rm_asset_set: 37 | new_initial_assets.append(asset) 38 | else: 39 | removed_asset_entries[symbol] += 1 40 | genesis["initial_assets"] = new_initial_assets 41 | 42 | removed_balance_entries = {aname : [] for aname in opts.asset} 43 | new_initial_balances = [] 44 | for balance in genesis["initial_balances"]: 45 | symbol = balance["asset_symbol"] 46 | if symbol not in rm_asset_set: 47 | new_initial_balances.append(balance) 48 | else: 49 | removed_balance_entries[symbol].append(balance) 50 | genesis["initial_balances"] = new_initial_balances 51 | # TODO: Remove from initial_vesting_balances 52 | 53 | for aname in opts.asset: 54 | sys.stderr.write( 55 | "Asset {sym} removed {acount} initial_assets, {bcount} initial_balances totaling {btotal}\n".format( 56 | sym=aname, 57 | acount=removed_asset_entries[aname], 58 | bcount=len(removed_balance_entries[aname]), 59 | btotal=sum(int(e["amount"]) for e in removed_balance_entries[aname]), 60 | )) 61 | 62 | if opts.output == "-": 63 | dump_json( genesis, sys.stdout, opts.pretty ) 64 | sys.stdout.flush() 65 | else: 66 | with open(opts.output, "w") as f: 67 | dump_json( genesis, f, opts.pretty ) 68 | return 69 | 70 | if __name__ == "__main__": 71 | main() 72 | -------------------------------------------------------------------------------- /programs/genesis_util/sort_objects.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Sort initial_accounts and initial_assets by \"id\" member, then remove \"id\" member") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 19 | opts = parser.parse_args() 20 | 21 | if opts.input == "-": 22 | genesis = json.load(sys.stdin) 23 | else: 24 | with open(opts.input, "r") as f: 25 | genesis = json.load(f) 26 | 27 | genesis["initial_assets"].sort( key=lambda e : e["id"] ) 28 | genesis["initial_accounts"].sort( key=lambda e : e["id"] ) 29 | 30 | for e in genesis["initial_assets"]: 31 | del e["id"] 32 | for e in genesis["initial_accounts"]: 33 | del e["id"] 34 | 35 | if opts.output == "-": 36 | dump_json( genesis, sys.stdout, opts.pretty ) 37 | sys.stdout.flush() 38 | else: 39 | with open(opts.output, "w") as f: 40 | dump_json( genesis, f, opts.pretty ) 41 | return 42 | 43 | if __name__ == "__main__": 44 | main() 45 | -------------------------------------------------------------------------------- /programs/genesis_util/unprefix_asset_owners.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Set is_prefixed=false for all asset owners") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 19 | opts = parser.parse_args() 20 | 21 | if opts.input == "-": 22 | genesis = json.load(sys.stdin) 23 | else: 24 | with open(opts.input, "r") as f: 25 | genesis = json.load(f) 26 | 27 | asset_owners = set() 28 | for asset in genesis["initial_assets"]: 29 | asset_owners.add(asset["issuer_name"]) 30 | for account in genesis["initial_accounts"]: 31 | if account["name"] in asset_owners: 32 | account["is_prefixed"] = False 33 | 34 | if opts.output == "-": 35 | dump_json( genesis, sys.stdout, opts.pretty ) 36 | sys.stdout.flush() 37 | else: 38 | with open(opts.output, "w") as f: 39 | dump_json( genesis, f, opts.pretty ) 40 | return 41 | 42 | if __name__ == "__main__": 43 | main() 44 | -------------------------------------------------------------------------------- /programs/genesis_util/unprefix_names.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def load_names(infile): 15 | names = set() 16 | for line in infile: 17 | if '#' in line: 18 | line = line[:line.index('#')] 19 | line = line.strip() 20 | if line == "": 21 | continue 22 | names.add(line) 23 | return names 24 | 25 | def main(): 26 | parser = argparse.ArgumentParser(description="Set is_prefixed=False for a list of names") 27 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 28 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 29 | parser.add_argument("-n", "--names", metavar="NAMES", help="list of names to unprefix") 30 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 31 | opts = parser.parse_args() 32 | 33 | if opts.input == "-": 34 | genesis = json.load(sys.stdin) 35 | else: 36 | with open(opts.input, "r") as f: 37 | genesis = json.load(f) 38 | 39 | if opts.names == "-": 40 | names = load_names(sys.stdin) 41 | else: 42 | with open(opts.names, "r") as f: 43 | names = load_names(f) 44 | 45 | for account in genesis["initial_accounts"]: 46 | if account["name"] in names: 47 | account["is_prefixed"] = False 48 | 49 | if opts.output == "-": 50 | dump_json( genesis, sys.stdout, opts.pretty ) 51 | sys.stdout.flush() 52 | else: 53 | with open(opts.output, "w") as f: 54 | dump_json( genesis, f, opts.pretty ) 55 | return 56 | 57 | if __name__ == "__main__": 58 | main() 59 | -------------------------------------------------------------------------------- /programs/genesis_util/upgrade_members.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import re 6 | import sys 7 | 8 | def dump_json(obj, out, pretty): 9 | if pretty: 10 | json.dump(obj, out, indent=2, sort_keys=True) 11 | else: 12 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 13 | return 14 | 15 | re_init = re.compile(r"^init[0-9]+$") 16 | 17 | def load_names(infile): 18 | names = set() 19 | for line in infile: 20 | if '#' in line: 21 | line = line[:line.index('#')] 22 | line = line.strip() 23 | if line == "": 24 | continue 25 | names.add(line) 26 | return names 27 | 28 | def main(): 29 | parser = argparse.ArgumentParser(description="Upgrade a list of members") 30 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 31 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 32 | parser.add_argument("-n", "--names", metavar="NAMES", default="", help="file containing names to upgrade") 33 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 34 | opts = parser.parse_args() 35 | 36 | if opts.input == "-": 37 | genesis = json.load(sys.stdin) 38 | else: 39 | with open(opts.input, "r") as f: 40 | genesis = json.load(f) 41 | 42 | if opts.names == "-": 43 | names = load_names(sys.stdin) 44 | else: 45 | with open(opts.names, "r") as f: 46 | names = load_names(f) 47 | 48 | for account in genesis["initial_accounts"]: 49 | if account["name"] in names: 50 | account["is_lifetime_member"] = True 51 | 52 | if opts.output == "-": 53 | dump_json( genesis, sys.stdout, opts.pretty ) 54 | sys.stdout.flush() 55 | else: 56 | with open(opts.output, "w") as f: 57 | dump_json( genesis, f, opts.pretty ) 58 | return 59 | 60 | if __name__ == "__main__": 61 | main() 62 | -------------------------------------------------------------------------------- /programs/js_operation_serializer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | file( GLOB HEADERS "*.hpp" ) 3 | 4 | add_executable( js_operation_serializer 5 | main.cpp 6 | ${HEADERS} ) 7 | target_link_libraries( js_operation_serializer 8 | PRIVATE graphene_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 9 | 10 | #install( TARGETS 11 | # js_operation_serializer 12 | # 13 | # RUNTIME DESTINATION bin 14 | # LIBRARY DESTINATION lib 15 | # ARCHIVE DESTINATION lib 16 | #) 17 | -------------------------------------------------------------------------------- /programs/size_checker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable( size_checker main.cpp ) 3 | target_link_libraries( size_checker 4 | PRIVATE graphene_chain graphene_egenesis_none fc cryptopp ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 5 | 6 | #install( TARGETS 7 | # size_checker 8 | # 9 | # RUNTIME DESTINATION bin 10 | # LIBRARY DESTINATION lib 11 | # ARCHIVE DESTINATION lib 12 | #) 13 | -------------------------------------------------------------------------------- /programs/verify_sign/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable( verify_sign main.cpp ) 3 | target_link_libraries( verify_sign 4 | PRIVATE graphene_chain fc cryptopp ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 5 | -------------------------------------------------------------------------------- /scripts/Windows/Banner.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DECENTfoundation/DECENT-Network/0f045ef2e353ed85bccb422534e93ff70d1fdf54/scripts/Windows/Banner.bmp -------------------------------------------------------------------------------- /scripts/Windows/DCore.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DECENTfoundation/DECENT-Network/0f045ef2e353ed85bccb422534e93ff70d1fdf54/scripts/Windows/DCore.ico -------------------------------------------------------------------------------- /scripts/Windows/DCore.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 14 3 | VisualStudioVersion = 14.0.25420.1 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{3EB741FD-BE8D-4E90-8F67-B17F92E8F98D}") = "DCore", "DCore.wixproj", "{0BB92B04-5540-4BB0-93E3-17F3701DBE20}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|x64 = Debug|x64 10 | Release|x64 = Release|x64 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {0BB92B04-5540-4BB0-93E3-17F3701DBE20}.Debug|x64.ActiveCfg = Debug|x64 14 | {0BB92B04-5540-4BB0-93E3-17F3701DBE20}.Debug|x64.Build.0 = Debug|x64 15 | {0BB92B04-5540-4BB0-93E3-17F3701DBE20}.Debug|x86.ActiveCfg = Debug|x64 16 | {0BB92B04-5540-4BB0-93E3-17F3701DBE20}.Release|x64.ActiveCfg = Release|x64 17 | {0BB92B04-5540-4BB0-93E3-17F3701DBE20}.Release|x64.Build.0 = Release|x64 18 | {0BB92B04-5540-4BB0-93E3-17F3701DBE20}.Release|x86.ActiveCfg = Release|x64 19 | EndGlobalSection 20 | GlobalSection(SolutionProperties) = preSolution 21 | HideSolutionNode = FALSE 22 | EndGlobalSection 23 | EndGlobal 24 | -------------------------------------------------------------------------------- /scripts/Windows/Dialog.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DECENTfoundation/DECENT-Network/0f045ef2e353ed85bccb422534e93ff70d1fdf54/scripts/Windows/Dialog.bmp -------------------------------------------------------------------------------- /scripts/price_getter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -le 0 ]; then echo "Usage: $0 http://ip:port account_name coinmarketcat_api_key"; exit ; fi 4 | endpoint=$1 5 | account=$2 6 | CMC_API_KEY=$3 7 | max_length=17 8 | 9 | for c in USD EUR JPY BGN CZK DKK GBP HUF PLN RON SEK CHF NOK HRK RUB TRY AUD BRL CAD CNY HKD IDR ILS INR KRW MXN MYR NZD PHP SGD THB ZAR 10 | do 11 | price=`curl -s -H "X-CMC_PRO_API_KEY: $CMC_API_KEY" "https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=DCT&convert=$c" | grep -i price | grep -o '[0-9]*\.\?[0-9]\+'` 12 | orig_price=`echo $price` 13 | base=`echo $price | sed 's/\(.*\)\.\(.*\)/\1\2/'` 14 | quote_exp=`echo $price | sed 's/\(.*\)\.\(.*\)/\20000/' |sed s/./0/g` 15 | id=`curl -s -X POST --data "{\"id\":1, \"method\":\"call\", \"params\":[0,\"get_asset\",[\"$c\"]]}" $endpoint | awk -F '"' '{print $8}'` 16 | 17 | length=`echo "$quote_exp" | awk '{print length}'` 18 | if (( length > max_length )); then 19 | diff=$((length - max_length)) 20 | base=`echo $base | sed 's/.\{'"$diff"'\}$//'` 21 | quote_exp=`echo $quote_exp | sed 's/.\{'"$diff"'\}$//'` 22 | fi 23 | 24 | result=`curl -s -X POST --data "{\"id\":1, \"method\":\"call\", \"params\":[0,\"publish_asset_feed\",[\"$account\",\"$c\",{ \"core_exchange_rate\":{\"quote\":{\"amount\": 1$quote_exp, \"asset_id\": \"1.3.0\" }, \"base\":{\"amount\": \"$base\", \"asset_id\": \"$id\" } } }, true]]}" $endpoint` 25 | 26 | echo "$result" 27 | echo 28 | sleep 2 # cmc basic plan limits the number of requests to 30 per minute. 29 | done 30 | -------------------------------------------------------------------------------- /tests/benchmarks/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #define BOOST_TEST_MODULE "C++ Benchmarks for Graphene Blockchain Database" 25 | #include 26 | -------------------------------------------------------------------------------- /tests/common/tempdir.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "tempdir.hpp" 26 | #include 27 | #include 28 | 29 | namespace graphene { namespace utilities { 30 | 31 | boost::filesystem::path temp_directory_path() 32 | { 33 | const char* graphene_tempdir = getenv("GRAPHENE_TEMPDIR"); 34 | if( graphene_tempdir != nullptr ) 35 | return boost::filesystem::path( graphene_tempdir ); 36 | return temp_directory_path() / "graphene-tmp"; 37 | } 38 | 39 | } } // graphene::utilities 40 | -------------------------------------------------------------------------------- /tests/common/tempdir.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | #include 29 | 30 | namespace graphene { namespace utilities { 31 | 32 | boost::filesystem::path temp_directory_path(); 33 | 34 | } } // graphene::utilities 35 | -------------------------------------------------------------------------------- /tests/encrypt/test_pbc_benchmark.cpp: -------------------------------------------------------------------------------- 1 | /* (c) 2016, 2017 DECENT Services. For details refers to LICENSE.txt */ 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | #define _DECENT_PAIRING_PARAM_ "type a\n\ 11 | q 8780710799663312522437781984754049815806883199414208211028653399266475630880222957078625179422662221423155858769582317459277713367317481324925129998224791\n\ 12 | h 12016012264891146079388821366740534204802954401251311822919615131047207289359704531102844802183906537786776\n\ 13 | r 730750818665451621361119245571504901405976559617\n\ 14 | exp2 159\n\ 15 | exp1 107\n\ 16 | sign1 1\n\ 17 | sign0 1" 18 | //*/ 19 | 20 | #define _DECENT_PAIRING_PARAM_ "type a\n\ 21 | q 107469721672869524998588652624299090254588259753590905940381448229303192908187\n\ 22 | h 83459336727718274173193788390204479901284\n\ 23 | r 1287689620916637251875563089646583807\n\ 24 | exp2 120\n\ 25 | exp1 115\n\ 26 | sign1 -1\n\ 27 | sign0 -1" 28 | 29 | int main(int argc, char **argv) { 30 | pairing_t pairing; 31 | pairing_init_set_str(pairing, _DECENT_PAIRING_PARAM_); 32 | element_t g; 33 | element_t tmp; 34 | element_init_G1(g, pairing); 35 | element_init_G1(tmp, pairing); 36 | element_random(g); 37 | element_printf("system parameter g = %B\n", g); 38 | element_random(tmp); 39 | for(int i=0; i<0; i++){ 40 | 41 | element_t tmp2; 42 | element_init_G1(tmp2, pairing); 43 | element_set(tmp2, tmp); 44 | element_mul(tmp, tmp2, g); 45 | element_clear(tmp2); 46 | } 47 | element_pp_t g_pp; 48 | element_pp_init(g_pp, g); 49 | mpz_t power; 50 | mpz_init(power); 51 | mpz_set_str(power, "26219755532374060961822481953204487875830586022463559049872633319816613072",10); 52 | for(int i=0; i<300000; i++){ 53 | element_pp_pow(tmp, power, g_pp); 54 | } 55 | 56 | return 0; 57 | 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /tests/generate_empty_blocks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable( generate_empty_blocks main.cpp ) 3 | 4 | target_link_libraries( generate_empty_blocks 5 | PRIVATE graphene_app graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 6 | 7 | install( TARGETS 8 | generate_empty_blocks 9 | 10 | RUNTIME DESTINATION bin 11 | LIBRARY DESTINATION lib 12 | ARCHIVE DESTINATION lib 13 | ) 14 | -------------------------------------------------------------------------------- /tests/intense/api_stress.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import json 4 | import os 5 | import random 6 | import signal 7 | import struct 8 | import sys 9 | import time 10 | 11 | try: 12 | import asyncio 13 | except ImportError: 14 | print("asyncio module not found (try pip install asyncio, or upgrade to Python 3.4 or later)") 15 | sys.exit(1) 16 | 17 | try: 18 | import websockets 19 | except ImportError: 20 | print("websockets module not found (try pip install websockets)") 21 | sys.exit(1) 22 | 23 | @asyncio.coroutine 24 | def mainloop(): 25 | ws = yield from websockets.connect('ws://localhost:8090/') 26 | entropy = struct.unpack(" 25 | #include 26 | #include 27 | 28 | boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { 29 | std::srand(time(NULL)); 30 | std::cout << "Random number generator seeded to " << time(NULL) << std::endl; 31 | return nullptr; 32 | } 33 | -------------------------------------------------------------------------------- /tests/tests/database_tests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | 31 | #include "../common/database_fixture.hpp" 32 | 33 | using namespace graphene::chain; 34 | 35 | BOOST_AUTO_TEST_CASE( undo_test ) 36 | { 37 | try { 38 | database db; 39 | auto ses = db._undo_db.start_undo_session(); 40 | const auto& bal_obj1 = db.create( [&]( account_balance_object& obj ){ 41 | /* no balances right now */ 42 | }); 43 | auto id1 = bal_obj1.id; 44 | // abandon changes 45 | ses.undo(); 46 | // start a new session 47 | ses = db._undo_db.start_undo_session(); 48 | 49 | const auto& bal_obj2 = db.create( [&]( account_balance_object& obj ){ 50 | /* no balances right now */ 51 | }); 52 | auto id2 = bal_obj2.id; 53 | BOOST_CHECK( id1 == id2 ); 54 | } catch ( const fc::exception& e ) 55 | { 56 | edump( (e.to_detail_string()) ); 57 | throw; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tests/tests/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #include 25 | #include 26 | #include 27 | 28 | extern uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP; 29 | 30 | boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { 31 | std::srand(static_cast(time(NULL))); 32 | std::cout << "Random number generator seeded to " << time(NULL) << std::endl; 33 | const char* genesis_timestamp_str = getenv("GRAPHENE_TESTING_GENESIS_TIMESTAMP"); 34 | if( genesis_timestamp_str != nullptr ) 35 | { 36 | GRAPHENE_TESTING_GENESIS_TIMESTAMP = std::stoul( genesis_timestamp_str ); 37 | } 38 | std::cout << "GRAPHENE_TESTING_GENESIS_TIMESTAMP is " << GRAPHENE_TESTING_GENESIS_TIMESTAMP << std::endl; 39 | return nullptr; 40 | } 41 | --------------------------------------------------------------------------------