├── white_paper.pdf ├── .gitmodules ├── libraries ├── chain │ ├── hardfork.d │ │ ├── 538.hf │ │ ├── 555.hf │ │ ├── 516.hf │ │ ├── 563.hf │ │ ├── 359.hf │ │ ├── 409.hf │ │ ├── 613.hf │ │ ├── 413.hf │ │ ├── 445.hf │ │ ├── 483.hf │ │ ├── 533.hf │ │ ├── 599.hf │ │ ├── 607.hf │ │ ├── 419.hf │ │ ├── 480.hf │ │ ├── 416.hf │ │ ├── 357.hf │ │ ├── 385.hf │ │ ├── 453.hf │ │ ├── 415.hf │ │ ├── 572.hf │ │ ├── 436.hf │ │ ├── 615.hf │ │ └── 000-200-preamble.hf │ ├── include │ │ └── graphene │ │ │ └── chain │ │ │ ├── protocol │ │ │ ├── README.md │ │ │ ├── config.hpp │ │ │ ├── protocol.hpp │ │ │ ├── fba.hpp │ │ │ ├── buyback.hpp │ │ │ └── special_authority.hpp │ │ │ ├── get_config.hpp │ │ │ ├── buyback.hpp │ │ │ ├── special_authority.hpp │ │ │ ├── worker_evaluator.hpp │ │ │ ├── fba_accumulator_id.hpp │ │ │ ├── assert_evaluator.hpp │ │ │ ├── custom_evaluator.hpp │ │ │ ├── incentive_evaluator.hpp │ │ │ ├── immutable_chain_parameters.hpp │ │ │ ├── witness_schedule_object.hpp │ │ │ ├── chain_property_object.hpp │ │ │ ├── witness_evaluator.hpp │ │ │ ├── is_authorized_asset.hpp │ │ │ ├── balance_evaluator.hpp │ │ │ ├── transfer_evaluator.hpp │ │ │ ├── fba_object.hpp │ │ │ ├── node_property_object.hpp │ │ │ ├── block_summary_object.hpp │ │ │ ├── vesting_balance_evaluator.hpp │ │ │ ├── internal_exceptions.hpp │ │ │ └── block_database.hpp │ ├── protocol │ │ ├── incentive.cpp │ │ ├── authority.cpp │ │ ├── deflation.cpp │ │ ├── custom.cpp │ │ ├── worker.cpp │ │ ├── witness.cpp │ │ ├── vote.cpp │ │ ├── market.cpp │ │ ├── construction_capital.cpp │ │ ├── committee_member.cpp │ │ └── assert.cpp │ ├── database.cpp │ ├── genesis_state.cpp │ ├── index.cpp │ └── buyback.cpp ├── plugins │ ├── CMakeLists.txt │ ├── witness │ │ └── CMakeLists.txt │ ├── debug_witness │ │ └── CMakeLists.txt │ ├── delayed_node │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── graphene │ │ │ └── delayed_node │ │ │ └── delayed_node_plugin.hpp │ ├── market_history │ │ └── CMakeLists.txt │ ├── account_history │ │ └── CMakeLists.txt │ ├── incentive_history │ │ └── CMakeLists.txt │ └── transaction_record │ │ └── CMakeLists.txt ├── CMakeLists.txt ├── db │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── db │ │ │ └── fwd.hpp │ └── index.cpp ├── time │ ├── CMakeLists.txt │ └── include │ │ └── graphene │ │ └── time │ │ └── time.hpp ├── utilities │ ├── git_revision.cpp.in │ ├── include │ │ └── graphene │ │ │ └── utilities │ │ │ ├── words.hpp │ │ │ ├── tempdir.hpp │ │ │ ├── string_escape.hpp │ │ │ ├── git_revision.hpp │ │ │ └── key_conversion.hpp │ ├── CMakeLists.txt │ └── tempdir.cpp ├── deterministic_openssl_rand │ ├── CMakeLists.txt │ └── include │ │ └── graphene │ │ └── utilities │ │ └── deterministic_openssl_rand.hpp ├── net │ └── CMakeLists.txt ├── app │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── app │ │ │ ├── api_access.hpp │ │ │ └── impacted.hpp │ └── plugin.cpp └── egenesis │ ├── egenesis_none.cpp │ ├── egenesis_brief.cpp.tmpl │ └── include │ └── graphene │ └── egenesis │ └── egenesis.hpp ├── docker ├── Dockerfile-bin ├── launch └── Dockerfile ├── src └── hyper_core │ └── rust │ ├── .gitignore │ ├── src │ ├── main.rs │ └── ahi_ai_core.rs │ ├── Cargo.toml │ └── tests │ └── test_super_pi_ecosystem.rs ├── programs ├── CMakeLists.txt ├── genesis_util │ ├── python_format.py │ ├── canonical_format.py │ ├── CMakeLists.txt │ ├── change_bitasset_owners.py │ ├── unprefix_asset_owners.py │ ├── sort_objects.py │ ├── convert_address.cpp │ ├── unprefix_names.py │ ├── change_asset_symbol.py │ ├── apply_patch.py │ ├── upgrade_members.py │ └── generate_init_config.py ├── size_checker │ └── CMakeLists.txt ├── js_operation_serializer │ └── CMakeLists.txt ├── witness_node │ ├── saltpass.py │ └── CMakeLists.txt ├── delayed_node │ └── CMakeLists.txt ├── build_helpers │ └── CMakeLists.txt ├── debug_node │ └── CMakeLists.txt ├── cli_wallet │ └── CMakeLists.txt └── cold_wallet │ └── CMakeLists.txt ├── tests ├── generate_empty_blocks │ └── CMakeLists.txt ├── benchmarks │ └── main.cpp ├── intense │ └── main.cpp ├── CMakeLists.txt └── tests │ └── main.cpp ├── .gitignore ├── quantum_ai_innovations ├── quantum_consensus.py ├── ai_smart_contracts.py ├── quantum_ml.py ├── quantum_nlp.py ├── quantum_encryption.py ├── quantum_image_classification.py ├── decentralized_ai_service.py ├── quantum_voting.py ├── quantum_financial_forecasting.py ├── quantum_recommendation.py └── dynamic_supply_adjustment.py ├── economic_stabilization ├── incentive_mechanism.py ├── quantum_security.py ├── PiCoinStabilization.sol ├── dynamic_pricing_model.py ├── risk_assessment_tool.py └── dynamic_supply_adjustment.py ├── LICENSE.md ├── .env.example ├── quantum_models ├── quantum_neural_network.py ├── noisy_quantum_model.py └── hybrid_quantum_classical_model.py ├── LICENSE.bitshares.md ├── user_interface ├── api_server.py └── web_app.py ├── HEADER ├── README.md ├── governance ├── governance_token.sol └── voting_system.py └── decentralized_finance └── yield_farming.py /white_paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KOSASIH/super-pi/HEAD/white_paper.pdf -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libraries/fc"] 2 | path = libraries/fc 3 | url = https://github.com/pidiscovery/bitshares-fc.git 4 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/538.hf: -------------------------------------------------------------------------------- 1 | // #538 Buyback accounts 2 | #ifndef HARDFORK_538_TIME 3 | #define HARDFORK_538_TIME (fc::time_point_sec( 1456250400 )) 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( 1456250400 )) 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( 1456250400 )) 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( 1456250400 )) 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/613.hf: -------------------------------------------------------------------------------- 1 | // #613 Deprecate annual membership 2 | #ifndef HARDFORK_613_TIME 3 | #define HARDFORK_613_TIME (fc::time_point_sec( 1458752400 )) 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/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/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/533.hf: -------------------------------------------------------------------------------- 1 | // #533 Improve vote counting implementation 2 | #ifndef HARDFORK_533_TIME 3 | #define HARDFORK_533_TIME (fc::time_point_sec( 1456250400 )) 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( 1459789200 )) 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( 1458752400 )) 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/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/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/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/385.hf: -------------------------------------------------------------------------------- 1 | // #385 October 23 enforce PARENT.CHILD and allow short names 2 | #ifndef HARDFORK_385_TIME 3 | #define HARDFORK_385_TIME (fc::time_point_sec( 1445558400 )) 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/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/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( 1456250400 )) 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/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( 1458752400 )) 4 | #endif 5 | -------------------------------------------------------------------------------- /docker/Dockerfile-bin: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER "wallex64 wallex64@outlook.com" 3 | 4 | ADD entry.sh / 5 | ADD witness_node /usr/local/bin 6 | ADD cli_wallet /usr/local/bin 7 | 8 | 9 | EXPOSE 40010/tcp 10 | EXPOSE 8010/tcp 11 | 12 | CMD ["/entry.sh"] 13 | 14 | -------------------------------------------------------------------------------- /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 ) 6 | add_subdirectory( incentive_history ) 7 | add_subdirectory( transaction_record ) -------------------------------------------------------------------------------- /src/hyper_core/rust/.gitignore: -------------------------------------------------------------------------------- 1 | # Rust build artifacts 2 | target/ 3 | Cargo.lock 4 | 5 | # Soroban specific 6 | *.wasm 7 | soroban-*.log 8 | 9 | # IDE and editor files 10 | .vscode/ 11 | .idea/ 12 | *.swp 13 | *.swo 14 | 15 | # OS files 16 | .DS_Store 17 | Thumbs.db 18 | 19 | # Logs 20 | *.log 21 | 22 | # Temporary files 23 | *.tmp 24 | -------------------------------------------------------------------------------- /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( utilities ) 8 | add_subdirectory( app ) 9 | add_subdirectory( plugins ) 10 | add_subdirectory( wallet ) 11 | -------------------------------------------------------------------------------- /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 | add_subdirectory( cold_wallet ) 10 | -------------------------------------------------------------------------------- /src/hyper_core/rust/src/main.rs: -------------------------------------------------------------------------------- 1 | use soroban_sdk::Env; 2 | 3 | mod lib; // Import lib.rs 4 | 5 | fn main() { 6 | let env = Env::default(); 7 | let ecosystem = lib::SuperPiEcosystem::init(env.clone()); 8 | lib::SuperPiEcosystem::run_full_super_pi_ecosystem(env.clone()); 9 | let status = lib::SuperPiEcosystem::get_ecosystem_status(env); 10 | println!("Ecosystem Status: {:?}", status); 11 | } 12 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docker/launch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | [ -e /data_dir/config.ini ] || cp /default_config.ini /data_dir/config.ini 4 | 5 | [ -e /data_dir/pre_exec ] && bash /data_dir/pre_exec 6 | if [ -e /data_dir/extra_args ]; then 7 | /bitshares-2/programs/witness_node/witness_node --data-dir /data_dir `cat /data_dir/extra_args` 8 | else 9 | /bitshares-2/programs/witness_node/witness_node --data-dir /data_dir 10 | fi 11 | [ -e /data_dir/post_exec ] && bash /data_dir/post_exec 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | install( FILES ${HEADERS} DESTINATION "include/graphene/db" ) 14 | -------------------------------------------------------------------------------- /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/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 ) 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 | install( FILES ${HEADERS} DESTINATION "include/graphene/time" ) 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # Build a docker image from github source code 2 | 3 | FROM ubuntu:16.04 4 | MAINTAINER walle x64 5 | 6 | RUN apt-get update && apt-get upgrade -y 7 | RUN apt-get install -y git build-essential libboost-all-dev libssl-dev cmake autoconf 8 | 9 | RUN cd /root && git clone https://github.com/pidiscovery/pi.git 10 | RUN cd /root/pi && git submodule update --init --recursive 11 | RUN cd /root/pi && mkdir build && cd build && cmake .. 12 | RUN cd /root/pi/build && make install 13 | RUN rm -rf /root/pi 14 | 15 | ADD entry.sh /entry.sh 16 | 17 | EXPOSE 40010/tcp 18 | EXPOSE 8010/tcp 19 | 20 | CMD ["/entry.sh"] 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.sw* 3 | 4 | *.cmake 5 | CMakeCache.txt 6 | CMakeFiles 7 | Makefile 8 | compile_commands.json 9 | moc_* 10 | *.moc 11 | 12 | genesis.json 13 | hardfork.hpp 14 | 15 | libraries/utilities/git_revision.cpp 16 | 17 | libraries/wallet/Doxyfile 18 | libraries/wallet/api_documentation.cpp 19 | libraries/wallet/doxygen 20 | 21 | programs/cli_wallet/cli_wallet 22 | programs/js_operation_serializer/js_operation_serializer 23 | programs/witness_node/witness_node 24 | 25 | tests/app_test 26 | tests/chain_bench 27 | tests/chain_test 28 | tests/intense_test 29 | tests/performance_test 30 | 31 | doxygen 32 | 33 | wallet.json 34 | witness_node_data_dir 35 | 36 | *.wallet 37 | 38 | programs/witness_node/object_database/* 39 | 40 | object_database/* 41 | 42 | *.pyc 43 | *.pyo 44 | -------------------------------------------------------------------------------- /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 | INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/market_history" ) 23 | 24 | -------------------------------------------------------------------------------- /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 | INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/account_history" ) 23 | 24 | -------------------------------------------------------------------------------- /libraries/plugins/incentive_history/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/incnetive_history/*.hpp") 2 | 3 | add_library( graphene_incentive_history 4 | incentive_history_plugin.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_incentive_history graphene_chain graphene_app ) 8 | target_include_directories( graphene_incentive_history 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | if(MSVC) 12 | set_source_files_properties( incentive_history_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 13 | endif(MSVC) 14 | 15 | install( TARGETS 16 | graphene_incentive_history 17 | 18 | RUNTIME DESTINATION bin 19 | LIBRARY DESTINATION lib 20 | ARCHIVE DESTINATION lib 21 | ) 22 | INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/incentive_history" ) 23 | 24 | -------------------------------------------------------------------------------- /libraries/plugins/transaction_record/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/transaction_record/*.hpp") 2 | 3 | add_library( graphene_transaction_record 4 | transaction_record_plugin.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_transaction_record graphene_chain graphene_app ) 8 | target_include_directories( graphene_transaction_record 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | if(MSVC) 12 | set_source_files_properties( transaction_record_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 13 | endif(MSVC) 14 | 15 | install( TARGETS 16 | graphene_transaction_record 17 | 18 | RUNTIME DESTINATION bin 19 | LIBRARY DESTINATION lib 20 | ARCHIVE DESTINATION lib 21 | ) 22 | INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/transaction_record" ) 23 | 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /quantum_ai_innovations/quantum_consensus.py: -------------------------------------------------------------------------------- 1 | # quantum_consensus.py 2 | 3 | import cirq 4 | 5 | def quantum_consensus_algorithm(): 6 | # Define a simple quantum circuit for consensus 7 | qubits = cirq.LineQubit.range(3) 8 | circuit = cirq.Circuit( 9 | cirq.H(qubits[0]), # Initialize qubit 0 10 | cirq.CNOT(qubits[0], qubits[1]), # Entangle qubit 0 and 1 11 | cirq.CNOT(qubits[0], qubits[2]), # Entangle qubit 0 and 2 12 | cirq.measure(*qubits, key='result') # Measure the qubits 13 | ) 14 | 15 | # Simulate the circuit 16 | simulator = cirq.Simulator() 17 | result = simulator.run(circuit, repetitions=100) 18 | 19 | # Display the results 20 | print("Consensus results:", result.histogram(key='result')) 21 | 22 | if __name__ == "__main__": 23 | quantum_consensus_algorithm() 24 | -------------------------------------------------------------------------------- /quantum_ai_innovations/ai_smart_contracts.py: -------------------------------------------------------------------------------- 1 | # ai_smart_contracts.py 2 | 3 | import numpy as np 4 | from sklearn.linear_model import LinearRegression 5 | 6 | def ai_optimize_contract(features, targets): 7 | # Reshape the features for the model 8 | X = np.array(features).reshape(-1, 1) 9 | y = np.array(targets) 10 | 11 | # Create and train the model 12 | model = LinearRegression() 13 | model.fit(X, y) 14 | 15 | # Output the optimized contract parameters 16 | print("Optimized contract parameters:", model.coef_) 17 | return model 18 | 19 | if __name__ == "__main__": 20 | # Sample data for contract optimization 21 | sample_features = [1, 2, 3, 4, 5] 22 | sample_targets = [2, 3, 5, 7, 11] 23 | 24 | # Optimize the smart contract 25 | ai_optimize_contract(sample_features, sample_targets) 26 | -------------------------------------------------------------------------------- /economic_stabilization/incentive_mechanism.py: -------------------------------------------------------------------------------- 1 | class IncentiveMechanism: 2 | def __init__(self): 3 | self.user_rewards = {} 4 | 5 | def transact(self, user, amount): 6 | # Simulate a transaction and reward the user 7 | if user not in self.user_rewards: 8 | self.user_rewards[user] = 0 9 | reward = self.calculate_reward(amount) 10 | self.user_rewards[user] += reward 11 | print(f"User {user} transacted {amount} PI. Reward: {reward}. Total Rewards: {self.user_rewards[user]}") 12 | 13 | def calculate_reward(self, amount): 14 | # Reward 2% of the transaction amount 15 | return amount * 0.02 16 | 17 | if __name__ == "__main__": 18 | incentive_system = IncentiveMechanism() 19 | incentive_system.transact("Alice", 1000) 20 | incentive_system.transact("Bob", 500) 21 | incentive_system.transact("Alice", 2000) 22 | -------------------------------------------------------------------------------- /economic_stabilization/quantum_security.py: -------------------------------------------------------------------------------- 1 | import cirq 2 | 3 | class QuantumSecurity: 4 | def __init__(self): 5 | self.qubits = cirq.LineQubit.range(2) 6 | 7 | def secure_transaction(self, transaction_data): 8 | # Create a quantum circuit for securing the transaction 9 | circuit = cirq.Circuit( 10 | cirq.H(self.qubits[0]), # Create superposition 11 | cirq.CNOT(self.qubits[0], self.qubits[1]), # Entangle qubits 12 | cirq.measure(*self.qubits, key='result') # Measure the qubits 13 | ) 14 | simulator = cirq.Simulator() 15 | result = simulator.run(circuit) 16 | print(f"Transaction Data: {transaction_data}, Quantum Security Result: {result}") 17 | 18 | if __name__ == "__main__": 19 | security_system = QuantumSecurity() 20 | security_system.secure_transaction("Transaction 1: Alice pays Bob 100 PI") 21 | -------------------------------------------------------------------------------- /quantum_ai_innovations/quantum_ml.py: -------------------------------------------------------------------------------- 1 | # quantum_ml.py 2 | 3 | import tensorflow as tf 4 | import tensorflow_quantum as tfq 5 | import cirq 6 | 7 | def create_quantum_model(): 8 | # Define a simple quantum circuit 9 | qubits = cirq.GridQubit.rect(1, 2) 10 | circuit = cirq.Circuit( 11 | cirq.H(qubits[0]), # Hadamard gate 12 | cirq.CNOT(qubits[0], qubits[1]) # CNOT gate 13 | ) 14 | 15 | # Create a quantum layer 16 | model = tfq.layers.PQC(circuit, cirq.Z(qubits[1])) 17 | return model 18 | 19 | def quantum_ml_model(): 20 | # Create the quantum model 21 | model = create_quantum_model() 22 | 23 | # Example input data 24 | input_data = tfq.convert_to_tensor([cirq.Circuit(cirq.X(cirq.GridQubit(0, 0)))]) 25 | 26 | # Get the output from the model 27 | output = model(input_data) 28 | print("Quantum ML Model Output:", output.numpy()) 29 | 30 | if __name__ == "__main__": 31 | quantum_ml_model() 32 | -------------------------------------------------------------------------------- /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_incentive_history graphene_transaction_record 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 | -------------------------------------------------------------------------------- /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 | install( FILES ${headers} DESTINATION "include/graphene/deterministic_openssl_rand" ) 29 | -------------------------------------------------------------------------------- /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 | install( FILES ${HEADERS} DESTINATION "include/graphene/net" ) 36 | -------------------------------------------------------------------------------- /programs/cold_wallet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( key_generator key_generator.cpp ) 2 | 3 | target_link_libraries( key_generator 4 | PRIVATE graphene_chain fc graphene_utilities ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 5 | 6 | if(MSVC) 7 | set_source_files_properties( key_generator.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 8 | endif(MSVC) 9 | 10 | install( TARGETS 11 | key_generator 12 | 13 | RUNTIME DESTINATION bin 14 | LIBRARY DESTINATION lib 15 | ARCHIVE DESTINATION lib 16 | ) 17 | 18 | add_executable( cold_wallet cold_wallet.cpp ) 19 | 20 | target_link_libraries( cold_wallet 21 | PRIVATE graphene_app graphene_net graphene_chain graphene_egenesis_brief graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 22 | 23 | if(MSVC) 24 | set_source_files_properties( cold_wallet.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 25 | endif(MSVC) 26 | 27 | install( TARGETS 28 | cold_wallet 29 | 30 | RUNTIME DESTINATION bin 31 | LIBRARY DESTINATION lib 32 | ARCHIVE DESTINATION lib 33 | ) 34 | 35 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | The MIT License 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # .env.example 2 | 3 | # Network Configuration 4 | # Specify the blockchain network to connect to (e.g., mainnet, testnet) 5 | NETWORK=mainnet 6 | 7 | # Infura Project ID 8 | # Replace with your Infura project ID for Ethereum network access 9 | INFURA_PROJECT_ID=your_infura_project_id 10 | 11 | # Private Key 12 | # Your wallet's private key (keep this secret and secure) 13 | PRIVATE_KEY=your_wallet_private_key 14 | 15 | # Database Configuration 16 | # Database connection string (if applicable) 17 | DATABASE_URL=mongodb://username:password@localhost:27017/pi_database 18 | 19 | # AI Service Configuration 20 | # API key for AI services (if applicable) 21 | AI_SERVICE_API_KEY=your_ai_service_api_key 22 | 23 | # Quantum Service Configuration 24 | # Configuration for quantum computing services (if applicable) 25 | QUANTUM_SERVICE_URL=https://quantum.example.com/api 26 | QUANTUM_API_KEY=your_quantum_api_key 27 | 28 | # Logging Configuration 29 | # Set the logging level (e.g., debug, info, warn, error) 30 | LOG_LEVEL=info 31 | 32 | # Other Configuration 33 | # Any other environment variables specific to your application 34 | -------------------------------------------------------------------------------- /quantum_models/quantum_neural_network.py: -------------------------------------------------------------------------------- 1 | # quantum_neural_network.py 2 | 3 | import tensorflow as tf 4 | import tensorflow_quantum as tfq 5 | import cirq 6 | import numpy as np 7 | 8 | # Define a simple quantum circuit 9 | def create_quantum_circuit(qubits): 10 | circuit = cirq.Circuit() 11 | circuit.append(cirq.H(qubits[0])) # Hadamard gate 12 | circuit.append(cirq.CNOT(qubits[0], qubits[1])) # CNOT gate 13 | return circuit 14 | 15 | # Quantum model 16 | class QuantumModel(tf.keras.Model): 17 | def __init__(self): 18 | super(QuantumModel, self).__init__() 19 | self.qubits = cirq.GridQubit.rect(1, 2) 20 | self.circuit = create_quantum_circuit(self.qubits) 21 | self.readout = tfq.layers.PQC(self.circuit, cirq.Z(self.qubits[1])) 22 | 23 | def call(self, inputs): 24 | return self.readout(inputs) 25 | 26 | # Example usage 27 | if __name__ == "__main__": 28 | quantum_model = QuantumModel() 29 | input_data = tfq.convert_to_tensor([cirq.Circuit(cirq.X(cirq.GridQubit(0, 0)))]) 30 | output = quantum_model(input_data) 31 | print("Quantum Model Output:", output.numpy()) 32 | -------------------------------------------------------------------------------- /quantum_models/noisy_quantum_model.py: -------------------------------------------------------------------------------- 1 | # noisy_quantum_model.py 2 | 3 | import tensorflow as tf 4 | import tensorflow_quantum as tfq 5 | import cirq 6 | 7 | # Define a noisy quantum circuit 8 | def create_noisy_circuit(qubits): 9 | circuit = cirq.Circuit() 10 | circuit.append(cirq.H(qubits[0])) 11 | circuit.append(cirq.CNOT(qubits[0], qubits[1])) 12 | circuit.append(cirq.depolarize(0.1).on(qubits)) # Add noise 13 | return circuit 14 | 15 | # Quantum model with noise mitigation 16 | class NoisyQuantumModel(tf.keras.Model): 17 | def __init__(self): 18 | super(NoisyQuantumModel, self).__init__() 19 | self.qubits = cirq.GridQubit.rect(1, 2) 20 | self.circuit = create_noisy_circuit(self.qubits) 21 | self.readout = tfq.layers.PQC(self.circuit, cirq.Z(self.qubits[1])) 22 | 23 | def call(self, inputs): 24 | return self.readout(inputs) 25 | 26 | # Example usage 27 | if __name__ == "__main__": 28 | noisy_model = NoisyQuantumModel() 29 | input_data = tfq.convert_to_tensor([cirq.Circuit(cirq.X(cirq.GridQubit(0, 0)))]) 30 | output = noisy_model(input_data) 31 | print("Noisy Quantum Model Output:", output.numpy()) 32 | -------------------------------------------------------------------------------- /LICENSE.bitshares.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 | -------------------------------------------------------------------------------- /quantum_ai_innovations/quantum_nlp.py: -------------------------------------------------------------------------------- 1 | # quantum_nlp.py 2 | 3 | import tensorflow as tf 4 | import tensorflow_quantum as tfq 5 | import cirq 6 | 7 | def create_nlp_circuit(): 8 | # Define a simple quantum circuit for NLP 9 | qubits = cirq.GridQubit.rect(1, 2) 10 | circuit = cirq.Circuit( 11 | cirq.H(qubits[0]), # Hadamard gate 12 | cirq.CNOT(qubits[0], qubits[1]), # CNOT gate 13 | cirq.measure(*qubits, key='result') # Measure the qubits 14 | ) 15 | return circuit 16 | 17 | def quantum_nlp_model(input_text): 18 | # Create the quantum circuit 19 | circuit = create_nlp_circuit() 20 | 21 | # Create a quantum model 22 | model = tfq.layers.PQC(circuit, cirq.Z(cirq.GridQubit(0, 1))) 23 | 24 | # Convert input text to quantum circuits (dummy conversion for demonstration) 25 | input_circuits = tfq.convert_to_tensor([cirq.Circuit(cirq.X(cirq.GridQubit(0, 0)))]) 26 | 27 | # Get the output from the model 28 | output = model(input_circuits) 29 | return output.numpy() 30 | 31 | if __name__ == "__main__": 32 | text = "Quantum computing is the future." 33 | predictions = quantum_nlp_model(text) 34 | print("Quantum NLP Model Predictions:", predictions) 35 | -------------------------------------------------------------------------------- /quantum_ai_innovations/quantum_encryption.py: -------------------------------------------------------------------------------- 1 | # quantum_encryption.py 2 | 3 | import cirq 4 | import numpy as np 5 | 6 | class QuantumEncryption: 7 | def __init__(self): 8 | self.key = [] 9 | 10 | def generate_key(self, length): 11 | # Generate a random quantum key 12 | for _ in range(length): 13 | qubit = cirq.LineQubit(0) 14 | circuit = cirq.Circuit( 15 | cirq.H(qubit), # Create superposition 16 | cirq.measure(qubit, key='key') # Measure the qubit 17 | ) 18 | simulator = cirq.Simulator() 19 | result = simulator.run(circuit) 20 | self.key.append(result.measurements['key'][0][0]) 21 | 22 | def encrypt_message(self, message): 23 | # Encrypt the message using the generated key 24 | encrypted_message = ''.join( 25 | chr(ord(char) ^ self.key[i % len(self.key)]) for i, char in enumerate(message) 26 | ) 27 | return encrypted_message 28 | 29 | if __name__ == "__main__": 30 | encryption_system = QuantumEncryption() 31 | encryption_system.generate_key(10) 32 | message = "Hello, Quantum World!" 33 | encrypted = encryption_system.encrypt_message(message) 34 | print("Encrypted Message:", encrypted) 35 | -------------------------------------------------------------------------------- /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 | 36 | install( TARGETS 37 | convert_address 38 | 39 | RUNTIME DESTINATION bin 40 | LIBRARY DESTINATION lib 41 | ARCHIVE DESTINATION lib 42 | ) 43 | -------------------------------------------------------------------------------- /quantum_ai_innovations/quantum_image_classification.py: -------------------------------------------------------------------------------- 1 | # quantum_image_classification.py 2 | 3 | import tensorflow as tf 4 | import tensorflow_quantum as tfq 5 | import cirq 6 | import numpy as np 7 | 8 | def create_quantum_circuit(qubits): 9 | circuit = cirq.Circuit( 10 | cirq.H(qubits[0]), # Hadamard gate 11 | cirq.CNOT(qubits[0], qubits[1]), # CNOT gate 12 | cirq.measure(*qubits, key='result') # Measure the qubits 13 | ) 14 | return circuit 15 | 16 | def quantum_image_classifier(input_data): 17 | # Define qubits 18 | qubits = cirq.GridQubit.rect(1, 2) 19 | circuit = create_quantum_circuit(qubits) 20 | 21 | # Create a quantum model 22 | model = tfq.layers.PQC(circuit, cirq.Z(qubits[1])) 23 | 24 | # Convert input data to quantum circuits 25 | input_circuits = tfq.convert_to_tensor([cirq.Circuit(cirq.X(qubits[0])) for _ in input_data]) 26 | 27 | # Get the output from the model 28 | output = model(input_circuits) 29 | return output.numpy() 30 | 31 | if __name__ == "__main__": 32 | # Example input data (dummy data for demonstration) 33 | input_data = [0, 1, 0, 1] 34 | predictions = quantum_image_classifier(input_data) 35 | print("Quantum Image Classification Predictions:", predictions) 36 | -------------------------------------------------------------------------------- /quantum_ai_innovations/decentralized_ai_service.py: -------------------------------------------------------------------------------- 1 | # decentralized_ai_service.py 2 | 3 | import numpy as np 4 | from sklearn.linear_model import LinearRegression 5 | import json 6 | 7 | class DecentralizedAIService: 8 | def __init__(self): 9 | self.models = {} 10 | 11 | def train_model(self, model_id, features, targets): 12 | # Train a linear regression model 13 | X = np.array(features).reshape(-1, 1) 14 | y = np.array(targets) 15 | model = LinearRegression() 16 | model.fit(X, y) 17 | self.models[model_id] = model 18 | print(f"Model {model_id} trained.") 19 | 20 | def predict(self, model_id, new_data): 21 | # Make predictions using the trained model 22 | if model_id in self.models: 23 | model = self.models[model_id] 24 | prediction = model.predict(np.array(new_data).reshape(-1, 1)) 25 | return prediction.tolist() 26 | else: 27 | raise ValueError("Model not found.") 28 | 29 | if __name__ == "__main__": 30 | # Example usage 31 | service = DecentralizedAIService() 32 | service.train_model("model 1", [1, 2, 3, 4, 5], [2, 3, 5, 7, 11]) 33 | predictions = service.predict("model1", [6, 7, 8]) 34 | print("Predictions for new data:", predictions) 35 | -------------------------------------------------------------------------------- /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_incentive_history graphene_transaction_record graphene_chain fc graphene_db graphene_net 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 | INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/app" ) 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /quantum_ai_innovations/quantum_voting.py: -------------------------------------------------------------------------------- 1 | # quantum_voting.py 2 | 3 | import cirq 4 | import numpy as np 5 | 6 | class QuantumVoting: 7 | def __init__(self): 8 | self.votes = [] 9 | 10 | def cast_vote(self, vote): 11 | # Create a quantum circuit for voting 12 | qubits = cirq.LineQubit.range(2) 13 | circuit = cirq.Circuit( 14 | cirq.H(qubits[0]), # Superposition 15 | cirq.CNOT(qubits[0], qubits[1]), # Entanglement 16 | cirq.measure(*qubits, key='result') # Measure the qubits 17 | ) 18 | 19 | # Simulate the circuit 20 | simulator = cirq.Simulator() 21 | result = simulator.run(circuit, repetitions=1) 22 | self.votes.append((vote, result)) 23 | 24 | def tally_votes(self): 25 | # Tally the votes 26 | tally = {} 27 | for vote, _ in self.votes: 28 | if vote in tally: 29 | tally[vote] += 1 30 | else: 31 | tally[vote] = 1 32 | return tally 33 | 34 | if __name__ == "__main__": 35 | voting_system = QuantumVoting() 36 | voting_system.cast_vote("Candidate A") 37 | voting_system.cast_vote("Candidate B") 38 | voting_system.cast_vote("Candidate A") 39 | 40 | results = voting_system.tally_votes() 41 | print("Voting Results:", results) 42 | -------------------------------------------------------------------------------- /src/hyper_core/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "super-pi-ecosystem" 3 | version = "0.1.0" 4 | edition = "2025" 5 | authors = ["KOSASIH"] 6 | description = "Hyper-Tech Autonomous Super App for Pi Network Mainnet Opening and Decentralization" 7 | license = "MIT OR Apache-2.0" 8 | keywords = ["pi-network", "blockchain", "soroban", "decentralization"] 9 | categories = ["cryptography::cryptocurrencies", "smart-contracts"] 10 | 11 | [lib] 12 | crate-type = ["cdylib"] 13 | doctest = false 14 | 15 | [dependencies] 16 | soroban-sdk = "0.9" 17 | tokio = { version = "1.0", features = ["full"] } 18 | rayon = "1.5" 19 | serde = { version = "1.0", features = ["derive"] } 20 | serde_json = "1.0" 21 | sha2 = "0.10" 22 | regex = "1.5" 23 | chrono = { version = "0.4", features = ["serde"] } 24 | uuid = { version = "1.0", features = ["v4"] } 25 | hex = "0.4" 26 | 27 | [dev-dependencies] 28 | soroban-sdk = { version = "0.9", features = ["testutils"] } 29 | 30 | [profile.release] 31 | opt-level = 3 32 | debug = false 33 | rpath = false 34 | lto = true 35 | debug-assertions = false 36 | codegen-units = 1 37 | panic = "abort" 38 | incremental = false 39 | overflow-checks = true 40 | 41 | [profile.dev] 42 | opt-level = 0 43 | debug = true 44 | rpath = false 45 | lto = false 46 | debug-assertions = true 47 | codegen-units = 16 48 | panic = "unwind" 49 | incremental = true 50 | overflow-checks = true 51 | -------------------------------------------------------------------------------- /quantum_models/hybrid_quantum_classical_model.py: -------------------------------------------------------------------------------- 1 | # hybrid_quantum_classical_model.py 2 | 3 | import tensorflow as tf 4 | import tensorflow_quantum as tfq 5 | import cirq 6 | 7 | # Define a simple quantum circuit 8 | def create_quantum_circuit(qubits): 9 | circuit = cirq.Circuit() 10 | circuit.append(cirq.H(qubits[0])) # Hadamard gate 11 | circuit.append(cirq.CNOT(qubits[0], qubits[1])) # CNOT gate 12 | return circuit 13 | 14 | # Define a hybrid model 15 | class HybridQuantumClassicalModel(tf.keras.Model): 16 | def __init__(self): 17 | super(HybridQuantumClassicalModel, self).__init__() 18 | self.qubits = cirq.GridQubit.rect(1, 2) 19 | self.circuit = create_quantum_circuit(self.qubits) 20 | self.quantum_layer = tfq.layers.PQC(self.circuit, cirq.Z(self.qubits[1])) 21 | self.classical_layer = tf.keras.layers.Dense(10, activation='relu') 22 | 23 | def call(self, inputs): 24 | quantum_output = self.quantum_layer(inputs) 25 | classical_output = self.classical_layer(quantum_output) 26 | return classical_output 27 | 28 | # Example usage 29 | if __name__ == "__main__": 30 | hybrid_model = HybridQuantumClassicalModel() 31 | input_data = tfq.convert_to_tensor([cirq.Circuit(cirq.X(cirq.GridQubit(0, 0)))]) 32 | output = hybrid_model(input_data) 33 | print("Hybrid Model Output:", output.numpy()) 34 | -------------------------------------------------------------------------------- /quantum_ai_innovations/quantum_financial_forecasting.py: -------------------------------------------------------------------------------- 1 | # quantum_financial_forecasting.py 2 | 3 | import numpy as np 4 | import cirq 5 | 6 | class QuantumFinancialForecasting: 7 | def __init__(self, historical_data): 8 | self.historical_data = historical_data 9 | 10 | def create_forecasting_circuit(self): 11 | # Create a quantum circuit for forecasting 12 | qubits = cirq.LineQubit.range(2) 13 | circuit = cirq.Circuit( 14 | cirq.H(qubits[0]), # Hadamard gate 15 | cirq.CNOT(qubits[0], qubits[1]), # CNOT gate 16 | cirq.measure(*qubits, key='result') # Measure the qubits 17 | ) 18 | return circuit 19 | 20 | def forecast(self): 21 | # Generate forecasts based on historical data 22 | circuit = self.create_forecasting_circuit() 23 | simulator = cirq.Simulator() 24 | result = simulator.run(circuit, repetitions=100) 25 | 26 | # Analyze results to provide forecasts 27 | forecast = np.array(result.histogram(key='result')) 28 | return forecast 29 | 30 | if __name__ == "__main__": 31 | historical_data = [100, 102, 101, 105, 107] # Example historical stock prices 32 | forecasting_system = QuantumFinancialForecasting(historical_data) 33 | forecast = forecasting_system.forecast() 34 | print("Forecasted Stock Prices:", forecast) 35 | -------------------------------------------------------------------------------- /src/hyper_core/rust/tests/test_super_pi_ecosystem.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod test_super_pi_ecosystem { 3 | use soroban_sdk::testutils::Env; 4 | use crate::SuperPiEcosystem; 5 | use soroban_sdk::Symbol; 6 | 7 | #[test] 8 | fn test_init_super_pi_ecosystem() { 9 | let env = Env::default(); 10 | let ecosystem = SuperPiEcosystem::init(env); 11 | // Assert initialization (mock, as init returns struct) 12 | assert!(true, "Super Pi Ecosystem initialized successfully"); 13 | } 14 | 15 | #[test] 16 | fn test_run_full_super_pi_ecosystem() { 17 | let env = Env::default(); 18 | let ecosystem = SuperPiEcosystem::init(env.clone()); 19 | SuperPiEcosystem::run_full_super_pi_ecosystem(env); 20 | // Assert run completes without panic (mock) 21 | assert!(true, "Full Super Pi Ecosystem run successfully"); 22 | } 23 | 24 | #[test] 25 | fn test_get_ecosystem_status() { 26 | let env = Env::default(); 27 | let ecosystem = SuperPiEcosystem::init(env.clone()); 28 | let status = SuperPiEcosystem::get_ecosystem_status(env); 29 | // Assert status is a valid Symbol 30 | assert!(status == Symbol::new(&Env::default(), "Super Pi Ecosystem: Perfection Achieved, Evolution Complete, Intelligence Super-Activated, Supremacy Eternal"), "Status matches expected"); 31 | } 32 | } 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 | -------------------------------------------------------------------------------- /user_interface/api_server.py: -------------------------------------------------------------------------------- 1 | # api_server.py 2 | 3 | from flask import Flask, request, jsonify 4 | from proposal_management import ProposalManagement 5 | 6 | app = Flask(__name__) 7 | proposal_management = ProposalManagement() 8 | 9 | @app.route('/proposals', methods=['POST']) 10 | def create_proposal(): 11 | data = request.json 12 | description = data.get('description') 13 | proposal_management.create_proposal(description) 14 | return jsonify({"message": "Proposal created successfully."}), 201 15 | 16 | @app.route('/proposals//vote', methods=['POST']) 17 | def vote_on_proposal(proposal_id): 18 | data = request.json 19 | voter = data.get('voter') 20 | amount = data.get('amount') 21 | proposal_management.vote(proposal_id, voter, amount) 22 | return jsonify({"message": "Vote recorded successfully."}), 200 23 | 24 | @app.route('/proposals//results', methods=['GET']) 25 | def get_proposal_results(proposal_id): 26 | results = proposal_management.get_proposal_results(proposal_id) 27 | return jsonify(results), 200 28 | 29 | @app.route('/proposals//complete', methods=['POST']) 30 | def complete_proposal(proposal_id): 31 | proposal_management.complete_proposal(proposal_id) 32 | return jsonify({"message": "Proposal completed successfully."}), 200 33 | 34 | if __name__ == '__main__': 35 | app.run(debug=True) 36 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /economic_stabilization/PiCoinStabilization.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | contract PiCoinStabilization { 5 | string public name = "Pi Coin"; 6 | string public symbol = "PI"; 7 | uint8 public decimals = 18; 8 | uint256 public totalSupply = 100000000000 * 10 ** uint256(decimals); // Fixed total supply 9 | uint256 public pegValue = 314159 * 10 ** uint256(decimals); // Pegged value in wei 10 | mapping(address => uint256) public balanceOf; 11 | 12 | event Transfer(address indexed from, address indexed to, uint256 value); 13 | event PegAdjusted(uint256 newPegValue); 14 | 15 | constructor() { 16 | balanceOf[msg.sender] = totalSupply; // Assign all tokens to the contract creator 17 | } 18 | 19 | function transfer(address to, uint256 value) public returns (bool success) { 20 | require(balanceOf[msg.sender] >= value, "Insufficient balance"); 21 | balanceOf[msg.sender] -= value; 22 | balanceOf[to] += value; 23 | emit Transfer(msg.sender, to, value); 24 | return true; 25 | } 26 | 27 | function adjustPeg(uint256 newPegValue) public { 28 | // Only the owner can adjust the peg 29 | pegValue = newPegValue; 30 | emit PegAdjusted(newPegValue); 31 | } 32 | 33 | function getPegValue() public view returns (uint256) { 34 | return pegValue; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /quantum_ai_innovations/quantum_recommendation.py: -------------------------------------------------------------------------------- 1 | # quantum_recommendation.py 2 | 3 | import numpy as np 4 | import cirq 5 | 6 | class QuantumRecommendation: 7 | def __init__(self, user_preferences): 8 | self.user_preferences = user_preferences 9 | 10 | def create_quantum_circuit(self): 11 | # Create a quantum circuit for recommendations 12 | qubits = cirq.LineQubit.range(len(self.user_preferences)) 13 | circuit = cirq.Circuit( 14 | cirq.H(qubits), # Apply Hadamard to all qubits 15 | cirq.measure(*qubits, key='result') # Measure the qubits 16 | ) 17 | return circuit 18 | 19 | def recommend(self): 20 | # Generate recommendations based on user preferences 21 | circuit = self.create_quantum_circuit() 22 | simulator = cirq.Simulator() 23 | result = simulator.run(circuit, repetitions=100) 24 | 25 | # Analyze results to provide recommendations 26 | recommendations = np.array(result.histogram(key='result')) 27 | recommended_items = np.argsort(recommendations)[-3:] # Top 3 recommendations 28 | return recommended_items 29 | 30 | if __name__ == "__main__": 31 | user_preferences = [1, 0, 1, 0, 1] # Example user preferences 32 | recommendation_system = QuantumRecommendation(user_preferences) 33 | recommendations = recommendation_system.recommend() 34 | print("Recommended Items:", recommendations) 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /user_interface/web_app.py: -------------------------------------------------------------------------------- 1 | # web_app.py 2 | 3 | from flask import Flask, render_template, request, redirect, url_for 4 | import requests 5 | 6 | app = Flask(__name__) 7 | API_URL = "http://127.0.0.1:5000" # URL of the API server 8 | 9 | @app.route('/') 10 | def index(): 11 | return render_template('index.html') 12 | 13 | @app.route('/create_proposal', methods=['POST']) 14 | def create_proposal(): 15 | description = request.form['description'] 16 | response = requests.post(f"{API_URL}/proposals", json={"description": description}) 17 | return redirect(url_for('index')) 18 | 19 | @app.route('/vote', methods=['POST']) 20 | def vote(): 21 | proposal_id = request.form['proposal_id'] 22 | voter = request.form['voter'] 23 | amount = request.form['amount'] 24 | response = requests.post(f"{API_URL}/proposals/{proposal_id}/vote", json={"voter": voter, "amount": amount}) 25 | return redirect(url_for('index')) 26 | 27 | @app.route('/results/') 28 | def results(proposal_id): 29 | response = requests.get(f"{API_URL}/proposals/{proposal_id}/results") 30 | results = response.json() 31 | return render_template('results.html', results=results) 32 | 33 | @app.route('/complete/', methods=['POST']) 34 | def complete(proposal_id): 35 | response = requests.post(f"{API_URL}/proposals/{proposal_id}/complete") 36 | return redirect(url_for('index')) 37 | 38 | if __name__ == '__main__': 39 | app.run(port=5001, debug=True) 40 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReadMe 2 | 3 | Pi(π) is a new generation blockchain technology. 4 | 5 | Pi adopts a new consensus mechanism called IPoS(Improved Proof of Stake), which helps it reach a balance between fairness and efficiency. Pi introduces a new incentive algorithm to attract users to use and to construct the Pi network. 6 | 7 | Pi derives from BitShares ([https://github.com/bitshares/bitshares-core](https://github.com/bitshares/bitshares-core)). 8 | 9 | ## Repository Contents 10 | 11 | ### libraries 12 | 13 | This directory include all kinds of libraries used by different apps. 14 | 15 | ### programs 16 | 17 | This directory include main files for different apps. 18 | 19 | `pi_node` is the most important app. This is the core server node which produce blockchains and process all kinds of RPCs. 20 | 21 | `cli_wallet` is a reference wallet implement based on Pi RPC protocol. 22 | 23 | ### test 24 | 25 | Unit tests and benchmarks. 26 | 27 | ### docs 28 | 29 | Documentation of pi development. 30 | 31 | 32 | ## How to Build 33 | 34 | Pi uses cmake toolchain to build. 35 | 36 | ```bash 37 | git clone https://github.com/pidiscovery/pi.git 38 | cd pi 39 | git submodule update --init --recursive 40 | mkdir build 41 | cd build 42 | cmake .. 43 | make 44 | ``` 45 | 46 | You'll find a built binary program named `pi_node` at path `pi/build/pi_node/`. 47 | 48 | ## License 49 | 50 | Pi is open source and permissively licensed under the MIT license. See the LICENSE.md file for more details. 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /libraries/chain/protocol/incentive.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 incentive_operation::validate() const { 29 | // FC_ASSERT( !"virtual operation" ); 30 | } 31 | 32 | } } // graphene::chain 33 | -------------------------------------------------------------------------------- /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/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 | install( FILES ${HEADERS} DESTINATION "include/graphene/utilities" ) 41 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /tests/intense/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 | 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libraries/chain/protocol/deflation.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 deflation_operation::validate() const { 29 | } 30 | 31 | void account_deflation_operation::validate() const { 32 | } 33 | 34 | void order_deflation_operation::validate() const { 35 | } 36 | 37 | } } // graphene::chain 38 | -------------------------------------------------------------------------------- /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/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 | #include "db_notify.cpp" 36 | #include "db_incentive.cpp" 37 | #include "db_deflation.cpp" 38 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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 graphene_wallet ${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_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_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/incentive_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 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace graphene { namespace chain { 32 | class incentive_evaluator : public evaluator { 33 | public: 34 | typedef incentive_operation operation_type; 35 | 36 | void_result do_evaluate( const incentive_operation& o ); 37 | void_result do_apply( const incentive_operation& o ) ; 38 | 39 | // virtual void pay_fee() override; 40 | 41 | }; 42 | }} // graphene::chain 43 | 44 | 45 | -------------------------------------------------------------------------------- /economic_stabilization/dynamic_pricing_model.py: -------------------------------------------------------------------------------- 1 | # dynamic_pricing_model.py 2 | 3 | import logging 4 | 5 | # Configure logging 6 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') 7 | 8 | class DynamicPricingModel: 9 | def __init__(self, base_price): 10 | self.base_price = base_price # Base price of Pi Coin 11 | self.current_price = base_price # Initialize current price 12 | 13 | def calculate_price(self, demand, supply, volatility=1.0): 14 | """Calculate the dynamic price based on demand and supply.""" 15 | if supply <= 0: 16 | logging.error("Supply must be greater than zero to calculate price.") 17 | return None 18 | 19 | # Example dynamic pricing formula 20 | price = self.base_price * (demand / supply) * volatility 21 | 22 | # Ensure price does not fall below a minimum threshold 23 | self.current_price = max(price, self.base_price * 0.5) # Minimum price is 50% of base price 24 | logging.info(f"Calculated price: {self.current_price:.2f} Pi Coin (Demand: {demand}, Supply: {supply}, Volatility: {volatility})") 25 | return self.current_price 26 | 27 | def simulate_price_changes(self, demand_changes, supply_changes): 28 | """Simulate price changes over a series of demand and supply changes.""" 29 | for demand, supply in zip(demand_changes, supply_changes): 30 | self.calculate_price(demand, supply) 31 | print(f"New Price: {self.current_price:.2f} Pi Coin") 32 | 33 | if __name__ == "__main__": 34 | # Example usage 35 | pricing_model = DynamicPricingModel(base_price=1.0) 36 | 37 | # Simulate market conditions 38 | demand_changes = [1200, 800, 1000, 1500] # Example demand values 39 | supply_changes = [1000, 1000, 800, 1200] # Example supply values 40 | 41 | # Simulate price changes 42 | pricing_model.simulate_price_changes(demand_changes, supply_changes) 43 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /governance/governance_token.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | import "@openzeppelin/contracts/access/Ownable.sol"; 6 | 7 | contract GovernanceToken is ERC20, Ownable { 8 | // Mapping from proposal ID to votes 9 | mapping(uint256 => mapping(address => uint256)) public votes; 10 | mapping(uint256 => uint256) public totalVotes; 11 | 12 | // Event for proposal voting 13 | event Voted(address indexed voter, uint256 proposalId, uint256 amount); 14 | 15 | constructor(uint256 initialSupply) ERC20("Governance Token", "GOV") { 16 | _mint(msg.sender, initialSupply * (10 ** decimals())); 17 | } 18 | 19 | // Function to vote on a proposal 20 | function vote(uint256 proposalId, uint256 amount) external { 21 | require(amount > 0, "Amount must be greater than 0"); 22 | require(balanceOf(msg.sender) >= amount, "Insufficient token balance"); 23 | 24 | // Transfer tokens from the voter to the contract 25 | _transfer(msg.sender, address(this), amount); 26 | 27 | // Update votes 28 | votes[proposalId][msg.sender] += amount; 29 | totalVotes[proposalId] += amount; 30 | 31 | emit Voted(msg.sender, proposalId, amount); 32 | } 33 | 34 | // Function to withdraw tokens after voting 35 | function withdrawVotes(uint256 proposalId) external { 36 | uint256 amount = votes[proposalId][msg.sender]; 37 | require(amount > 0, "No votes to withdraw"); 38 | 39 | // Reset the votes 40 | votes[proposalId][msg.sender] = 0; 41 | totalVotes[proposalId] -= amount; 42 | 43 | // Transfer tokens back to the voter 44 | _transfer(address(this), msg.sender, amount); 45 | } 46 | 47 | // Function to check the voting power of an address for a specific proposal 48 | function getVotingPower(uint256 proposalId, address voter) external view returns (uint256) { 49 | return votes[proposalId][voter]; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /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 | #include 31 | 32 | namespace graphene { namespace app { 33 | 34 | void operation_get_impacted_accounts( 35 | const graphene::chain::operation& op, 36 | fc::flat_set& result, 37 | graphene::chain::database *db = nullptr 38 | ); 39 | 40 | void transaction_get_impacted_accounts( 41 | const graphene::chain::transaction& tx, 42 | fc::flat_set& result, 43 | graphene::chain::database *db = nullptr 44 | ); 45 | 46 | } } // graphene::app 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/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 | -------------------------------------------------------------------------------- /governance/voting_system.py: -------------------------------------------------------------------------------- 1 | # voting_system.py 2 | 3 | class VotingSystem: 4 | def __init__(self): 5 | self.proposals = {} 6 | self.total_proposals = 0 7 | 8 | def create_proposal(self, description): 9 | self.total_proposals += 1 10 | self.proposals[self.total_proposals] = { 11 | 'description': description, 12 | 'votes': {}, 13 | 'total_votes': 0 14 | } 15 | print(f"Proposal {self.total_proposals} created: {description}") 16 | 17 | def vote(self, proposal_id, voter, amount): 18 | if proposal_id not in self.proposals: 19 | print("Proposal does not exist.") 20 | return 21 | 22 | if voter in self.proposals[proposal_id]['votes']: 23 | print(f"{voter} has already voted on this proposal.") 24 | return 25 | 26 | self.proposals[proposal_id]['votes'][voter] = amount 27 | self.proposals[proposal_id]['total_votes'] += amount 28 | print(f"{voter} voted {amount} on Proposal {proposal_id}.") 29 | 30 | def get_results(self, proposal_id): 31 | if proposal_id not in self.proposals: 32 | print("Proposal does not exist.") 33 | return 34 | 35 | proposal = self.proposals[proposal_id] 36 | print(f"Results for Proposal {proposal_id}:") 37 | print(f"Description: {proposal['description']}") 38 | print(f"Total Votes: {proposal['total_votes']}") 39 | for voter, amount in proposal['votes'].items(): 40 | print(f" {voter}: {amount}") 41 | 42 | if __name__ == "__main__": 43 | voting_system = VotingSystem() 44 | 45 | # Example usage 46 | voting_system.create_proposal("Increase the reward rate for staking.") 47 | voting_system.create_proposal("Implement a new governance model.") 48 | 49 | voting_system.vote(1, "Alice", 100) 50 | voting_system.vote(1, "Bob", 200) 51 | voting_system.vote(2, "Alice", 150) 52 | 53 | voting_system.get_results(1) 54 | voting_system.get_results(2) 55 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /decentralized_finance/yield_farming.py: -------------------------------------------------------------------------------- 1 | # yield_farming.py 2 | 3 | class YieldFarming: 4 | def __init__(self): 5 | self.stakers = {} 6 | self.total_staked = 0 7 | self.reward_rate = 0.1 # 10% reward rate per cycle 8 | 9 | def stake(self, user, amount): 10 | if user not in self.stakers: 11 | self.stakers[user] = {'staked': 0, 'rewards': 0} 12 | 13 | self.stakers[user]['staked'] += amount 14 | self.total_staked += amount 15 | print(f"{user} has staked {amount}. Total staked: {self.total_staked}") 16 | 17 | def calculate_rewards(self, user): 18 | if user not in self.stakers: 19 | print("User not found.") 20 | return 0 21 | 22 | staked_amount = self.stakers[user]['staked'] 23 | rewards = staked_amount * self.reward_rate 24 | self.stakers[user]['rewards'] += rewards 25 | print(f"{user} earned {rewards} in rewards.") 26 | return rewards 27 | 28 | def withdraw(self, user): 29 | if user not in self.stakers or self.stakers[user]['staked'] <= 0: 30 | print("No staked amount to withdraw.") 31 | return 32 | 33 | staked_amount = self.stakers[user]['staked'] 34 | rewards = self.stakers[user]['rewards'] 35 | 36 | # Reset user's staked amount and rewards 37 | self.stakers[user]['staked'] = 0 38 | self.stakers[user]['rewards'] = 0 39 | self.total_staked -= staked_amount 40 | 41 | print(f"{user} withdrew {staked_amount} and earned {rewards} in rewards.") 42 | return staked_amount + rewards 43 | 44 | if __name__ == "__main__": 45 | farm = YieldFarming() 46 | 47 | # Example usage 48 | farm.stake("Alice", 1000) 49 | farm.stake("Bob", 2000) 50 | 51 | # Simulate a reward cycle 52 | farm.calculate_rewards("Alice") 53 | farm.calculate_rewards("Bob") 54 | 55 | # Users withdraw their stakes and rewards 56 | farm.withdraw("Alice") 57 | farm.withdraw("Bob") 58 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /economic_stabilization/risk_assessment_tool.py: -------------------------------------------------------------------------------- 1 | # risk_assessment_tool.py 2 | 3 | import logging 4 | 5 | # Configure logging 6 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') 7 | 8 | class RiskAssessmentTool: 9 | def __init__(self): 10 | self.risk_score = 0 11 | 12 | def assess_risk(self, inflation_rate, unemployment_rate, gdp_growth): 13 | """Assess risk based on economic indicators.""" 14 | # Simple risk assessment formula 15 | self.risk_score = (inflation_rate * 0.4) + (unemployment_rate * 0.4) - (gdp_growth * 0.2) 16 | 17 | # Normalize risk score to a scale of 0 to 100 18 | self.risk_score = max(0, min(100, self.risk_score)) 19 | logging.info(f"Risk assessed: {self.risk_score:.2f} (Inflation: {inflation_rate}, Unemployment: {unemployment_rate}, GDP Growth: {gdp_growth})") 20 | return self.risk_score 21 | 22 | def provide_recommendations(self): 23 | """Provide recommendations based on the assessed risk score.""" 24 | if self.risk_score < 30: 25 | return "Risk is low. Continue current economic policies." 26 | elif 30 <= self.risk_score < 70: 27 | return "Moderate risk detected. Consider implementing measures to stimulate growth." 28 | else: 29 | return "High risk detected. Urgent measures needed to stabilize the economy." 30 | 31 | if __name__ == "__main__": 32 | # Example usage 33 | risk_tool = RiskAssessmentTool() 34 | 35 | # Simulated economic indicators 36 | inflation_rate = 5.0 # Example inflation rate in percentage 37 | unemployment_rate = 7.0 # Example unemployment rate in percentage 38 | gdp_growth = 2.0 # Example GDP growth rate in percentage 39 | 40 | # Assess risk 41 | risk_score = risk_tool.assess_risk(inflation_rate, unemployment_rate, gdp_growth) 42 | 43 | # Provide recommendations 44 | recommendations = risk_tool.provide_recommendations() 45 | print(f"Risk Score: {risk_score:.2f}") 46 | print(f"Recommendations: {recommendations}") 47 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /src/hyper_core/rust/src/ahi_ai_core.rs: -------------------------------------------------------------------------------- 1 | // src/hyper_core/rust/src/ahi_ai_core.rs 2 | // Autonomous Hyper Intelligence AI Core - Soroban Smart Contract 3 | // Monitors compliance and halts Stellar support autonomously. 4 | // Dependencies: soroban-sdk = "0.9" in Cargo.toml 5 | 6 | use soroban_sdk::{contract, contractimpl, Env, Symbol, Vec, log, panic_with_error}; 7 | 8 | #[contract] 9 | pub struct AhiAiCore; 10 | 11 | #[derive(Clone)] 12 | pub struct HyperNeuralNet { 13 | weights: Vec, // Simplified for on-chain 14 | } 15 | 16 | impl HyperNeuralNet { 17 | pub fn new(env: &Env) -> Self { 18 | Self { 19 | weights: Vec::from_array(env, [314, 159, 265, 359]), // Pi-inspired 20 | } 21 | } 22 | 23 | pub fn predict_volatility(&self, input: &Symbol) -> i32 { 24 | // Simplified prediction 25 | let score = input.to_string().len() as i32 % 10; 26 | score 27 | } 28 | } 29 | 30 | #[contractimpl] 31 | impl AhiAiCore { 32 | /// Initialize the AI Core 33 | pub fn init(env: Env) -> AhiAiCore { 34 | log!(&env, "AHI AI Core Initialized"); 35 | AhiAiCore 36 | } 37 | 38 | /// Filter input/output 39 | pub fn filter_io(env: Env, data: Symbol) -> Result { 40 | let ai = HyperNeuralNet::new(&env); 41 | let score = ai.predict_volatility(&data); 42 | if score > 5 { 43 | Err(Symbol::new(&env, "volatile_rejected")) 44 | } else { 45 | Ok(Symbol::new(&env, "filtered_stable")) 46 | } 47 | } 48 | 49 | /// Enforce compliance and halt Stellar if needed 50 | pub fn enforce_compliance(env: Env) -> Symbol { 51 | // Simulate API check (in real: integrate Pi Network oracle) 52 | let compliant = true; // Placeholder 53 | if !compliant { 54 | log!(&env, "Halting Stellar support due to non-compliance"); 55 | panic_with_error!(&env, Symbol::new(&env, "stellar_halted")); 56 | } 57 | Symbol::new(&env, "compliant") 58 | } 59 | 60 | /// Get status 61 | pub fn get_status(env: Env) -> (bool, bool) { 62 | (true, false) // (compliant, stellar_halted) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /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/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_fee_config_operation::validate()const 29 | { 30 | FC_ASSERT( fee.amount >= 0 ); 31 | } 32 | 33 | void limit_order_create_operation::validate()const 34 | { 35 | FC_ASSERT( amount_to_sell.asset_id != min_to_receive.asset_id ); 36 | FC_ASSERT( fee.amount >= 0 ); 37 | FC_ASSERT( amount_to_sell.amount > 0 ); 38 | FC_ASSERT( min_to_receive.amount > 0 ); 39 | } 40 | 41 | void limit_order_cancel_operation::validate()const 42 | { 43 | FC_ASSERT( fee.amount >= 0 ); 44 | } 45 | 46 | void call_order_update_operation::validate()const 47 | { try { 48 | FC_ASSERT( fee.amount >= 0 ); 49 | FC_ASSERT( delta_collateral.asset_id != delta_debt.asset_id ); 50 | FC_ASSERT( delta_collateral.amount != 0 || delta_debt.amount != 0 ); 51 | } FC_CAPTURE_AND_RETHROW((*this)) } 52 | 53 | } } // graphene::chain 54 | -------------------------------------------------------------------------------- /economic_stabilization/dynamic_supply_adjustment.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | class PiCoinMarket: 4 | def __init__(self, peg_value=314159): 5 | self.supply = 100000000000 # Fixed supply of 100 billion Pi Coins 6 | self.peg_value = peg_value 7 | self.current_price = peg_value 8 | self.price_history = [] 9 | 10 | def simulate_market(self): 11 | # Simulate market fluctuations 12 | price_change = random.uniform(-1000, 1000) # Simulate price changes 13 | self.current_price += price_change 14 | self.price_history.append(self.current_price) 15 | 16 | print(f"Current Price: {self.current_price:.2f} (Change: {price_change:.2f})") 17 | 18 | # Adjust supply based on price 19 | if self.current_price < self.peg_value * 0.95: # If price drops below 95% of peg 20 | self.increase_supply() 21 | elif self.current_price > self.peg_value * 1.05: # If price rises above 105% of peg 22 | self.decrease_supply() 23 | 24 | def increase_supply(self): 25 | adjustment = self.supply * 0.01 * (self.peg_value - self.current_price) / self.peg_value # Adjust based on deviation 26 | self.supply += adjustment 27 | print(f"Increasing supply by {adjustment:.2f}. New supply: {self.supply:.2f}") 28 | 29 | def decrease_supply(self): 30 | adjustment = self.supply * 0.01 * (self.current_price - self.peg_value) / self.peg_value # Adjust based on deviation 31 | self.supply -= adjustment 32 | print(f"Decreasing supply by {adjustment:.2f}. New supply: {self.supply:.2f}") 33 | 34 | def get_market_summary(self): 35 | print(f"Market Summary:") 36 | print(f" Current Price: {self.current_price:.2f}") 37 | print(f" Total Supply: {self.supply:.2f}") 38 | print(f" Peg Value: {self.peg_value:.2f}") 39 | print(f" Price History: {self.price_history}") 40 | 41 | if __name__ == "__main__": 42 | peg_value = float(input("Enter peg value: ")) 43 | 44 | market = PiCoinMarket(peg_value=peg_value) 45 | 46 | for _ in range(10): # Simulate 10 market fluctuations 47 | market.simulate_market() 48 | 49 | market.get_market_summary() 50 | -------------------------------------------------------------------------------- /quantum_ai_innovations/dynamic_supply_adjustment.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | class PiCoinMarket: 4 | def __init__(self, peg_value=314159): 5 | self.supply = 100000000000 # Fixed supply of 100 billion Pi Coins 6 | self.peg_value = peg_value 7 | self.current_price = peg_value 8 | self.price_history = [] 9 | 10 | def simulate_market(self): 11 | # Simulate market fluctuations 12 | price_change = random.uniform(-1000, 1000) # Simulate price changes 13 | self.current_price += price_change 14 | self.price_history.append(self.current_price) 15 | 16 | print(f"Current Price: {self.current_price:.2f} (Change: {price_change:.2f})") 17 | 18 | # Adjust supply based on price 19 | if self.current_price < self.peg_value * 0.95: # If price drops below 95% of peg 20 | self.increase_supply() 21 | elif self.current_price > self.peg_value * 1.05: # If price rises above 105% of peg 22 | self.decrease_supply() 23 | 24 | def increase_supply(self): 25 | adjustment = self.supply * 0.01 * (self.peg_value - self.current_price) / self.peg_value # Adjust based on deviation 26 | self.supply += adjustment 27 | print(f"Increasing supply by {adjustment:.2f}. New supply: {self.supply:.2f}") 28 | 29 | def decrease_supply(self): 30 | adjustment = self.supply * 0.01 * (self.current_price - self.peg_value) / self.peg_value # Adjust based on deviation 31 | self.supply -= adjustment 32 | print(f"Decreasing supply by {adjustment:.2f}. New supply: {self.supply:.2f}") 33 | 34 | def get_market_summary(self): 35 | print(f"Market Summary:") 36 | print(f" Current Price: {self.current_price:.2f}") 37 | print(f" Total Supply: {self.supply:.2f}") 38 | print(f" Peg Value: {self.peg_value:.2f}") 39 | print(f" Price History: {self.price_history}") 40 | 41 | if __name__ == "__main__": 42 | peg_value = float(input("Enter peg value: ")) 43 | 44 | market = PiCoinMarket(peg_value=peg_value) 45 | 46 | for _ in range(10): # Simulate 10 market fluctuations 47 | market.simulate_market() 48 | 49 | market.get_market_summary() 50 | -------------------------------------------------------------------------------- /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/protocol/construction_capital.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 | 28 | namespace graphene { namespace chain { 29 | 30 | void construction_capital_create_operation::validate() const { 31 | // FC_ASSERT( fee.amount >= 0 ); 32 | // FC_ASSERT( amount >= GRAPHENE_DEFAULT_MIN_CONSTRUCTION_CAPITAL_AMOUNT ); 33 | // FC_ASSERT( period >= GRAPHENE_DEFAULT_MIN_CONSTRUCTION_CAPITAL_PERIOD 34 | // && period <= GRAPHENE_DEFAULT_MAX_CONSTRUCTION_CAPITAL_PERIOD); 35 | // FC_ASSERT( total_periods >= GRAPHENE_DEFAULT_MIN_CONSTRUCTION_CAPITAL_PERIOD_LEN 36 | // && total_periods <= GRAPHENE_DEFAULT_MAX_CONSTRUCTION_CAPITAL_PERIOD_LEN ); 37 | } 38 | 39 | void construction_capital_vote_operation::validate() const { 40 | } 41 | 42 | void construction_capital_rate_vote_operation::validate() const { 43 | } 44 | 45 | }} // graphene::chain 46 | -------------------------------------------------------------------------------- /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/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 | void committee_member_issue_construction_capital_operation::validate() const 48 | { 49 | FC_ASSERT( fee.amount >= 0 ); 50 | } 51 | 52 | void committee_member_grant_instant_payback_operation::validate() const 53 | { 54 | FC_ASSERT( fee.amount >= 0 ); 55 | } 56 | 57 | } } // graphene::chain 58 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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 | --------------------------------------------------------------------------------