├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CMakeModules ├── FindBerkeleyDB.cmake ├── FindGperftools.cmake ├── FindLineman.cmake ├── FindNodeJs.cmake └── cotire.cmake ├── Doxyfile ├── HEADER ├── LICENSE.md ├── README.md ├── Vagrantfile ├── libraries ├── CMakeLists.txt ├── app │ ├── CMakeLists.txt │ ├── api.cpp │ ├── application.cpp │ ├── database_api.cpp │ ├── impacted.cpp │ ├── include │ │ └── graphene │ │ │ └── app │ │ │ ├── api.hpp │ │ │ ├── api_access.hpp │ │ │ ├── application.hpp │ │ │ ├── database_api.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 │ ├── balance_evaluator.cpp │ ├── block_database.cpp │ ├── buyback.cpp │ ├── committee_member_evaluator.cpp │ ├── confidential_evaluator.cpp │ ├── database.cpp │ ├── db_balance.cpp │ ├── db_block.cpp │ ├── db_debug.cpp │ ├── db_getter.cpp │ ├── db_init.cpp │ ├── db_maint.cpp │ ├── db_management.cpp │ ├── db_market.cpp │ ├── db_update.cpp │ ├── db_witness_schedule.cpp │ ├── evaluator.cpp │ ├── fba_object.cpp │ ├── fork_database.cpp │ ├── genesis_state.cpp │ ├── get_config.cpp │ ├── hardfork.d │ │ ├── 000-200-preamble.hf │ │ ├── 357.hf │ │ ├── 359.hf │ │ ├── 409.hf │ │ ├── 413.hf │ │ ├── 415.hf │ │ ├── 416.hf │ │ ├── 419.hf │ │ ├── 436.hf │ │ ├── 445.hf │ │ ├── 453.hf │ │ ├── 480.hf │ │ ├── 483.hf │ │ ├── 516.hf │ │ ├── 533.hf │ │ ├── 538.hf │ │ ├── 555.hf │ │ ├── 563.hf │ │ ├── 572.hf │ │ ├── 599.hf │ │ ├── 607.hf │ │ ├── 613.hf │ │ └── 615.hf │ ├── include │ │ └── graphene │ │ │ └── chain │ │ │ ├── account_evaluator.hpp │ │ │ ├── account_object.hpp │ │ │ ├── assert_evaluator.hpp │ │ │ ├── asset_evaluator.hpp │ │ │ ├── asset_object.hpp │ │ │ ├── balance_evaluator.hpp │ │ │ ├── balance_object.hpp │ │ │ ├── block_database.hpp │ │ │ ├── block_summary_object.hpp │ │ │ ├── budget_record_object.hpp │ │ │ ├── buyback.hpp │ │ │ ├── buyback_object.hpp │ │ │ ├── chain_property_object.hpp │ │ │ ├── committee_member_evaluator.hpp │ │ │ ├── committee_member_object.hpp │ │ │ ├── confidential_evaluator.hpp │ │ │ ├── confidential_object.hpp │ │ │ ├── config.hpp │ │ │ ├── custom_evaluator.hpp │ │ │ ├── database.hpp │ │ │ ├── db_with.hpp │ │ │ ├── evaluator.hpp │ │ │ ├── exceptions.hpp │ │ │ ├── fba_accumulator_id.hpp │ │ │ ├── fba_object.hpp │ │ │ ├── fork_database.hpp │ │ │ ├── genesis_state.hpp │ │ │ ├── get_config.hpp │ │ │ ├── global_property_object.hpp │ │ │ ├── immutable_chain_parameters.hpp │ │ │ ├── internal_exceptions.hpp │ │ │ ├── is_authorized_asset.hpp │ │ │ ├── market_evaluator.hpp │ │ │ ├── market_object.hpp │ │ │ ├── node_property_object.hpp │ │ │ ├── operation_history_object.hpp │ │ │ ├── proposal_evaluator.hpp │ │ │ ├── proposal_object.hpp │ │ │ ├── protocol │ │ │ ├── README.md │ │ │ ├── account.hpp │ │ │ ├── address.hpp │ │ │ ├── assert.hpp │ │ │ ├── asset.hpp │ │ │ ├── asset_ops.hpp │ │ │ ├── authority.hpp │ │ │ ├── balance.hpp │ │ │ ├── base.hpp │ │ │ ├── block.hpp │ │ │ ├── buyback.hpp │ │ │ ├── chain_parameters.hpp │ │ │ ├── committee_member.hpp │ │ │ ├── confidential.hpp │ │ │ ├── config.hpp │ │ │ ├── custom.hpp │ │ │ ├── ext.hpp │ │ │ ├── fba.hpp │ │ │ ├── fee_schedule.hpp │ │ │ ├── market.hpp │ │ │ ├── memo.hpp │ │ │ ├── operations.hpp │ │ │ ├── proposal.hpp │ │ │ ├── protocol.hpp │ │ │ ├── special_authority.hpp │ │ │ ├── transaction.hpp │ │ │ ├── transfer.hpp │ │ │ ├── types.hpp │ │ │ ├── vesting.hpp │ │ │ ├── vote.hpp │ │ │ ├── withdraw_permission.hpp │ │ │ ├── witness.hpp │ │ │ └── worker.hpp │ │ │ ├── pts_address.hpp │ │ │ ├── special_authority.hpp │ │ │ ├── special_authority_object.hpp │ │ │ ├── transaction_evaluation_state.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 │ │ │ ├── witness_evaluator.hpp │ │ │ ├── witness_object.hpp │ │ │ ├── witness_schedule_object.hpp │ │ │ ├── worker_evaluator.hpp │ │ │ └── worker_object.hpp │ ├── index.cpp │ ├── is_authorized_asset.cpp │ ├── market_evaluator.cpp │ ├── proposal_evaluator.cpp │ ├── proposal_object.cpp │ ├── protocol │ │ ├── account.cpp │ │ ├── address.cpp │ │ ├── assert.cpp │ │ ├── asset.cpp │ │ ├── asset_ops.cpp │ │ ├── authority.cpp │ │ ├── block.cpp │ │ ├── committee_member.cpp │ │ ├── confidential.cpp │ │ ├── custom.cpp │ │ ├── fee_schedule.cpp │ │ ├── market.cpp │ │ ├── memo.cpp │ │ ├── operations.cpp │ │ ├── proposal.cpp │ │ ├── transaction.cpp │ │ ├── transfer.cpp │ │ ├── types.cpp │ │ ├── vote.cpp │ │ ├── withdraw_permission.cpp │ │ ├── witness.cpp │ │ └── worker.cpp │ ├── pts_address.cpp │ ├── special_authority.cpp │ ├── transaction_object.cpp │ ├── transfer_evaluator.cpp │ ├── vesting_balance_evaluator.cpp │ ├── vesting_balance_object.cpp │ ├── withdraw_permission_evaluator.cpp │ ├── witness_evaluator.cpp │ └── worker_evaluator.cpp ├── db │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── db │ │ │ ├── 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 ├── deterministic_openssl_rand │ ├── CMakeLists.txt │ ├── deterministic_openssl_rand.cpp │ └── include │ │ └── graphene │ │ └── utilities │ │ └── deterministic_openssl_rand.hpp ├── egenesis │ ├── CMakeLists.txt │ ├── egenesis_brief.cpp.tmpl │ ├── egenesis_full.cpp.tmpl │ ├── egenesis_none.cpp │ ├── embed_genesis.cpp │ └── include │ │ └── graphene │ │ └── egenesis │ │ └── egenesis.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 ├── p2p │ ├── CMakeLists.txt │ ├── design.md │ ├── include │ │ └── graphene │ │ │ └── p2p │ │ │ ├── message.hpp │ │ │ ├── message_oriented_connection.hpp │ │ │ ├── node.hpp │ │ │ ├── peer_connection.hpp │ │ │ └── stcp_socket.hpp │ ├── message_oriented_connection.cpp │ ├── node.cpp │ ├── peer_connection.cpp │ └── stcp_socket.cpp ├── plugins │ ├── CMakeLists.txt │ ├── account_history │ │ ├── CMakeLists.txt │ │ ├── account_history_plugin.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── account_history │ │ │ └── account_history_plugin.hpp │ ├── debug_witness │ │ ├── CMakeLists.txt │ │ ├── debug_api.cpp │ │ ├── debug_witness.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── debug_witness │ │ │ ├── debug_api.hpp │ │ │ └── debug_witness.hpp │ ├── delayed_node │ │ ├── CMakeLists.txt │ │ ├── delayed_node_plugin.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── delayed_node │ │ │ └── delayed_node_plugin.hpp │ ├── market_history │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── graphene │ │ │ │ └── market_history │ │ │ │ └── market_history_plugin.hpp │ │ └── market_history_plugin.cpp │ └── witness │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── graphene │ │ │ └── witness │ │ │ └── witness.hpp │ │ └── witness.cpp ├── time │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── time │ │ │ └── time.hpp │ └── time.cpp ├── utilities │ ├── CMakeLists.txt │ ├── git_revision.cpp.in │ ├── include │ │ └── graphene │ │ │ └── utilities │ │ │ ├── git_revision.hpp │ │ │ ├── key_conversion.hpp │ │ │ ├── padding_ostream.hpp │ │ │ ├── string_escape.hpp │ │ │ ├── tempdir.hpp │ │ │ └── words.hpp │ ├── key_conversion.cpp │ ├── string_escape.cpp │ ├── tempdir.cpp │ └── words.cpp └── wallet │ ├── CMakeLists.txt │ ├── Doxyfile.in │ ├── api_documentation_standin.cpp │ ├── generate_api_documentation.pl │ ├── include │ └── graphene │ │ └── wallet │ │ ├── api_documentation.hpp │ │ ├── reflect_util.hpp │ │ └── wallet.hpp │ └── wallet.cpp ├── programs ├── CMakeLists.txt ├── build_helpers │ ├── CMakeLists.txt │ ├── cat-parts.cpp │ ├── check_reflect.py │ └── member_enumerator.cpp ├── cli_wallet │ ├── CMakeLists.txt │ └── main.cpp ├── debug_node │ ├── CMakeLists.txt │ └── main.cpp ├── delayed_node │ ├── CMakeLists.txt │ └── main.cpp ├── genesis_util │ ├── CMakeLists.txt │ ├── apply_patch.py │ ├── canonical_format.py │ ├── change_asset_symbol.py │ ├── change_bitasset_owners.py │ ├── change_key_prefix.py │ ├── convert_address.cpp │ ├── create_bloom_filter.py │ ├── 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 └── witness_node │ ├── CMakeLists.txt │ ├── main.cpp │ └── saltpass.py ├── testnet-shared-accounts.txt ├── testnet-shared-balances.txt ├── testnet-shared-committee-members.txt ├── testnet-shared-private-keys.txt ├── testnet-shared-vesting-balances.txt ├── testnet-shared-witnesses.txt └── tests ├── CMakeLists.txt ├── app └── main.cpp ├── benchmarks ├── genesis_allocation.cpp └── main.cpp ├── common ├── database_fixture.cpp └── database_fixture.hpp ├── generate_empty_blocks ├── CMakeLists.txt └── main.cpp ├── intense ├── api_stress.py ├── block_tests.cpp └── main.cpp ├── performance └── performance_tests.cpp └── tests ├── authority_tests.cpp ├── basic_tests.cpp ├── block_tests.cpp ├── confidential_tests.cpp ├── database_tests.cpp ├── fee_tests.cpp ├── main.cpp ├── operation_tests.cpp ├── operation_tests2.cpp ├── serialization_tests.cpp └── uia_tests.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.sw* 3 | 4 | *.cmake 5 | CMakeCache.txt 6 | CMakeFiles 7 | Makefile 8 | compile_commands.json 9 | moc_* 10 | *.moc 11 | hardfork.hpp 12 | 13 | libraries/utilities/git_revision.cpp 14 | 15 | libraries/wallet/Doxyfile 16 | libraries/wallet/api_documentation.cpp 17 | libraries/wallet/doxygen 18 | 19 | programs/cli_wallet/cli_wallet 20 | programs/js_operation_serializer/js_operation_serializer 21 | programs/witness_node/witness_node 22 | 23 | tests/app_test 24 | tests/chain_bench 25 | tests/chain_test 26 | tests/intense_test 27 | tests/performance_test 28 | 29 | doxygen 30 | 31 | wallet.json 32 | witness_node_data_dir 33 | 34 | *.wallet 35 | 36 | programs/witness_node/object_database/* 37 | 38 | object_database/* 39 | 40 | *.pyc 41 | *.pyo 42 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "docs"] 2 | path = docs 3 | url = https://github.com/cryptonomex/graphene.wiki.git 4 | ignore = dirty 5 | [submodule "libraries/fc"] 6 | path = libraries/fc 7 | url = https://github.com/cryptonomex/fc.git 8 | ignore = dirty 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /CMakeModules/FindLineman.cmake: -------------------------------------------------------------------------------- 1 | find_program(NPM_EXECUTABLE npm) 2 | include(FindPackageHandleStandardArgs) 3 | find_package_handle_standard_args("NPM" DEFAULT_MSG NPM_EXECUTABLE) 4 | 5 | find_program(LINEMAN_EXECUTABLE lineman) 6 | include(FindPackageHandleStandardArgs) 7 | find_package_handle_standard_args("Lineman" DEFAULT_MSG LINEMAN_EXECUTABLE) 8 | 9 | -------------------------------------------------------------------------------- /CMakeModules/FindNodeJs.cmake: -------------------------------------------------------------------------------- 1 | find_program(NODEJS_EXECUTABLE node) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args("NodeJs" DEFAULT_MSG NODEJS_EXECUTABLE) -------------------------------------------------------------------------------- /HEADER: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Cryptonomex, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and 6 | * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted until September 8, 2015, provided that the following conditions are met: 8 | * 9 | * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. 10 | * 11 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 12 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 13 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 14 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 15 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 16 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 | */ 18 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Cryptonomex, Inc., and contributors. 2 | 3 | The MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /libraries/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( fc ) 2 | add_subdirectory( db ) 3 | add_subdirectory( deterministic_openssl_rand ) 4 | add_subdirectory( chain ) 5 | add_subdirectory( egenesis ) 6 | add_subdirectory( net ) 7 | #add_subdirectory( p2p ) 8 | add_subdirectory( time ) 9 | add_subdirectory( utilities ) 10 | add_subdirectory( app ) 11 | add_subdirectory( plugins ) 12 | add_subdirectory( wallet ) 13 | -------------------------------------------------------------------------------- /libraries/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/app/*.hpp") 2 | file(GLOB EGENESIS_HEADERS "../egenesis/include/graphene/app/*.hpp") 3 | 4 | add_library( graphene_app 5 | api.cpp 6 | application.cpp 7 | database_api.cpp 8 | impacted.cpp 9 | plugin.cpp 10 | ${HEADERS} 11 | ${EGENESIS_HEADERS} 12 | ) 13 | 14 | # need to link graphene_debug_witness because plugins aren't sufficiently isolated #246 15 | target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_chain fc graphene_db graphene_net graphene_time graphene_utilities graphene_debug_witness ) 16 | target_include_directories( graphene_app 17 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 18 | "${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" ) 19 | 20 | if(MSVC) 21 | set_source_files_properties( application.cpp api.cpp database_api.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 22 | endif(MSVC) 23 | 24 | INSTALL( TARGETS 25 | graphene_app 26 | 27 | RUNTIME DESTINATION bin 28 | LIBRARY DESTINATION lib 29 | ARCHIVE DESTINATION lib 30 | ) 31 | -------------------------------------------------------------------------------- /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 | 28 | #include 29 | #include 30 | #include 31 | 32 | namespace graphene { namespace app { 33 | 34 | struct api_access_info 35 | { 36 | std::string password_hash_b64; 37 | std::string password_salt_b64; 38 | std::vector< std::string > allowed_apis; 39 | }; 40 | 41 | struct api_access 42 | { 43 | std::map< std::string, api_access_info > permission_map; 44 | }; 45 | 46 | } } // graphene::app 47 | 48 | FC_REFLECT( graphene::app::api_access_info, 49 | (password_hash_b64) 50 | (password_salt_b64) 51 | (allowed_apis) 52 | ) 53 | 54 | FC_REFLECT( graphene::app::api_access, 55 | (permission_map) 56 | ) 57 | -------------------------------------------------------------------------------- /libraries/app/include/graphene/app/full_account.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 app { 31 | using namespace graphene::chain; 32 | 33 | struct full_account 34 | { 35 | account_object account; 36 | account_statistics_object statistics; 37 | string registrar_name; 38 | string referrer_name; 39 | string lifetime_referrer_name; 40 | vector votes; 41 | optional cashback_balance; 42 | vector balances; 43 | vector vesting_balances; 44 | vector limit_orders; 45 | vector call_orders; 46 | vector proposals; 47 | }; 48 | 49 | } } 50 | 51 | FC_REFLECT( graphene::app::full_account, 52 | (account) 53 | (statistics) 54 | (registrar_name) 55 | (referrer_name) 56 | (lifetime_referrer_name) 57 | (votes) 58 | (cashback_balance) 59 | (balances) 60 | (vesting_balances) 61 | (limit_orders) 62 | (call_orders) 63 | (proposals) 64 | ) 65 | -------------------------------------------------------------------------------- /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 | #include 29 | #include 30 | 31 | namespace graphene { namespace app { 32 | 33 | void operation_get_impacted_accounts( 34 | const graphene::chain::operation& op, 35 | fc::flat_set& result ); 36 | 37 | void transaction_get_impacted_accounts( 38 | const graphene::chain::transaction& tx, 39 | fc::flat_set& result 40 | ); 41 | 42 | } } // graphene::app 43 | -------------------------------------------------------------------------------- /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() 31 | { 32 | _app = nullptr; 33 | return; 34 | } 35 | 36 | plugin::~plugin() 37 | { 38 | return; 39 | } 40 | 41 | std::string plugin::plugin_name()const 42 | { 43 | return ""; 44 | } 45 | 46 | void plugin::plugin_initialize( const boost::program_options::variables_map& options ) 47 | { 48 | return; 49 | } 50 | 51 | void plugin::plugin_startup() 52 | { 53 | return; 54 | } 55 | 56 | void plugin::plugin_shutdown() 57 | { 58 | return; 59 | } 60 | 61 | void plugin::plugin_set_app( application* app ) 62 | { 63 | _app = app; 64 | return; 65 | } 66 | 67 | void plugin::plugin_set_program_options( 68 | boost::program_options::options_description& command_line_options, 69 | boost::program_options::options_description& config_file_options 70 | ) 71 | { 72 | return; 73 | } 74 | 75 | } } // graphene::app 76 | -------------------------------------------------------------------------------- /libraries/chain/buyback.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 | #include 29 | 30 | namespace graphene { namespace chain { 31 | 32 | void evaluate_buyback_account_options( const database& db, const buyback_account_options& bbo ) 33 | { 34 | FC_ASSERT( db.head_block_time() >= HARDFORK_538_TIME ); 35 | const asset_object& a = bbo.asset_to_buy(db); 36 | GRAPHENE_ASSERT( a.issuer == bbo.asset_to_buy_issuer, 37 | account_create_buyback_incorrect_issuer, "Incorrect asset issuer specified in buyback_account_options", ("asset", a)("bbo", bbo) ); 38 | GRAPHENE_ASSERT( !a.buyback_account.valid(), 39 | account_create_buyback_already_exists, "Cannot create buyback for asset which already has buyback", ("asset", a)("bbo", bbo) ); 40 | // TODO: Replace with chain parameter #554 41 | GRAPHENE_ASSERT( bbo.markets.size() < GRAPHENE_DEFAULT_MAX_BUYBACK_MARKETS, 42 | account_create_buyback_too_many_markets, "Too many buyback markets", ("asset", a)("bbo", bbo) ); 43 | } 44 | 45 | } } 46 | -------------------------------------------------------------------------------- /libraries/chain/database.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 "db_balance.cpp" 26 | #include "db_block.cpp" 27 | #include "db_debug.cpp" 28 | #include "db_getter.cpp" 29 | #include "db_init.cpp" 30 | #include "db_maint.cpp" 31 | #include "db_management.cpp" 32 | #include "db_market.cpp" 33 | #include "db_update.cpp" 34 | #include "db_witness_schedule.cpp" 35 | -------------------------------------------------------------------------------- /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.d/000-200-preamble.hf: -------------------------------------------------------------------------------- 1 | /***************************************** 2 | * * 3 | * This file is automatically generated. * 4 | * To create new hardfork, please modify * 5 | * the .hf files in hardfork.d instead * 6 | * of modifying this file. * 7 | * * 8 | *****************************************/ 9 | 10 | #pragma once 11 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/357.hf: -------------------------------------------------------------------------------- 1 | // #357 Disallow publishing certain malformed price feeds 2 | #ifndef HARDFORK_357_TIME 3 | #define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/359.hf: -------------------------------------------------------------------------------- 1 | // #359 Allow digits in asset name 2 | #ifndef HARDFORK_359_TIME 3 | #define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/409.hf: -------------------------------------------------------------------------------- 1 | // #409 Allow creation of sub-assets 2 | #ifndef HARDFORK_409_TIME 3 | #define HARDFORK_409_TIME (fc::time_point_sec( 1446652800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/413.hf: -------------------------------------------------------------------------------- 1 | // #413 Add operation to claim asset fees 2 | #ifndef HARDFORK_413_TIME 3 | #define HARDFORK_413_TIME (fc::time_point_sec( 1446652800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/415.hf: -------------------------------------------------------------------------------- 1 | // #415 Default accept policy for asset with no whitelist authorities 2 | #ifndef HARDFORK_415_TIME 3 | #define HARDFORK_415_TIME (fc::time_point_sec( 1446652800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/416.hf: -------------------------------------------------------------------------------- 1 | // #416 enforce_white_list is inconsistently applied 2 | #ifndef HARDFORK_416_TIME 3 | #define HARDFORK_416_TIME (fc::time_point_sec( 1446652800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/419.hf: -------------------------------------------------------------------------------- 1 | // #419 Account can pay fees in blacklisted asset 2 | #ifndef HARDFORK_419_TIME 3 | #define HARDFORK_419_TIME (fc::time_point_sec( 1446652800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/436.hf: -------------------------------------------------------------------------------- 1 | // #436 Prevent margin call from being triggered unless feed < call price 2 | #ifndef HARDFORK_436_TIME 3 | #define HARDFORK_436_TIME (fc::time_point_sec( 1450288800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/445.hf: -------------------------------------------------------------------------------- 1 | // #445 Refund create order fees on cancel 2 | #ifndef HARDFORK_445_TIME 3 | #define HARDFORK_445_TIME (fc::time_point_sec( 1450288800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/453.hf: -------------------------------------------------------------------------------- 1 | // #453 Hardfork to retroactively correct referral percentages 2 | #ifndef HARDFORK_453_TIME 3 | #define HARDFORK_453_TIME (fc::time_point_sec( 1450288800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/480.hf: -------------------------------------------------------------------------------- 1 | // #480 Fix non-BTS MIA core_exchange_rate check 2 | #ifndef HARDFORK_480_TIME 3 | #define HARDFORK_480_TIME (fc::time_point_sec( 1450378800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/483.hf: -------------------------------------------------------------------------------- 1 | // #483 Operation history numbering change 2 | #ifndef HARDFORK_483_TIME 3 | #define HARDFORK_483_TIME (fc::time_point_sec( 1450378800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/516.hf: -------------------------------------------------------------------------------- 1 | // #516 Special authorities 2 | #ifndef HARDFORK_516_TIME 3 | #define HARDFORK_516_TIME (fc::time_point_sec( 1455127200 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/533.hf: -------------------------------------------------------------------------------- 1 | // #533 Improve vote counting implementation 2 | #ifndef HARDFORK_533_TIME 3 | #define HARDFORK_533_TIME (fc::time_point_sec( 1455127200 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/538.hf: -------------------------------------------------------------------------------- 1 | // #538 Buyback accounts 2 | #ifndef HARDFORK_538_TIME 3 | #define HARDFORK_538_TIME (fc::time_point_sec( 1455127200 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/555.hf: -------------------------------------------------------------------------------- 1 | // #555 Buyback accounts 2 | #ifndef HARDFORK_555_TIME 3 | #define HARDFORK_555_TIME (fc::time_point_sec( 1455127200 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/563.hf: -------------------------------------------------------------------------------- 1 | // #563 Stealth fee routing 2 | #ifndef HARDFORK_563_TIME 3 | #define HARDFORK_563_TIME (fc::time_point_sec( 1455127200 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/572.hf: -------------------------------------------------------------------------------- 1 | // #572 Allow asset to update permission flags when no supply exists 2 | #ifndef HARDFORK_572_TIME 3 | #define HARDFORK_572_TIME (fc::time_point_sec( 1450378800 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/599.hf: -------------------------------------------------------------------------------- 1 | // #599 Unpacking of extension is incorrect 2 | #ifndef HARDFORK_599_TIME 3 | #define HARDFORK_599_TIME (fc::time_point_sec( 1458061200 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/607.hf: -------------------------------------------------------------------------------- 1 | // #607 Disable negative voting on workers 2 | #ifndef HARDFORK_607_TIME 3 | #define HARDFORK_607_TIME (fc::time_point_sec( 1458061200 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/613.hf: -------------------------------------------------------------------------------- 1 | // #613 Deprecate annual membership 2 | #ifndef HARDFORK_613_TIME 3 | #define HARDFORK_613_TIME (fc::time_point_sec( 1458061200 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/615.hf: -------------------------------------------------------------------------------- 1 | // #615 Fix price feed expiration check, so websocket server will never spam too much data 2 | #ifndef HARDFORK_615_TIME 3 | #define HARDFORK_615_TIME (fc::time_point_sec( 1457550000 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /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 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class assert_evaluator : public evaluator 32 | { 33 | public: 34 | typedef assert_operation operation_type; 35 | 36 | void_result do_evaluate( const assert_operation& o ); 37 | void_result do_apply( const assert_operation& o ); 38 | }; 39 | 40 | } } // graphene::chain 41 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/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 | #include 29 | #include 30 | #include 31 | 32 | namespace graphene { namespace chain { 33 | 34 | class balance_claim_evaluator : public evaluator 35 | { 36 | public: 37 | typedef balance_claim_operation operation_type; 38 | 39 | const balance_object* balance = nullptr; 40 | 41 | void_result do_evaluate(const balance_claim_operation& op); 42 | 43 | /** 44 | * @note the fee is always 0 for this particular operation because once the 45 | * balance is claimed it frees up memory and it cannot be used to spam the network 46 | */ 47 | void_result do_apply(const balance_claim_operation& op); 48 | }; 49 | 50 | } } // graphene::chain 51 | -------------------------------------------------------------------------------- /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 fc::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 | optional fetch_optional( const block_id_type& id )const; 43 | optional fetch_by_number( uint32_t block_num )const; 44 | optional last()const; 45 | optional last_id()const; 46 | private: 47 | mutable std::fstream _blocks; 48 | mutable std::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 | using namespace graphene::db; 29 | 30 | /** 31 | * @brief tracks minimal information about past blocks to implement TaPOS 32 | * @ingroup object 33 | * 34 | * When attempting to calculate the validity of a transaction we need to 35 | * lookup a past block and check its block hash and the time it occurred 36 | * so we can calculate whether the current transaction is valid and at 37 | * what time it should expire. 38 | */ 39 | class block_summary_object : public abstract_object 40 | { 41 | public: 42 | static const uint8_t space_id = implementation_ids; 43 | static const uint8_t type_id = impl_block_summary_object_type; 44 | 45 | block_id_type block_id; 46 | }; 47 | 48 | } } 49 | 50 | FC_REFLECT_DERIVED( graphene::chain::block_summary_object, (graphene::db::object), (block_id) ) 51 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/buyback.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 database; 31 | 32 | void evaluate_buyback_account_options( const database& db, const buyback_account_options& auth ); 33 | 34 | } } // graphene::chain 35 | -------------------------------------------------------------------------------- /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 abstract_object 36 | { 37 | public: 38 | static const uint8_t space_id = implementation_ids; 39 | static const uint8_t type_id = impl_chain_property_object_type; 40 | 41 | chain_id_type chain_id; 42 | immutable_chain_parameters immutable_parameters; 43 | }; 44 | 45 | } } 46 | 47 | FC_REFLECT_DERIVED( graphene::chain::chain_property_object, (graphene::db::object), 48 | (chain_id) 49 | (immutable_parameters) 50 | ) 51 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/committee_member_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 committee_member_create_evaluator : public evaluator 31 | { 32 | public: 33 | typedef committee_member_create_operation operation_type; 34 | 35 | void_result do_evaluate( const committee_member_create_operation& o ); 36 | object_id_type do_apply( const committee_member_create_operation& o ); 37 | }; 38 | 39 | class committee_member_update_evaluator : public evaluator 40 | { 41 | public: 42 | typedef committee_member_update_operation operation_type; 43 | 44 | void_result do_evaluate( const committee_member_update_operation& o ); 45 | void_result do_apply( const committee_member_update_operation& o ); 46 | }; 47 | 48 | class committee_member_update_global_parameters_evaluator : public evaluator 49 | { 50 | public: 51 | typedef committee_member_update_global_parameters_operation operation_type; 52 | 53 | void_result do_evaluate( const committee_member_update_global_parameters_operation& o ); 54 | void_result do_apply( const committee_member_update_global_parameters_operation& o ); 55 | }; 56 | 57 | } } // graphene::chain 58 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/confidential_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 | struct transfer_to_blind_operation; 30 | struct transfer_from_blind_operation; 31 | struct blind_transfer_operation; 32 | 33 | class transfer_to_blind_evaluator : public evaluator 34 | { 35 | public: 36 | typedef transfer_to_blind_operation operation_type; 37 | 38 | void_result do_evaluate( const transfer_to_blind_operation& o ); 39 | void_result do_apply( const transfer_to_blind_operation& o ) ; 40 | 41 | virtual void pay_fee() override; 42 | }; 43 | 44 | class transfer_from_blind_evaluator : public evaluator 45 | { 46 | public: 47 | typedef transfer_from_blind_operation operation_type; 48 | 49 | void_result do_evaluate( const transfer_from_blind_operation& o ); 50 | void_result do_apply( const transfer_from_blind_operation& o ) ; 51 | 52 | virtual void pay_fee() override; 53 | }; 54 | 55 | class blind_transfer_evaluator : public evaluator 56 | { 57 | public: 58 | typedef blind_transfer_operation operation_type; 59 | 60 | void_result do_evaluate( const blind_transfer_operation& o ); 61 | void_result do_apply( const blind_transfer_operation& o ) ; 62 | 63 | virtual void pay_fee() override; 64 | }; 65 | 66 | } } // namespace graphene::chain 67 | -------------------------------------------------------------------------------- /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 | #include 27 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class custom_evaluator : public evaluator 32 | { 33 | public: 34 | typedef custom_operation operation_type; 35 | 36 | void_result do_evaluate( const custom_operation& o ){ return void_result(); } 37 | void_result do_apply( const custom_operation& o ){ return void_result(); } 38 | }; 39 | } } 40 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/fba_accumulator_id.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 | /** 31 | * An object will be created at genesis for each of these FBA accumulators. 32 | */ 33 | enum graphene_fba_accumulator_id_enum 34 | { 35 | fba_accumulator_id_transfer_to_blind = 0, 36 | fba_accumulator_id_blind_transfer, 37 | fba_accumulator_id_transfer_from_blind, 38 | fba_accumulator_id_count 39 | }; 40 | 41 | } } 42 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/fba_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 | #include 28 | #include 29 | 30 | namespace graphene { namespace chain { 31 | 32 | class database; 33 | 34 | /** 35 | * fba_accumulator_object accumulates fees to be paid out via buyback or other FBA mechanism. 36 | */ 37 | 38 | class fba_accumulator_object : public graphene::db::abstract_object< fba_accumulator_object > 39 | { 40 | public: 41 | static const uint8_t space_id = implementation_ids; 42 | static const uint8_t type_id = impl_fba_accumulator_object_type; 43 | 44 | share_type accumulated_fba_fees; 45 | optional< asset_id_type > designated_asset; 46 | 47 | bool is_configured( const database& db )const; 48 | }; 49 | 50 | } } // graphene::chain 51 | 52 | FC_REFLECT_DERIVED( graphene::chain::fba_accumulator_object, (graphene::db::object), (accumulated_fba_fees)(designated_asset) ) 53 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/get_config.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 | fc::variant_object get_config(); 31 | 32 | } } // graphene::chain 33 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/immutable_chain_parameters.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 | #include 31 | 32 | namespace graphene { namespace chain { 33 | 34 | struct immutable_chain_parameters 35 | { 36 | uint16_t min_committee_member_count = GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT; 37 | uint16_t min_witness_count = GRAPHENE_DEFAULT_MIN_WITNESS_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_committee_member_count) 46 | (min_witness_count) 47 | (num_special_accounts) 48 | (num_special_assets) 49 | ) 50 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/internal_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 | #include 28 | 29 | #define GRAPHENE_DECLARE_INTERNAL_EXCEPTION( exc_name, seqnum, msg ) \ 30 | FC_DECLARE_DERIVED_EXCEPTION( \ 31 | internal_ ## exc_name, \ 32 | graphene::chain::internal_exception, \ 33 | 3990000 + seqnum, \ 34 | msg \ 35 | ) 36 | 37 | namespace graphene { namespace chain { 38 | 39 | FC_DECLARE_DERIVED_EXCEPTION( internal_exception, graphene::chain::chain_exception, 3990000, "internal exception" ) 40 | 41 | GRAPHENE_DECLARE_INTERNAL_EXCEPTION( verify_auth_max_auth_exceeded, 1, "Exceeds max authority fan-out" ) 42 | GRAPHENE_DECLARE_INTERNAL_EXCEPTION( verify_auth_account_not_found, 2, "Auth account not found" ) 43 | 44 | } } // graphene::chain 45 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/is_authorized_asset.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 chain { 27 | 28 | class account_object; 29 | class asset_object; 30 | class database; 31 | 32 | namespace detail { 33 | 34 | bool _is_authorized_asset(const database& d, const account_object& acct, const asset_object& asset_obj); 35 | 36 | } 37 | 38 | /** 39 | * @return true if the account is whitelisted and not blacklisted to transact in the provided asset; false 40 | * otherwise. 41 | */ 42 | 43 | inline bool is_authorized_asset(const database& d, const account_object& acct, const asset_object& asset_obj) 44 | { 45 | bool fast_check = !(asset_obj.options.flags & white_list); 46 | fast_check &= !(acct.allowed_assets.valid()); 47 | 48 | if( fast_check ) 49 | return true; 50 | 51 | bool slow_check = detail::_is_authorized_asset( d, acct, asset_obj ); 52 | return slow_check; 53 | } 54 | 55 | } } 56 | -------------------------------------------------------------------------------- /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 witness node. Or if we're processing a 35 | * transaction in a witness-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 | std::map< block_id_type, std::vector< fc::variant_object > > debug_updates; 47 | }; 48 | } } // graphene::chain 49 | -------------------------------------------------------------------------------- /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/protocol/buyback.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 | struct buyback_account_options 31 | { 32 | /** 33 | * The asset to buy. 34 | */ 35 | asset_id_type asset_to_buy; 36 | 37 | /** 38 | * Issuer of the asset. Must sign the transaction, must match issuer 39 | * of specified asset. 40 | */ 41 | account_id_type asset_to_buy_issuer; 42 | 43 | /** 44 | * What assets the account is willing to buy with. 45 | * Other assets will just sit there since the account has null authority. 46 | */ 47 | flat_set< asset_id_type > markets; 48 | }; 49 | 50 | } } 51 | 52 | FC_REFLECT( graphene::chain::buyback_account_options, (asset_to_buy)(asset_to_buy_issuer)(markets) ); 53 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/config.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 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/custom.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 | #include 27 | 28 | namespace graphene { namespace chain { 29 | 30 | /** 31 | * @brief provides a generic way to add higher level protocols on top of witness consensus 32 | * @ingroup operations 33 | * 34 | * There is no validation for this operation other than that required auths are valid and a fee 35 | * is paid that is appropriate for the data contained. 36 | */ 37 | struct custom_operation : public base_operation 38 | { 39 | struct fee_parameters_type { 40 | uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; 41 | uint32_t price_per_kbyte = 10; 42 | }; 43 | 44 | asset fee; 45 | account_id_type payer; 46 | flat_set required_auths; 47 | uint16_t id = 0; 48 | vector data; 49 | 50 | account_id_type fee_payer()const { return payer; } 51 | void validate()const; 52 | share_type calculate_fee(const fee_parameters_type& k)const; 53 | }; 54 | 55 | } } // namespace graphene::chain 56 | 57 | FC_REFLECT( graphene::chain::custom_operation::fee_parameters_type, (fee)(price_per_kbyte) ) 58 | FC_REFLECT( graphene::chain::custom_operation, (fee)(payer)(required_auths)(id)(data) ) 59 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/fba.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 | struct fba_distribute_operation : public base_operation 30 | { 31 | struct fee_parameters_type {}; 32 | 33 | asset fee; // always zero 34 | account_id_type account_id; 35 | fba_accumulator_id_type fba_id; 36 | share_type amount; 37 | 38 | account_id_type fee_payer()const { return account_id; } 39 | void validate()const { FC_ASSERT( false ); } 40 | share_type calculate_fee(const fee_parameters_type& k)const { return 0; } 41 | }; 42 | 43 | } } 44 | 45 | FC_REFLECT( graphene::chain::fba_distribute_operation::fee_parameters_type, ) 46 | 47 | FC_REFLECT( graphene::chain::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) 48 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/protocol.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 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/special_authority.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 | struct no_special_authority {}; 32 | 33 | struct top_holders_special_authority 34 | { 35 | asset_id_type asset; 36 | uint8_t num_top_holders = 1; 37 | }; 38 | 39 | typedef static_variant< 40 | no_special_authority, 41 | top_holders_special_authority 42 | > special_authority; 43 | 44 | void validate_special_authority( const special_authority& auth ); 45 | 46 | } } // graphene::chain 47 | 48 | FC_REFLECT( graphene::chain::no_special_authority, ) 49 | FC_REFLECT( graphene::chain::top_holders_special_authority, (asset)(num_top_holders) ) 50 | FC_REFLECT_TYPENAME( graphene::chain::special_authority ) 51 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/special_authority.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 database; 31 | 32 | void evaluate_special_authority( const database& db, const special_authority& auth ); 33 | 34 | } } // graphene::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 ) 39 | :_db(db){} 40 | 41 | 42 | database& db()const { assert( _db ); return *_db; } 43 | vector operation_results; 44 | 45 | const signed_transaction* _trx = nullptr; 46 | database* _db = nullptr; 47 | bool _is_proposed_trx = false; 48 | bool skip_fee = false; 49 | bool skip_fee_schedule_check = false; 50 | }; 51 | } } // namespace graphene::chain 52 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/transfer_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 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class transfer_evaluator : public evaluator 32 | { 33 | public: 34 | typedef transfer_operation operation_type; 35 | 36 | void_result do_evaluate( const transfer_operation& o ); 37 | void_result do_apply( const transfer_operation& o ); 38 | }; 39 | 40 | class override_transfer_evaluator : public evaluator 41 | { 42 | public: 43 | typedef override_transfer_operation operation_type; 44 | 45 | void_result do_evaluate( const override_transfer_operation& o ); 46 | void_result do_apply( const override_transfer_operation& o ); 47 | }; 48 | 49 | } } // graphene::chain 50 | -------------------------------------------------------------------------------- /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 | 28 | namespace graphene { namespace chain { 29 | 30 | class vesting_balance_create_evaluator; 31 | class vesting_balance_withdraw_evaluator; 32 | 33 | class vesting_balance_create_evaluator : public evaluator 34 | { 35 | public: 36 | typedef vesting_balance_create_operation operation_type; 37 | 38 | void_result do_evaluate( const vesting_balance_create_operation& op ); 39 | object_id_type do_apply( const vesting_balance_create_operation& op ); 40 | }; 41 | 42 | class vesting_balance_withdraw_evaluator : public evaluator 43 | { 44 | public: 45 | typedef vesting_balance_withdraw_operation operation_type; 46 | 47 | void_result do_evaluate( const vesting_balance_withdraw_operation& op ); 48 | void_result do_apply( const vesting_balance_withdraw_operation& op ); 49 | }; 50 | 51 | } } // graphene::chain 52 | -------------------------------------------------------------------------------- /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 | 28 | namespace graphene { namespace chain { 29 | 30 | class withdraw_permission_create_evaluator : public evaluator 31 | { 32 | public: 33 | typedef withdraw_permission_create_operation operation_type; 34 | 35 | void_result do_evaluate( const operation_type& op ); 36 | object_id_type do_apply( const operation_type& op ); 37 | }; 38 | 39 | class withdraw_permission_claim_evaluator : public evaluator 40 | { 41 | public: 42 | typedef withdraw_permission_claim_operation operation_type; 43 | 44 | void_result do_evaluate( const operation_type& op ); 45 | void_result do_apply( const operation_type& op ); 46 | }; 47 | 48 | class withdraw_permission_update_evaluator : public evaluator 49 | { 50 | public: 51 | typedef withdraw_permission_update_operation operation_type; 52 | 53 | void_result do_evaluate( const operation_type& op ); 54 | void_result do_apply( const operation_type& op ); 55 | }; 56 | 57 | class withdraw_permission_delete_evaluator : public evaluator 58 | { 59 | public: 60 | typedef withdraw_permission_delete_operation operation_type; 61 | 62 | void_result do_evaluate( const operation_type& op ); 63 | void_result do_apply( const operation_type& op ); 64 | }; 65 | 66 | } } // graphene::chain 67 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/witness_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 witness_create_evaluator : public evaluator 31 | { 32 | public: 33 | typedef witness_create_operation operation_type; 34 | 35 | void_result do_evaluate( const witness_create_operation& o ); 36 | object_id_type do_apply( const witness_create_operation& o ); 37 | }; 38 | 39 | class witness_update_evaluator : public evaluator 40 | { 41 | public: 42 | typedef witness_update_operation operation_type; 43 | 44 | void_result do_evaluate( const witness_update_operation& o ); 45 | void_result do_apply( const witness_update_operation& o ); 46 | }; 47 | 48 | } } // graphene::chain 49 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/witness_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 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class witness_schedule_object; 32 | 33 | class witness_schedule_object : public graphene::db::abstract_object 34 | { 35 | public: 36 | static const uint8_t space_id = implementation_ids; 37 | static const uint8_t type_id = impl_witness_schedule_object_type; 38 | 39 | vector< witness_id_type > current_shuffled_witnesses; 40 | }; 41 | 42 | } } 43 | 44 | FC_REFLECT_DERIVED( 45 | graphene::chain::witness_schedule_object, 46 | (graphene::db::object), 47 | (current_shuffled_witnesses) 48 | ) 49 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/worker_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 worker_create_evaluator : public evaluator 30 | { 31 | public: 32 | typedef worker_create_operation operation_type; 33 | 34 | void_result do_evaluate( const operation_type& o ); 35 | object_id_type do_apply( const operation_type& o ); 36 | }; 37 | 38 | } } // graphene::chain 39 | -------------------------------------------------------------------------------- /libraries/chain/index.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 | void base_primary_index::save_undo( const object& obj ) 30 | { _db.save_undo( obj ); } 31 | 32 | void base_primary_index::on_add( const object& obj ) 33 | { 34 | _db.save_undo_add( obj ); 35 | for( auto ob : _observers ) ob->on_add( obj ); 36 | } 37 | 38 | void base_primary_index::on_remove( const object& obj ) 39 | { _db.save_undo_remove( obj ); for( auto ob : _observers ) ob->on_remove( obj ); } 40 | 41 | void base_primary_index::on_modify( const object& obj ) 42 | {for( auto ob : _observers ) ob->on_modify( obj ); } 43 | } } // graphene::chain 44 | -------------------------------------------------------------------------------- /libraries/chain/is_authorized_asset.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 | #include 29 | #include 30 | 31 | namespace graphene { namespace chain { 32 | 33 | namespace detail { 34 | 35 | bool _is_authorized_asset( 36 | const database& d, 37 | const account_object& acct, 38 | const asset_object& asset_obj) 39 | { 40 | if( acct.allowed_assets.valid() ) 41 | { 42 | if( acct.allowed_assets->find( asset_obj.id ) == acct.allowed_assets->end() ) 43 | return false; 44 | // must still pass other checks even if it is in allowed_assets 45 | } 46 | 47 | for( const auto id : acct.blacklisting_accounts ) 48 | { 49 | if( asset_obj.options.blacklist_authorities.find(id) != asset_obj.options.blacklist_authorities.end() ) 50 | return false; 51 | } 52 | 53 | if( d.head_block_time() > HARDFORK_415_TIME ) 54 | { 55 | if( asset_obj.options.whitelist_authorities.size() == 0 ) 56 | return true; 57 | } 58 | 59 | for( const auto id : acct.whitelisting_accounts ) 60 | { 61 | if( asset_obj.options.whitelist_authorities.find(id) != asset_obj.options.whitelist_authorities.end() ) 62 | return true; 63 | } 64 | 65 | return false; 66 | } 67 | 68 | } // detail 69 | 70 | } } // graphene::chain 71 | -------------------------------------------------------------------------------- /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 | 26 | namespace graphene { namespace chain { 27 | 28 | bool account_name_eq_lit_predicate::validate()const 29 | { 30 | return is_valid_name( name ); 31 | } 32 | 33 | bool asset_symbol_eq_lit_predicate::validate()const 34 | { 35 | return is_valid_symbol( symbol ); 36 | } 37 | 38 | struct predicate_validator 39 | { 40 | typedef void result_type; 41 | 42 | template 43 | void operator()( const T& p )const 44 | { 45 | p.validate(); 46 | } 47 | }; 48 | 49 | void assert_operation::validate()const 50 | { 51 | FC_ASSERT( fee.amount >= 0 ); 52 | for( const auto& item : predicates ) 53 | item.visit( predicate_validator() ); 54 | } 55 | 56 | /** 57 | * The fee for assert operations is proportional to their size, 58 | * but cheaper than a data fee because they require no storage 59 | */ 60 | share_type assert_operation::calculate_fee(const fee_parameters_type& k)const 61 | { 62 | return k.fee * predicates.size(); 63 | } 64 | 65 | 66 | } } // namespace graphene::chain 67 | -------------------------------------------------------------------------------- /libraries/chain/protocol/authority.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 chain { 28 | 29 | void add_authority_accounts( 30 | flat_set& result, 31 | const authority& a 32 | ) 33 | { 34 | for( auto& item : a.account_auths ) 35 | result.insert( item.first ); 36 | } 37 | 38 | } } // graphene::chain 39 | -------------------------------------------------------------------------------- /libraries/chain/protocol/committee_member.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 committee_member_create_operation::validate()const 29 | { 30 | FC_ASSERT( fee.amount >= 0 ); 31 | FC_ASSERT(url.size() < GRAPHENE_MAX_URL_LENGTH ); 32 | } 33 | 34 | void committee_member_update_operation::validate()const 35 | { 36 | FC_ASSERT( fee.amount >= 0 ); 37 | if( new_url.valid() ) 38 | FC_ASSERT(new_url->size() < GRAPHENE_MAX_URL_LENGTH ); 39 | } 40 | 41 | void committee_member_update_global_parameters_operation::validate() const 42 | { 43 | FC_ASSERT( fee.amount >= 0 ); 44 | new_parameters.validate(); 45 | } 46 | 47 | } } // graphene::chain 48 | -------------------------------------------------------------------------------- /libraries/chain/protocol/custom.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 custom_operation::validate()const 29 | { 30 | FC_ASSERT( fee.amount > 0 ); 31 | } 32 | share_type custom_operation::calculate_fee(const fee_parameters_type& k)const 33 | { 34 | return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); 35 | } 36 | 37 | } } 38 | -------------------------------------------------------------------------------- /libraries/chain/protocol/market.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 limit_order_create_operation::validate()const 29 | { 30 | FC_ASSERT( amount_to_sell.asset_id != min_to_receive.asset_id ); 31 | FC_ASSERT( fee.amount >= 0 ); 32 | FC_ASSERT( amount_to_sell.amount > 0 ); 33 | FC_ASSERT( min_to_receive.amount > 0 ); 34 | } 35 | 36 | void limit_order_cancel_operation::validate()const 37 | { 38 | FC_ASSERT( fee.amount >= 0 ); 39 | } 40 | 41 | void call_order_update_operation::validate()const 42 | { try { 43 | FC_ASSERT( fee.amount >= 0 ); 44 | FC_ASSERT( delta_collateral.asset_id != delta_debt.asset_id ); 45 | FC_ASSERT( delta_collateral.amount != 0 || delta_debt.amount != 0 ); 46 | } FC_CAPTURE_AND_RETHROW((*this)) } 47 | 48 | } } // graphene::chain 49 | -------------------------------------------------------------------------------- /libraries/chain/protocol/transfer.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 | share_type transfer_operation::calculate_fee( const fee_parameters_type& schedule )const 29 | { 30 | share_type core_fee_required = schedule.fee; 31 | if( memo ) 32 | core_fee_required += calculate_data_fee( fc::raw::pack_size(memo), schedule.price_per_kbyte ); 33 | return core_fee_required; 34 | } 35 | 36 | 37 | void transfer_operation::validate()const 38 | { 39 | FC_ASSERT( fee.amount >= 0 ); 40 | FC_ASSERT( from != to ); 41 | FC_ASSERT( amount.amount > 0 ); 42 | } 43 | 44 | 45 | 46 | share_type override_transfer_operation::calculate_fee( const fee_parameters_type& schedule )const 47 | { 48 | share_type core_fee_required = schedule.fee; 49 | if( memo ) 50 | core_fee_required += calculate_data_fee( fc::raw::pack_size(memo), schedule.price_per_kbyte ); 51 | return core_fee_required; 52 | } 53 | 54 | 55 | void override_transfer_operation::validate()const 56 | { 57 | FC_ASSERT( fee.amount >= 0 ); 58 | FC_ASSERT( from != to ); 59 | FC_ASSERT( amount.amount > 0 ); 60 | FC_ASSERT( issuer != from ); 61 | } 62 | 63 | } } // graphene::chain 64 | -------------------------------------------------------------------------------- /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 = 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/witness.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 witness_create_operation::validate() const 29 | { 30 | FC_ASSERT(fee.amount >= 0); 31 | FC_ASSERT(url.size() < GRAPHENE_MAX_URL_LENGTH ); 32 | } 33 | 34 | void witness_update_operation::validate() const 35 | { 36 | FC_ASSERT(fee.amount >= 0); 37 | if( new_url.valid() ) 38 | FC_ASSERT(new_url->size() < GRAPHENE_MAX_URL_LENGTH ); 39 | } 40 | 41 | } } // graphene::chain 42 | -------------------------------------------------------------------------------- /libraries/chain/protocol/worker.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 worker_create_operation::validate() const 29 | { 30 | FC_ASSERT(fee.amount >= 0); 31 | FC_ASSERT(work_end_date > work_begin_date); 32 | FC_ASSERT(daily_pay > 0); 33 | FC_ASSERT(daily_pay < GRAPHENE_MAX_SHARE_SUPPLY); 34 | FC_ASSERT(name.size() < GRAPHENE_MAX_WORKER_NAME_LENGTH ); 35 | FC_ASSERT(url.size() < GRAPHENE_MAX_URL_LENGTH ); 36 | } 37 | 38 | } } 39 | -------------------------------------------------------------------------------- /libraries/chain/special_authority.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 chain { 29 | 30 | struct special_authority_validate_visitor 31 | { 32 | typedef void result_type; 33 | 34 | void operator()( const no_special_authority& a ) {} 35 | 36 | void operator()( const top_holders_special_authority& a ) 37 | { 38 | FC_ASSERT( a.num_top_holders > 0 ); 39 | } 40 | }; 41 | 42 | void validate_special_authority( const special_authority& a ) 43 | { 44 | special_authority_validate_visitor vtor; 45 | a.visit( vtor ); 46 | } 47 | 48 | struct special_authority_evaluate_visitor 49 | { 50 | typedef void result_type; 51 | 52 | special_authority_evaluate_visitor( const database& d ) : db(d) {} 53 | 54 | void operator()( const no_special_authority& a ) {} 55 | 56 | void operator()( const top_holders_special_authority& a ) 57 | { 58 | a.asset(db); // require asset to exist 59 | } 60 | 61 | const database& db; 62 | }; 63 | 64 | void evaluate_special_authority( const database& db, const special_authority& a ) 65 | { 66 | special_authority_evaluate_visitor vtor( db ); 67 | a.visit( vtor ); 68 | } 69 | 70 | } } // graphene::chain 71 | -------------------------------------------------------------------------------- /libraries/db/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/db/*.hpp") 2 | add_library( graphene_db undo_database.cpp index.cpp object_database.cpp ${HEADERS} ) 3 | target_link_libraries( graphene_db fc ) 4 | target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 5 | 6 | install( TARGETS 7 | graphene_db 8 | 9 | RUNTIME DESTINATION bin 10 | LIBRARY DESTINATION lib 11 | ARCHIVE DESTINATION lib 12 | ) 13 | -------------------------------------------------------------------------------- /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/db/index.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 db { 29 | void base_primary_index::save_undo( const object& obj ) 30 | { _db.save_undo( obj ); } 31 | 32 | void base_primary_index::on_add( const object& obj ) 33 | { 34 | _db.save_undo_add( obj ); 35 | for( auto ob : _observers ) ob->on_add( obj ); 36 | } 37 | 38 | void base_primary_index::on_remove( const object& obj ) 39 | { _db.save_undo_remove( obj ); for( auto ob : _observers ) ob->on_remove( obj ); } 40 | 41 | void base_primary_index::on_modify( const object& obj ) 42 | {for( auto ob : _observers ) ob->on_modify( obj ); } 43 | } } // graphene::chain 44 | -------------------------------------------------------------------------------- /libraries/deterministic_openssl_rand/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | file(GLOB headers "include/graphene/utilities/*.hpp") 3 | 4 | set(sources deterministic_openssl_rand.cpp 5 | ${headers}) 6 | 7 | add_library( deterministic_openssl_rand 8 | ${sources} 9 | ${HEADERS} ) 10 | target_link_libraries( deterministic_openssl_rand fc ) 11 | target_include_directories( deterministic_openssl_rand 12 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 13 | "${CMAKE_CURRENT_SOURCE_DIR}/../blockchain/include" 14 | ) 15 | 16 | if (USE_PCH) 17 | set_target_properties(deterministic_openssl_rand PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 18 | cotire(deterministic_openssl_rand) 19 | endif(USE_PCH) 20 | 21 | install( TARGETS 22 | deterministic_openssl_rand 23 | 24 | RUNTIME DESTINATION bin 25 | LIBRARY DESTINATION lib 26 | ARCHIVE DESTINATION lib 27 | ) 28 | -------------------------------------------------------------------------------- /libraries/deterministic_openssl_rand/include/graphene/utilities/deterministic_openssl_rand.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 | void set_random_seed_for_testing(const fc::sha512& new_seed); 30 | 31 | } } // end namespace graphene::utilities 32 | -------------------------------------------------------------------------------- /libraries/egenesis/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library( graphene_egenesis_none 3 | egenesis_none.cpp 4 | include/graphene/egenesis/egenesis.hpp 5 | ) 6 | 7 | target_link_libraries( graphene_egenesis_none graphene_chain fc ) 8 | target_include_directories( graphene_egenesis_none 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | add_executable( embed_genesis 12 | embed_genesis.cpp 13 | ) 14 | 15 | target_link_libraries( embed_genesis graphene_chain graphene_app graphene_egenesis_none fc ) 16 | 17 | set( embed_genesis_args 18 | -t "${CMAKE_CURRENT_SOURCE_DIR}/egenesis_brief.cpp.tmpl---${CMAKE_CURRENT_BINARY_DIR}/egenesis_brief.cpp" 19 | -t "${CMAKE_CURRENT_SOURCE_DIR}/egenesis_full.cpp.tmpl---${CMAKE_CURRENT_BINARY_DIR}/egenesis_full.cpp" 20 | ) 21 | 22 | MESSAGE( STATUS "egenesis: " ${GRAPHENE_EGENESIS_JSON} ) 23 | 24 | if( GRAPHENE_EGENESIS_JSON ) 25 | list( APPEND embed_genesis_args --genesis-json "${GRAPHENE_EGENESIS_JSON}" ) 26 | endif( GRAPHENE_EGENESIS_JSON ) 27 | 28 | MESSAGE( STATUS "embed_genesis_args: " ${embed_genesis_args} ) 29 | 30 | add_custom_command( 31 | OUTPUT 32 | "${CMAKE_CURRENT_BINARY_DIR}/egenesis_brief.cpp" 33 | "${CMAKE_CURRENT_BINARY_DIR}/egenesis_full.cpp" 34 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 35 | COMMAND embed_genesis ${embed_genesis_args} 36 | DEPENDS 37 | "${GRAPHENE_EGENESIS_JSON}" 38 | "${CMAKE_CURRENT_SOURCE_DIR}/egenesis_brief.cpp.tmpl" 39 | "${CMAKE_CURRENT_SOURCE_DIR}/egenesis_full.cpp.tmpl" 40 | embed_genesis ) 41 | 42 | add_library( graphene_egenesis_brief "${CMAKE_CURRENT_BINARY_DIR}/egenesis_brief.cpp" include/graphene/egenesis/egenesis.hpp ) 43 | add_library( graphene_egenesis_full "${CMAKE_CURRENT_BINARY_DIR}/egenesis_full.cpp" include/graphene/egenesis/egenesis.hpp ) 44 | 45 | target_link_libraries( graphene_egenesis_brief graphene_chain fc ) 46 | target_link_libraries( graphene_egenesis_full graphene_chain fc ) 47 | 48 | target_include_directories( graphene_egenesis_brief 49 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 50 | target_include_directories( graphene_egenesis_full 51 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 52 | 53 | INSTALL( TARGETS 54 | embed_genesis graphene_egenesis_none graphene_egenesis_brief graphene_egenesis_full 55 | 56 | RUNTIME DESTINATION bin 57 | LIBRARY DESTINATION lib 58 | ARCHIVE DESTINATION lib 59 | ) 60 | -------------------------------------------------------------------------------- /libraries/egenesis/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 | -------------------------------------------------------------------------------- /libraries/egenesis/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 | -------------------------------------------------------------------------------- /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/net/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/net/*.hpp") 2 | 3 | set(SOURCES node.cpp 4 | stcp_socket.cpp 5 | core_messages.cpp 6 | peer_database.cpp 7 | peer_connection.cpp 8 | message_oriented_connection.cpp) 9 | 10 | add_library( graphene_net ${SOURCES} ${HEADERS} ) 11 | 12 | target_link_libraries( graphene_net 13 | PUBLIC fc graphene_db ) 14 | target_include_directories( graphene_net 15 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 16 | PRIVATE "${CMAKE_SOURCE_DIR}/libraries/chain/include" 17 | ) 18 | 19 | if(MSVC) 20 | set_source_files_properties( node.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 21 | endif(MSVC) 22 | 23 | if (USE_PCH) 24 | set_target_properties(graphene_net PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 25 | cotire(graphene_net) 26 | endif(USE_PCH) 27 | 28 | install( TARGETS 29 | graphene_net 30 | 31 | RUNTIME DESTINATION bin 32 | LIBRARY DESTINATION lib 33 | ARCHIVE DESTINATION lib 34 | ) 35 | -------------------------------------------------------------------------------- /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 | #include 26 | 27 | namespace graphene { namespace net { 28 | // registered in node.cpp 29 | 30 | FC_DECLARE_EXCEPTION( net_exception, 90000, "P2P Networking Exception" ); 31 | FC_DECLARE_DERIVED_EXCEPTION( send_queue_overflow, graphene::net::net_exception, 90001, "send queue for this peer exceeded maximum size" ); 32 | FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, graphene::net::net_exception, 90002, "insufficient relay fee" ); 33 | FC_DECLARE_DERIVED_EXCEPTION( already_connected_to_requested_peer, graphene::net::net_exception, 90003, "already connected to requested peer" ); 34 | FC_DECLARE_DERIVED_EXCEPTION( block_older_than_undo_history, graphene::net::net_exception, 90004, "block is older than our undo history allows us to process" ); 35 | FC_DECLARE_DERIVED_EXCEPTION( peer_is_on_an_unreachable_fork, graphene::net::net_exception, 90005, "peer is on another fork" ); 36 | FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, graphene::net::net_exception, 90006, "unlinkable block" ) 37 | 38 | } } 39 | -------------------------------------------------------------------------------- /libraries/p2p/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/p2p/*.hpp") 2 | 3 | set(SOURCES node.cpp 4 | stcp_socket.cpp 5 | peer_connection.cpp 6 | message_oriented_connection.cpp) 7 | 8 | add_library( graphene_p2p ${SOURCES} ${HEADERS} ) 9 | 10 | target_link_libraries( graphene_p2p 11 | PUBLIC fc graphene_db ) 12 | target_include_directories( graphene_p2p 13 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 14 | PRIVATE "${CMAKE_SOURCE_DIR}/libraries/chain/include" 15 | ) 16 | 17 | #if(MSVC) 18 | # set_source_files_properties( node.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 19 | #endif(MSVC) 20 | 21 | #if (USE_PCH) 22 | # set_target_properties(graphene_p2p PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 23 | # cotire(graphene_p2p ) 24 | #endif(USE_PCH) 25 | 26 | install( TARGETS 27 | graphene_p2p 28 | 29 | RUNTIME DESTINATION bin 30 | LIBRARY DESTINATION lib 31 | ARCHIVE DESTINATION lib 32 | ) 33 | -------------------------------------------------------------------------------- /libraries/p2p/peer_connection.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 p2p { 27 | 28 | } } //graphene::p2p 29 | 30 | 31 | -------------------------------------------------------------------------------- /libraries/plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( witness ) 2 | add_subdirectory( account_history ) 3 | add_subdirectory( market_history ) 4 | add_subdirectory( delayed_node ) 5 | add_subdirectory( debug_witness ) -------------------------------------------------------------------------------- /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 | ) 6 | 7 | target_link_libraries( graphene_account_history graphene_chain graphene_app ) 8 | target_include_directories( graphene_account_history 9 | 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/debug_witness/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/debug_witness/*.hpp") 2 | 3 | add_library( graphene_debug_witness 4 | debug_api.cpp 5 | debug_witness.cpp 6 | ) 7 | 8 | target_link_libraries( graphene_debug_witness graphene_chain graphene_app ) 9 | target_include_directories( graphene_debug_witness 10 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 11 | 12 | install( TARGETS 13 | graphene_debug_witness 14 | 15 | RUNTIME DESTINATION bin 16 | LIBRARY DESTINATION lib 17 | ARCHIVE DESTINATION lib 18 | ) 19 | -------------------------------------------------------------------------------- /libraries/plugins/delayed_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/delayed_node/*.hpp") 2 | 3 | add_library( graphene_delayed_node 4 | delayed_node_plugin.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_delayed_node graphene_chain graphene_app ) 8 | target_include_directories( graphene_delayed_node 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | if(MSVC) 12 | set_source_files_properties( delayed_node_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 13 | endif(MSVC) 14 | 15 | install( TARGETS 16 | graphene_delayed_node 17 | 18 | RUNTIME DESTINATION bin 19 | LIBRARY DESTINATION lib 20 | ARCHIVE DESTINATION lib 21 | ) 22 | -------------------------------------------------------------------------------- /libraries/plugins/delayed_node/include/graphene/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(); 36 | virtual ~delayed_node_plugin(); 37 | 38 | std::string plugin_name()const override { return "delayed_node"; } 39 | virtual void plugin_set_program_options(boost::program_options::options_description&, 40 | boost::program_options::options_description& cfg) override; 41 | virtual void plugin_initialize(const boost::program_options::variables_map& options) override; 42 | virtual void plugin_startup() override; 43 | void mainloop(); 44 | 45 | protected: 46 | void connection_failed(); 47 | void connect(); 48 | void sync_with_trusted_node(); 49 | }; 50 | 51 | } } //graphene::account_history 52 | 53 | -------------------------------------------------------------------------------- /libraries/plugins/market_history/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/market_history/*.hpp") 2 | 3 | add_library( graphene_market_history 4 | market_history_plugin.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_market_history graphene_chain graphene_app ) 8 | target_include_directories( graphene_market_history 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | if(MSVC) 12 | set_source_files_properties( market_history_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 13 | endif(MSVC) 14 | 15 | install( TARGETS 16 | graphene_market_history 17 | 18 | RUNTIME DESTINATION bin 19 | LIBRARY DESTINATION lib 20 | ARCHIVE DESTINATION lib 21 | ) 22 | -------------------------------------------------------------------------------- /libraries/plugins/witness/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/witness/*.hpp") 2 | 3 | add_library( graphene_witness 4 | witness.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_witness graphene_chain graphene_app graphene_time ) 8 | target_include_directories( graphene_witness 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | install( TARGETS 12 | graphene_witness 13 | 14 | RUNTIME DESTINATION bin 15 | LIBRARY DESTINATION lib 16 | ARCHIVE DESTINATION lib 17 | ) 18 | -------------------------------------------------------------------------------- /libraries/time/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/time/*.hpp") 2 | 3 | add_library( graphene_time 4 | time.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_time fc ) 8 | target_include_directories( graphene_time 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | install( TARGETS 12 | graphene_time 13 | 14 | RUNTIME DESTINATION bin 15 | LIBRARY DESTINATION lib 16 | ARCHIVE DESTINATION lib 17 | ) 18 | -------------------------------------------------------------------------------- /libraries/time/include/graphene/time/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 time { 31 | 32 | typedef fc::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::time 47 | -------------------------------------------------------------------------------- /libraries/utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/libraries/fc/GitVersionGen" ) 2 | include( GetGitRevisionDescription ) 3 | get_git_head_revision(GIT_REFSPEC GRAPHENE_GIT_REVISION_SHA) 4 | get_git_unix_timestamp(GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP) 5 | git_describe(GRAPHENE_GIT_REVISION_DESCRIPTION --tags) 6 | if(NOT GRAPHENE_GIT_REVISION_DESCRIPTION) 7 | set(GRAPHENE_GIT_REVISION_DESCRIPTION "unknown") 8 | endif(NOT GRAPHENE_GIT_REVISION_DESCRIPTION) 9 | 10 | file(GLOB headers "include/graphene/utilities/*.hpp") 11 | 12 | set(sources 13 | key_conversion.cpp 14 | string_escape.cpp 15 | tempdir.cpp 16 | words.cpp 17 | ${headers}) 18 | 19 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" @ONLY) 20 | list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") 21 | 22 | add_library( graphene_utilities 23 | ${sources} 24 | ${HEADERS} ) 25 | target_link_libraries( graphene_utilities fc ) 26 | target_include_directories( graphene_utilities 27 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 28 | if (USE_PCH) 29 | set_target_properties(graphene_utilities PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 30 | cotire(graphene_utilities) 31 | endif(USE_PCH) 32 | 33 | install( TARGETS 34 | graphene_utilities 35 | 36 | RUNTIME DESTINATION bin 37 | LIBRARY DESTINATION lib 38 | ARCHIVE DESTINATION lib 39 | ) 40 | -------------------------------------------------------------------------------- /libraries/utilities/git_revision.cpp.in: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define GRAPHENE_GIT_REVISION_SHA "@GRAPHENE_GIT_REVISION_SHA@" 5 | #define GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP @GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP@ 6 | #define GRAPHENE_GIT_REVISION_DESCRIPTION "@GRAPHENE_GIT_REVISION_DESCRIPTION@" 7 | 8 | namespace graphene { namespace utilities { 9 | 10 | const char* const git_revision_sha = GRAPHENE_GIT_REVISION_SHA; 11 | const uint32_t git_revision_unix_timestamp = GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP; 12 | const char* const git_revision_description = GRAPHENE_GIT_REVISION_DESCRIPTION; 13 | 14 | } } // end namespace graphene::utilities 15 | -------------------------------------------------------------------------------- /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 | extern const char* const git_revision_sha; 30 | extern const uint32_t git_revision_unix_timestamp; 31 | extern const char* const git_revision_description; 32 | 33 | } } // end namespace graphene::utilities 34 | -------------------------------------------------------------------------------- /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/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 | /* 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 utilities { 29 | 30 | std::string escape_string_for_c_source_code(const std::string& input); 31 | 32 | } } // end namespace graphene::utilities 33 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/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 | fc::path temp_directory_path(); 33 | 34 | } } // graphene::utilities 35 | -------------------------------------------------------------------------------- /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/utilities/string_escape.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 | 27 | namespace graphene { namespace utilities { 28 | 29 | std::string escape_string_for_c_source_code(const std::string& input) 30 | { 31 | std::ostringstream escaped_string; 32 | escaped_string << "\""; 33 | for (unsigned i = 0; i < input.size(); ++i) 34 | { 35 | switch (input[i]) 36 | { 37 | case '\a': 38 | escaped_string << "\\a"; 39 | break; 40 | case '\b': 41 | escaped_string << "\\b"; 42 | break; 43 | case '\t': 44 | escaped_string << "\\t"; 45 | break; 46 | case '\n': 47 | escaped_string << "\\n"; 48 | break; 49 | case '\v': 50 | escaped_string << "\\v"; 51 | break; 52 | case '\f': 53 | escaped_string << "\\f"; 54 | break; 55 | case '\r': 56 | escaped_string << "\\r"; 57 | break; 58 | case '\\': 59 | escaped_string << "\\\\"; 60 | break; 61 | case '\"': 62 | escaped_string << "\\\""; 63 | break; 64 | default: 65 | escaped_string << input[i]; 66 | } 67 | } 68 | escaped_string << "\""; 69 | return escaped_string.str(); 70 | } 71 | 72 | } } // end namespace graphene::utilities 73 | 74 | -------------------------------------------------------------------------------- /libraries/utilities/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 26 | 27 | #include 28 | 29 | namespace graphene { namespace utilities { 30 | 31 | fc::path temp_directory_path() 32 | { 33 | const char* graphene_tempdir = getenv("GRAPHENE_TEMPDIR"); 34 | if( graphene_tempdir != nullptr ) 35 | return fc::path( graphene_tempdir ); 36 | return fc::temp_directory_path() / "graphene-tmp"; 37 | } 38 | 39 | } } // graphene::utilities 40 | -------------------------------------------------------------------------------- /libraries/wallet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/wallet/*.hpp") 2 | 3 | find_package( Perl ) 4 | find_package( Doxygen ) 5 | 6 | if( PERL_FOUND AND DOXYGEN_FOUND AND NOT "${CMAKE_GENERATOR}" STREQUAL "Ninja" ) 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 Doxyfile include/graphene/wallet/wallet.hpp ) 12 | add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp 13 | COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new 14 | 15 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp 16 | COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new 17 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/doxygen/perlmod/DoxyDocs.pm ) 18 | else() 19 | # no perl and doxygen, generate the best docs we can at runtime from reflection 20 | add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp 21 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/api_documentation_standin.cpp ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp 22 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/api_documentation_standin.cpp ) 23 | endif() 24 | 25 | add_library( graphene_wallet wallet.cpp ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp ${HEADERS} ) 26 | target_link_libraries( graphene_wallet PRIVATE graphene_app graphene_net graphene_chain graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 27 | target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 28 | 29 | if(MSVC) 30 | set_source_files_properties( wallet.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 31 | endif(MSVC) 32 | 33 | install( TARGETS 34 | graphene_wallet 35 | 36 | RUNTIME DESTINATION bin 37 | LIBRARY DESTINATION lib 38 | ARCHIVE DESTINATION lib 39 | ) 40 | -------------------------------------------------------------------------------- /programs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( build_helpers ) 2 | add_subdirectory( cli_wallet ) 3 | add_subdirectory( genesis_util ) 4 | add_subdirectory( witness_node ) 5 | add_subdirectory( debug_node ) 6 | add_subdirectory( delayed_node ) 7 | add_subdirectory( js_operation_serializer ) 8 | add_subdirectory( size_checker ) 9 | -------------------------------------------------------------------------------- /programs/build_helpers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable( cat-parts cat-parts.cpp ) 3 | if( UNIX AND NOT APPLE ) 4 | set(rt_library rt ) 5 | endif() 6 | 7 | # we only actually need Boost, but link against FC for now so we don't duplicate it. 8 | target_link_libraries( cat-parts PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 9 | 10 | add_executable( member_enumerator member_enumerator.cpp ) 11 | if( UNIX AND NOT APPLE ) 12 | set(rt_library rt ) 13 | endif() 14 | 15 | # we only actually need Boost, but link against FC for now so we don't duplicate it. 16 | target_link_libraries( member_enumerator PRIVATE fc graphene_app graphene_net graphene_chain graphene_egenesis_brief graphene_utilities graphene_wallet ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 17 | 18 | -------------------------------------------------------------------------------- /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 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | find_package( Gperftools QUIET ) 7 | if( GPERFTOOLS_FOUND ) 8 | message( STATUS "Found gperftools; compiling cli_wallet with TCMalloc") 9 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 10 | endif() 11 | 12 | target_link_libraries( cli_wallet 13 | PRIVATE graphene_app graphene_net graphene_chain graphene_egenesis_brief graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 14 | 15 | if(MSVC) 16 | set_source_files_properties( main.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 17 | endif(MSVC) 18 | 19 | install( TARGETS 20 | cli_wallet 21 | 22 | RUNTIME DESTINATION bin 23 | LIBRARY DESTINATION lib 24 | ARCHIVE DESTINATION lib 25 | ) 26 | -------------------------------------------------------------------------------- /programs/debug_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( debug_node main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | find_package( Gperftools QUIET ) 7 | if( GPERFTOOLS_FOUND ) 8 | message( STATUS "Found gperftools; compiling debug_node with TCMalloc") 9 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 10 | endif() 11 | 12 | target_link_libraries( debug_node 13 | PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_debug_witness graphene_chain graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 14 | 15 | install( TARGETS 16 | debug_node 17 | 18 | RUNTIME DESTINATION bin 19 | LIBRARY DESTINATION lib 20 | ARCHIVE DESTINATION lib 21 | ) 22 | -------------------------------------------------------------------------------- /programs/delayed_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( delayed_node main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | find_package( Gperftools QUIET ) 7 | if( GPERFTOOLS_FOUND ) 8 | message( STATUS "Found gperftools; compiling delayed_node with TCMalloc") 9 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 10 | endif() 11 | 12 | target_link_libraries( delayed_node 13 | PRIVATE graphene_app graphene_account_history graphene_market_history graphene_delayed_node graphene_chain graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 14 | 15 | install( TARGETS 16 | delayed_node 17 | 18 | RUNTIME DESTINATION bin 19 | LIBRARY DESTINATION lib 20 | ARCHIVE DESTINATION lib 21 | ) 22 | -------------------------------------------------------------------------------- /programs/genesis_util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable( genesis_update genesis_update.cpp ) 3 | if( UNIX AND NOT APPLE ) 4 | set(rt_library rt ) 5 | endif() 6 | 7 | target_link_libraries( genesis_update 8 | PRIVATE graphene_app graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 9 | 10 | install( TARGETS 11 | genesis_update 12 | 13 | RUNTIME DESTINATION bin 14 | LIBRARY DESTINATION lib 15 | ARCHIVE DESTINATION lib 16 | ) 17 | 18 | add_executable( get_dev_key get_dev_key.cpp ) 19 | 20 | target_link_libraries( get_dev_key 21 | PRIVATE graphene_app graphene_chain graphene_egenesis_none graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 22 | 23 | install( TARGETS 24 | get_dev_key 25 | 26 | RUNTIME DESTINATION bin 27 | LIBRARY DESTINATION lib 28 | ARCHIVE DESTINATION lib 29 | ) 30 | 31 | add_executable( convert_address convert_address.cpp ) 32 | 33 | target_link_libraries( convert_address 34 | PRIVATE graphene_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 35 | -------------------------------------------------------------------------------- /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/convert_address.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 | /** 26 | * Convert BTC / PTS addresses to a Graphene address. 27 | */ 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | using namespace graphene::chain; 36 | 37 | int main(int argc, char** argv) 38 | { 39 | // grab 0 or more whitespace-delimited PTS addresses from stdin 40 | std::string s; 41 | while( std::cin >> s ) 42 | { 43 | std::cout << std::string( address( pts_address( s ) ) ) << std::endl; 44 | } 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /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/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/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/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 | add_executable( js_operation_serializer main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | target_link_libraries( js_operation_serializer 7 | PRIVATE graphene_app graphene_net graphene_chain graphene_egenesis_none graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 8 | 9 | install( TARGETS 10 | js_operation_serializer 11 | 12 | RUNTIME DESTINATION bin 13 | LIBRARY DESTINATION lib 14 | ARCHIVE DESTINATION lib 15 | ) 16 | -------------------------------------------------------------------------------- /programs/size_checker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( size_checker main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | target_link_libraries( size_checker 7 | PRIVATE graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 8 | 9 | install( TARGETS 10 | size_checker 11 | 12 | RUNTIME DESTINATION bin 13 | LIBRARY DESTINATION lib 14 | ARCHIVE DESTINATION lib 15 | ) 16 | -------------------------------------------------------------------------------- /programs/witness_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( witness_node main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | find_package( Gperftools QUIET ) 7 | if( GPERFTOOLS_FOUND ) 8 | message( STATUS "Found gperftools; compiling witness_node with TCMalloc") 9 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 10 | endif() 11 | 12 | # We have to link against graphene_debug_witness because deficiency in our API infrastructure doesn't allow plugins to be fully abstracted #246 13 | target_link_libraries( witness_node 14 | PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain graphene_debug_witness graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 15 | 16 | install( TARGETS 17 | witness_node 18 | 19 | RUNTIME DESTINATION bin 20 | LIBRARY DESTINATION lib 21 | ARCHIVE DESTINATION lib 22 | ) 23 | -------------------------------------------------------------------------------- /programs/witness_node/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 | -------------------------------------------------------------------------------- /testnet-shared-balances.txt: -------------------------------------------------------------------------------- 1 | "initial_balances": [{ 2 | "owner": "BTSHYhQcrjVg5kBzCoeeD38eQdncCC5pBgee", 3 | "asset_symbol": "CORE", 4 | "amount": 100000000000 5 | },{ 6 | "owner": "BTSPgQZg5929ht1NBdEvsGKqoQ7buRu3nKf4", 7 | "asset_symbol": "CORE", 8 | "amount": 100000000000 9 | },{ 10 | "owner": "BTSC9zrLXSAPUQaVmQPk1S9dMqSzT7jPqYU7", 11 | "asset_symbol": "CORE", 12 | "amount": 100000000000 13 | },{ 14 | "owner": "BTS93aQPtbbkXwaSjtHaREsNVcCvbfHo93aZ", 15 | "asset_symbol": "CORE", 16 | "amount": 100000000000 17 | },{ 18 | "owner": "BTS6RM4UfsYFPDuhbmgkvDS9ip8Kvqundvyk", 19 | "asset_symbol": "CORE", 20 | "amount": 100000000000 21 | },{ 22 | "owner": "BTSNVkZXdqWWSzqHVxvfetMe347is6kEkC4K", 23 | "asset_symbol": "CORE", 24 | "amount": 100000000000 25 | },{ 26 | "owner": "BTS5GHzWZ64Luoajqsz6JGjTKVMgWYkGV9SQ", 27 | "asset_symbol": "CORE", 28 | "amount": 100000000000 29 | },{ 30 | "owner": "BTSDCVRFez92bW9doRLjnFCKLJnpM58mgmMb", 31 | "asset_symbol": "CORE", 32 | "amount": 100000000000 33 | },{ 34 | "owner": "BTS5CCdX3JYLBptYMuCjbsezqGYzN9vG9JCu", 35 | "asset_symbol": "CORE", 36 | "amount": 100000000000 37 | },{ 38 | "owner": "BTSEQ3yQdr3EMDL2eRqGiceMCpoanaW16Puw", 39 | "asset_symbol": "CORE", 40 | "amount": 100000000000 41 | },{ 42 | -------------------------------------------------------------------------------- /testnet-shared-private-keys.txt: -------------------------------------------------------------------------------- 1 | 5KCNDLVGqvX8p3GcMFun9sMe6XbMvycVTm4bGrkB5aZGWCbAAtr 2 | 5HvFQ1bcAWk8H1A2qXj1AqSNp93GUAb6b2w5TVfLb1jWL6yNF3f 3 | 5JSxv2kgaBSm9nGseRNhLhgEKTBmoKJ5CkgLbbk5RW4RBCNsLJC 4 | 5K5E2TQtrodDFzsqPq3oVFi9rVX15AN8sLE3iTHfVsX1b49y49J 5 | 5HxC3fwN7VDZXKVkbbX3SzCczh18Fetx8TXBfJ3z3ovDUSPKvVd 6 | 5KSr4w978PDanQDYtftarcfJVvGe4wedYb1sYbdH6HNpi15heRa 7 | 5Kan4si6qWvDVpZuqug4c6KQH4zkvDhwspaGQiFKYniJv6qji6t 8 | 5KcZri5DDsMcDp1DjNeMkZSijkWurPoAoR7gBKTnnetNQ9CpXoJ 9 | 5K5TRZyEhC6GPgi57t5FhiSMRGVTHEbwXngbBEtCA41gM8LPFhF 10 | 5KXVG4oP4Vj3RawRpta79UFAg7pWp17FGf4DnrKfkr69ELytDMv 11 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB COMMON_SOURCES "common/*.cpp") 2 | 3 | find_package( Gperftools QUIET ) 4 | if( GPERFTOOLS_FOUND ) 5 | message( STATUS "Found gperftools; compiling tests with TCMalloc") 6 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 7 | endif() 8 | 9 | file(GLOB UNIT_TESTS "tests/*.cpp") 10 | add_executable( chain_test ${UNIT_TESTS} ${COMMON_SOURCES} ) 11 | target_link_libraries( chain_test graphene_chain graphene_app graphene_account_history graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 12 | if(MSVC) 13 | set_source_files_properties( tests/serialization_tests.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 14 | endif(MSVC) 15 | 16 | file(GLOB PERFORMANCE_TESTS "performance/*.cpp") 17 | add_executable( performance_test ${PERFORMANCE_TESTS} ${COMMON_SOURCES} ) 18 | target_link_libraries( performance_test graphene_chain graphene_app graphene_account_history graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 19 | 20 | file(GLOB BENCH_MARKS "benchmarks/*.cpp") 21 | add_executable( chain_bench ${BENCH_MARKS} ${COMMON_SOURCES} ) 22 | target_link_libraries( chain_bench graphene_chain graphene_app graphene_account_history graphene_time graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 23 | 24 | file(GLOB APP_SOURCES "app/*.cpp") 25 | add_executable( app_test ${APP_SOURCES} ) 26 | target_link_libraries( app_test graphene_app graphene_account_history graphene_net graphene_chain graphene_time graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 27 | 28 | file(GLOB INTENSE_SOURCES "intense/*.cpp") 29 | add_executable( intense_test ${INTENSE_SOURCES} ${COMMON_SOURCES} ) 30 | target_link_libraries( intense_test graphene_chain graphene_app graphene_account_history graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 31 | 32 | add_subdirectory( generate_empty_blocks ) 33 | -------------------------------------------------------------------------------- /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/generate_empty_blocks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( generate_empty_blocks main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | target_link_libraries( generate_empty_blocks 7 | PRIVATE graphene_app graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 8 | 9 | install( TARGETS 10 | generate_empty_blocks 11 | 12 | RUNTIME DESTINATION bin 13 | LIBRARY DESTINATION lib 14 | ARCHIVE DESTINATION lib 15 | ) 16 | -------------------------------------------------------------------------------- /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 32 | 33 | #include "../common/database_fixture.hpp" 34 | 35 | using namespace graphene::chain; 36 | 37 | BOOST_AUTO_TEST_CASE( undo_test ) 38 | { 39 | try { 40 | database db; 41 | auto ses = db._undo_db.start_undo_session(); 42 | const auto& bal_obj1 = db.create( [&]( account_balance_object& obj ){ 43 | /* no balances right now */ 44 | }); 45 | auto id1 = bal_obj1.id; 46 | // abandon changes 47 | ses.undo(); 48 | // start a new session 49 | ses = db._undo_db.start_undo_session(); 50 | 51 | const auto& bal_obj2 = db.create( [&]( account_balance_object& obj ){ 52 | /* no balances right now */ 53 | }); 54 | auto id2 = bal_obj2.id; 55 | BOOST_CHECK( id1 == id2 ); 56 | } catch ( const fc::exception& e ) 57 | { 58 | edump( (e.to_detail_string()) ); 59 | throw; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /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(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 | --------------------------------------------------------------------------------