├── .gitignore ├── LICENSE ├── README.md ├── change-checker.sh ├── compile.sh ├── configs ├── aeon.json ├── dashcoin.json ├── monero-block-explorer.json └── wownero.json ├── extensions ├── aeon.json ├── aeon │ └── files │ │ ├── blocks.dat │ │ └── tests │ │ ├── hash │ │ └── tests-slow-with-multiplier.txt │ │ └── performance_tests │ │ └── cn_slow_hash_with_multiplier_test.h ├── blockchain-explorer.json ├── bytecoin-clone.json ├── core │ ├── monero.json │ └── monero │ │ └── files │ │ ├── blocks.dat │ │ ├── checkpoints.dat │ │ └── testnet_blocks.dat ├── donations.json ├── enable-cors.json └── versionized-parameters.json ├── generator.sh ├── install_dependencies.sh ├── lib ├── environment_variables.py └── file-modification.py └── vars.cfg /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /generated_files 3 | config.json 4 | /extensions/core/cryptonotecoin.py 5 | /test/core/cryptonotecoin-test.sh -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # monero-generator 2 | Generate Monero based coins with 1 command 3 | -------------------------------------------------------------------------------- /change-checker.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | # Starts deployment if change is detected 4 | # Cron cycles this script 5 | 6 | # Exit immediately if an error occurs, or if an undeclared variable is used 7 | set -o errexit 8 | set -o nounset 9 | 10 | [ "$OSTYPE" != "win"* ] || die "Install Cygwin to use on Windows" 11 | 12 | # Set directory vars 13 | . "vars.cfg" 14 | GENERATOR_FILE_PATH="${PROJECT_DIR}/generator.sh" 15 | 16 | # Cron cycle period in minutes 17 | CRON_CYCLE='30' 18 | START_DEPLOY="" 19 | 20 | # Pull request 21 | echo "git pull base coin" 22 | cd $BASE_COIN_PATH 23 | git reset --hard origin/master 24 | git pull 25 | cd $PROJECT_DIR 26 | 27 | # Check if file is changed in _posts folder in the cron cycle 28 | CURRENT_TIMESTAMP="$( date +%s )" 29 | if [[ "$OSTYPE" == "darwin"* ]]; then 30 | LAST_EDITED_TIMESTAMP="$( stat -f "%m" ${BASE_COIN_PATH} )" 31 | else 32 | LAST_EDITED_TIMESTAMP="$( stat -c "%Y" ${BASE_COIN_PATH} )" 33 | fi 34 | let TARGET_TIME=${LAST_EDITED_TIMESTAMP}+${CRON_CYCLE}*60 35 | 36 | if [[ ${TARGET_TIME} -ge ${CURRENT_TIMESTAMP} ]]; then 37 | echo "Freshly edited" 38 | ${START_GENERATOR}="$( exec bash "${GENERATOR_FILE_PATH}" )" 39 | fi 40 | 41 | echo ${START_GENERATOR} 42 | -------------------------------------------------------------------------------- /compile.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | 4 | # Bash script for change coin files 5 | 6 | # Exit immediately if an error occurs, or if an undeclared variable is used 7 | set -o errexit 8 | 9 | 10 | [ "$OSTYPE" != "win"* ] || die "Windows is not supported" 11 | 12 | 13 | # A POSIX variable 14 | OPTIND=1 # Reset in case getopts has been used previously in the shell. 15 | 16 | 17 | while getopts "c:z" opt; do 18 | case "$opt" in 19 | c) COMPILE_ARGS=${OPTARG} 20 | ;; 21 | z) archive=1 22 | esac 23 | done 24 | archive=${archive:-0} 25 | 26 | shift $((OPTIND-1)) 27 | 28 | cd ${NEW_COIN_PATH} 29 | 30 | # Compile! 31 | if [[ "$OSTYPE" == "msys" ]]; then 32 | cmake -G "Visual Studio 12 Win64" "..\.." 33 | msbuild.exe Bytecoin.sln /property:Configuration=Release ${COMPILE_ARGS} 34 | else 35 | make release-static ${COMPILE_ARGS} 36 | fi 37 | 38 | if [[ $? == "0" ]]; then 39 | echo "Compilation successful" 40 | fi 41 | 42 | # Move and zip binaries 43 | if [[ $archive == "1" ]]; then 44 | BUILD_PATH="${WORK_FOLDERS_PATH}/builds" 45 | ALL_BUILD_FILES="${__CONFIG_core_CRYPTONOTE_NAME}-all-files" 46 | 47 | rm -rf ${BUILD_PATH}/${ALL_BUILD_FILES} 48 | mkdir -p ${BUILD_PATH}/${ALL_BUILD_FILES} 49 | cp -R ${NEW_COIN_PATH}/build/release/bin/ ${BUILD_PATH}/${ALL_BUILD_FILES}/ 50 | if [[ " ${__CONFIG_extensions_text} " == *"multiply.json"* ]]; then 51 | git clone https://github.com/forknote/configs.git ${BUILD_PATH}/${ALL_BUILD_FILES}/configs 52 | rm -rf ${BUILD_PATH}/${ALL_BUILD_FILES}/configs/.git 53 | rm -rf ${BUILD_PATH}/${ALL_BUILD_FILES}/configs/.gitignore 54 | fi 55 | 56 | rm -rf "${NEW_COIN_PATH}/build" 57 | fi 58 | -------------------------------------------------------------------------------- /configs/aeon.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensions": [ 3 | "core/monero.json", 4 | "donations.json", 5 | "aeon.json" 6 | ], 7 | "base_coin": { 8 | "name": "monero", 9 | "git": "https://github.com/monero-project/monero.git" 10 | }, 11 | "core": { 12 | "COIN_NAME": "Aeon", 13 | "CRYPTONOTE_NAME": "aeon", 14 | "CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX": 178, 15 | "CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX": 179, 16 | "CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX": 42, 17 | "MAINNET_P2P_DEFAULT_PORT": 11180, 18 | "MAINNET_RPC_DEFAULT_PORT": 11181, 19 | "MAINNET_ZMQ_RPC_DEFAULT_PORT": 11182, 20 | "TESTNET_P2P_DEFAULT_PORT": 22280, 21 | "TESTNET_RPC_DEFAULT_PORT": 22281, 22 | "TESTNET_ZMQ_RPC_DEFAULT_PORT": 22282, 23 | "MAINNET_SEED_NODES":"full_addrs.insert(\"74.91.23.186:11180\");\nfull_addrs.insert(\"192.187.114.114:11180\");\nfull_addrs.insert(\"34.200.218.170:11180\");\nfull_addrs.insert(\"144.76.104.208:11180\");\n", 24 | "TESTNET_SEED_NODES":"full_addrs.insert(\"165.227.238.211\");\n", 25 | "MAINNET_CHECKPOINTS":" ADD_CHECKPOINT(1, \"1440a20f078bf3264822234b347f8382606577d73d4e9d3cb7296d73889bc421\");\n ADD_CHECKPOINT(100, \"6dd13aaab16679f49ee6b2b75c7dc99b1fd09ab2282b18cb4b55b73110655742\");\n ADD_CHECKPOINT(1000, \"bc6458452fd0575a314089bf302f6fd68ebaa2d689c42f3365293b96bbdf1f25\");\n ADD_CHECKPOINT(10000, \"1ac1ebd25baf0d6ec593daa3389f1aa7e860ff2cc29f3cf1be586d245b379da4\");\n ADD_CHECKPOINT(15000, \"15567af42afc1ed00538f53b5e3822d421e3ed6372ca79f4ea4e3e3bab709a87\");\n ADD_CHECKPOINT(175500, \"3f7dd748b3b863b04654d87a387f2b65a365f467188971f3192eab2368e64a35\");\n ADD_CHECKPOINT(450000, \"f69a6e57c4dd5df2f492c9d31c50f11aad2c25a64d540ce5f5d11b572aec8ab7\");\n ADD_CHECKPOINT(540000, \"94e19cf9d5a16ae90f67c321f8376b87da21d6d6c2cb0957b9ab558dca66c1dc\");\n ADD_CHECKPOINT(592001, \"e8bc936b287a9c426a15cf127624b064c88e6d37655cc87f9a62cf1623c62385\");\n ADD_CHECKPOINT(798358, \"804c7fe07511d9387e7cda534c9e8b644d406d8d0ff299799a8177850d4e75a0\");\n ADD_CHECKPOINT(871000, \"99f7e5460da3fb4e2b15214017b0a17ff0294823ad852259ff837f0ffeeb90f0\");\n", 26 | "MAINNET_HARDFORKS":"{ 1, 1, 0, 1341378000 }", 27 | "TESTNET_HARDFORKS":"{ 1, 1, 0, 1341378000 }", 28 | "MAINNET_HARDFORK_V1_LAST_BLOCK": -1, 29 | "TESTNET_HARDFORK_V1_LAST_BLOCK": -1, 30 | "MAINNET_HARDFORK_V1HF":592000, 31 | 32 | "P2P_STAT_TRUSTED_PUB_KEY": "", 33 | 34 | "MAINNET_GENESIS_TX": "013c01ff0001ffffffffffff03029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121012bf2d282da90cee9c7a28c16e81418101ee28607d9e50f706594ee144a453b68", 35 | "TESTNET_GENESIS_TX": "013c01ff0001ffffffffffff03029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121017c18fb180e05e89625b8324cd22ceeb3d4925ebaa5c274c9e927b2cf5669ffd6", 36 | "MAINNET_NETWORK_ID": "0x32 ,0x32, 0xF3, 0x91 , 0x81, 0x18 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x10", 37 | "TESTNET_NETWORK_ID": "0x32 ,0x32, 0xF3, 0x91 , 0x81, 0x18 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x11", 38 | "MONEY_SUPPLY": -1, 39 | "FINAL_SUBSIDY_PER_MINUTE": 0, 40 | "MINIMUM_RELAY_FEE": 1000000, 41 | "DEFAULT_FEE": 10000000000, 42 | "NO_FEE_PER_KB_FEE_MAX_HEIGHT": -1, 43 | "EMISSION_SPEED_FACTOR_PER_MINUTE_V1": 20, 44 | "EMISSION_SPEED_FACTOR_PER_MINUTE_V1HF":18, 45 | "DIFFICULTY_WINDOW_V1": 720, 46 | "DIFFICULTY_WINDOW_V1HF": 360, 47 | "DIFFICULTY_WINDOW_V2": 360, 48 | "DIFFICULTY_TARGET_V1": 60, 49 | "DIFFICULTY_TARGET_V1HF": 240, 50 | "DIFFICULTY_TARGET_V2": 240, 51 | 52 | "POW_SPEED_MULTIPLIER_V1HF": 2, 53 | "MEMORY_MULTIPLIER_V1HF": 0.5, 54 | "CONFIG_DONATION_ADDRESS": "WmsSWgtT1JPg5e3cK41hKXSHVpKW7e47bjgiKmWZkYrhSS5LhRemNyqayaSBtAQ6517eo5PtH9wxHVmM78JDZSUu2W8PqRiNs" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /configs/dashcoin.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensions": [ 3 | "core/monero.json", 4 | "bytecoin-clone.json" 5 | ], 6 | "base_coin": { 7 | "name": "monero", 8 | "git": "https://github.com/monero-project/monero.git" 9 | }, 10 | "core": { 11 | "COIN_NAME": "Dashcoin", 12 | "CRYPTONOTE_NAME": "dashcoin.monero", 13 | "CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX": 72, 14 | "CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX": 73, 15 | "CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX": 42, 16 | "MAINNET_P2P_DEFAULT_PORT": 29080, 17 | "MAINNET_RPC_DEFAULT_PORT": 29081, 18 | "MAINNET_ZMQ_RPC_DEFAULT_PORT": 29082, 19 | "MAINNET_SEED_NODES":"full_addrs.insert(\"108.61.188.93:7610\");\nfull_addrs.insert(\"104.238.188.213:7610\");\n", 20 | "MAINNET_CHECKPOINTS":" ADD_CHECKPOINT(28000, \"70d2531151529ac00bf875281e15f51324934bc85e5733dcd92e1ccb1a665ff8\");\nADD_CHECKPOINT(87500, \"cce8a035f34457ec1098ab41e5949cac3db00ebff3503e26f36bfa057543095a\");\nADD_CHECKPOINT(738000, \"8202b5dc2b070bd7743c44763e6eb5546ea7699f3829dc29594f046f21199b08\");\n", 21 | "MAINNET_HARDFORKS":"{ 1, 1, 0, 1341378000 },\n { 2, 91453, 0, 1415599000 },", 22 | "MAINNET_HARDFORK_V1_LAST_BLOCK": 91452, 23 | 24 | "CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1": 10000, 25 | "CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2": 20000, 26 | "CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5": 200000, 27 | "CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW": 10, 28 | "CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE": 0, 29 | 30 | "BYTECOIN_CLONE": 1, 31 | 32 | "P2P_STAT_TRUSTED_PUB_KEY": "", 33 | 34 | "MAINNET_GENESIS_TX": "010a01ff0001ffffffffffff0f029b2e4c0271c0b42e7c53291a94d1c0cbff8883f8024f5142ee494ffbbd08807121013c086a48c15fb637a96991bc6d53caf77068b5ba6eeb3c82357228c49790584a", 35 | "MAINNET_GENESIS_NONCE": 70, 36 | "MAINNET_NETWORK_ID": "0x12, 0x11, 0x21, 0x11, 0x11, 0x10, 0x41, 0x01, 0x13, 0x11, 0x00, 0x12, 0x12, 0x11, 0x01, 0x10", 37 | 38 | "MONEY_SUPPLY": -1, 39 | "FINAL_SUBSIDY_PER_MINUTE": 0, 40 | "MINIMUM_RELAY_FEE": 1000000, 41 | "DEFAULT_FEE": 1000000000, 42 | "NO_FEE_PER_KB_FEE_MAX_HEIGHT": -1, 43 | "EMISSION_SPEED_FACTOR_PER_MINUTE": 19, 44 | "DIFFICULTY_WINDOW_V1": 720, 45 | "DIFFICULTY_WINDOW_V2": 720, 46 | "DIFFICULTY_TARGET_V1": 120, 47 | "DIFFICULTY_TARGET_V2": 120 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /configs/monero-block-explorer.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensions": [ 3 | "core/monero.json", 4 | "blockchain-explorer.json", 5 | "enable-cors.json" 6 | ], 7 | "base_coin": { 8 | "name": "monero", 9 | "git": "https://github.com/monero-project/monero.git" 10 | }, 11 | "core": { 12 | "CRYPTONOTE_NAME": "monero-block-explorer" 13 | } 14 | } -------------------------------------------------------------------------------- /configs/wownero.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensions": [ 3 | "core/monero.json" 4 | ], 5 | "base_coin": { 6 | "name": "monero", 7 | "git": "https://github.com/monero-project/monero.git" 8 | }, 9 | "core": { 10 | "COIN_NAME": "Wownero", 11 | "CRYPTONOTE_NAME": "wownero", 12 | 13 | "CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX": 4146, 14 | "CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX": 6810, 15 | "CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX": 12208, 16 | "MAINNET_P2P_DEFAULT_PORT": 34567, 17 | "MAINNET_RPC_DEFAULT_PORT": 34568, 18 | "MAINNET_ZMQ_RPC_DEFAULT_PORT": 34569, 19 | "TESTNET_P2P_DEFAULT_PORT": 11180, 20 | "TESTNET_RPC_DEFAULT_PORT": 11181, 21 | "TESTNET_ZMQ_RPC_DEFAULT_PORT": 11182, 22 | "MAINNET_SEED_NODES":"full_addrs.insert(\"127.0.0.1:34567\");\n", 23 | "TESTNET_SEED_NODES":"full_addrs.insert(\"127.0.0.1:11180\");\n", 24 | "MAINNET_CHECKPOINTS":" \n", 25 | "MAINNET_HARDFORKS":"{ 1, 1, 0, 1341378000 },\n { 6, 1, 0, 1519605000 }", 26 | "TESTNET_HARDFORKS":"{ 1, 1, 0, 1341378000 },\n { 6, 1, 0, 1519605000 }", 27 | "MAINNET_HARDFORK_V1_LAST_BLOCK": 1, 28 | "TESTNET_HARDFORK_V1_LAST_BLOCK": 1, 29 | 30 | "P2P_STAT_TRUSTED_PUB_KEY": "0000000000000000000000000000000000000000000000000000000000000000", 31 | 32 | "MAINNET_GENESIS_TX": "013c01ff0001ffffffffffff7f029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd0880712101e5e22882a5b0b01516ff6716104699e4081eb5e570ebe5b93c370ea879245941", 33 | "MAINNET_GENESIS_NONCE": 70, 34 | "TESTNET_GENESIS_TX": "013c01ff0001ffffffffffff7f029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121011fb442f1ba0f9882128e6a43dcf2a5bd2c9ad17df2df0b4f5d38d863a7bfe859", 35 | "TESTNET_GENESIS_NONCE": 70, 36 | 37 | "MAINNET_NETWORK_ID": "0x11, 0x33, 0xFF, 0x77, 0x61, 0x04, 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x10", 38 | "TESTNET_NETWORK_ID": "0x11, 0x33, 0xFF, 0x77, 0x61, 0x04, 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x11", 39 | "MONEY_SUPPLY": -1, 40 | "FINAL_SUBSIDY_PER_MINUTE": 0, 41 | "EMISSION_SPEED_FACTOR_PER_MINUTE": 19, 42 | "CRYPTONOTE_DISPLAY_DECIMAL_POINT": 11, 43 | "COIN": 100000000000, 44 | "DIFFICULTY_WINDOW_V1": 720, 45 | "DIFFICULTY_WINDOW_V2": 720, 46 | "DIFFICULTY_TARGET_V1": 300, 47 | "DIFFICULTY_TARGET_V2": 300 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /extensions/aeon.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "aeon.json", 3 | "description": "Changes for aeon", 4 | "required": [ 5 | "core/monero.json" 6 | ], 7 | "files": [ 8 | { 9 | "path": "/src/cryptonote_config.h", 10 | "changes": [ 11 | { 12 | "action": "add_below", 13 | "marker": "#define DIFFICULTY_TARGET_V1", 14 | "parameters": { 15 | "text": [ 16 | "#define DIFFICULTY_TARGET_V1HF %s" 17 | ], 18 | "replace_text_alt": [ 19 | "#define DIFFICULTY_TARGET_V1HF DIFFICULTY_TARGET_V1" 20 | ], 21 | "var": "DIFFICULTY_TARGET_V1HF" 22 | } 23 | }, 24 | { 25 | "action": "add_below", 26 | "marker": "#define DIFFICULTY_WINDOW 720", 27 | "parameters": { 28 | "text": [ 29 | "#define DIFFICULTY_WINDOW_V1HF %s" 30 | ], 31 | "replace_text_alt": [ 32 | "#define DIFFICULTY_WINDOW_V1HF DIFFICULTY_WINDOW" 33 | ], 34 | "var": "DIFFICULTY_WINDOW_V1HF" 35 | } 36 | }, 37 | { 38 | "action": "add_below", 39 | "marker": "#define EMISSION_SPEED_FACTOR_PER_MINUTE (20)", 40 | "parameters": { 41 | "text": [ 42 | "#define EMISSION_SPEED_FACTOR_PER_MINUTE_V1HF (%s)" 43 | ], 44 | "replace_text_alt": [ 45 | "#define EMISSION_SPEED_FACTOR_PER_MINUTE_V1HF EMISSION_SPEED_FACTOR_PER_MINUTE" 46 | ], 47 | "var": "EMISSION_SPEED_FACTOR_PER_MINUTE_V1HF" 48 | } 49 | }, 50 | { 51 | "action": "add_below", 52 | "marker": "#define DIFFICULTY_CUT 60", 53 | "parameters": { 54 | "text": [ 55 | "#define MAINNET_HARDFORK_V1HF ((uint64_t)(%s))" 56 | ], 57 | "replace_text_alt": [ 58 | "#define MAINNET_HARDFORK_V1HF ((uint64_t)(-1))" 59 | ], 60 | "var": "MAINNET_HARDFORK_V1HF" 61 | } 62 | }, 63 | { 64 | "action": "add_below", 65 | "marker": "#define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG", 66 | "parameters": { 67 | "text": [ 68 | "#define POW_SPEED_MULTIPLIER_V1HF %s" 69 | ], 70 | "var": "POW_SPEED_MULTIPLIER_V1HF" 71 | } 72 | }, 73 | { 74 | "action": "add_below", 75 | "marker": "#define HASH_OF_HASHES_STEP 256", 76 | "parameters": { 77 | "text": [ 78 | "#define MEMORY_MULTIPLIER_V1HF %s" 79 | ], 80 | "replace_text_alt": [ 81 | "#define MEMORY_MULTIPLIER_V1HF 1" 82 | ], 83 | "var": "MEMORY_MULTIPLIER_V1HF" 84 | } 85 | }, 86 | 87 | 88 | { 89 | "description": "NO_FEE_PER_KB", 90 | "action": "add_above", 91 | "marker": "#define FEE_PER_KB_OLD", 92 | "parameters": { 93 | "text": [ 94 | "#define MINIMUM_RELAY_FEE %s" 95 | ], 96 | "replace_text_alt": [ 97 | "#define MINIMUM_RELAY_FEE 0" 98 | ], 99 | "var": "MINIMUM_RELAY_FEE" 100 | } 101 | } 102 | ] 103 | }, 104 | { 105 | "path": "/src/cryptonote_config.h", 106 | "changes": [ 107 | { 108 | "description": "NO_FEE_PER_KB", 109 | "action": "add_above", 110 | "marker": "#define FEE_PER_KB_OLD", 111 | "parameters": { 112 | "text": [ 113 | "#define DEFAULT_FEE %s" 114 | ], 115 | "replace_text_alt": [ 116 | "#define DEFAULT_FEE 0" 117 | ], 118 | "var": "DEFAULT_FEE" 119 | } 120 | } 121 | ] 122 | }, 123 | { 124 | "path": "/src/cryptonote_config.h", 125 | "changes": [ 126 | { 127 | "description": "NO_FEE_PER_KB", 128 | "action": "add_above", 129 | "marker": "#define FEE_PER_KB_OLD", 130 | "parameters": { 131 | "text": [ 132 | "#define NO_FEE_PER_KB_FEE_MAX_HEIGHT ((uint64_t)(%s))" 133 | ], 134 | "replace_text_alt": [ 135 | "#define NO_FEE_PER_KB_FEE_MAX_HEIGHT ((uint64_t)(0))" 136 | ], 137 | "var": "NO_FEE_PER_KB_FEE_MAX_HEIGHT" 138 | } 139 | } 140 | ] 141 | }, 142 | { 143 | "path": "/src/crypto/slow-hash.c", 144 | "changes": [ 145 | { 146 | "action": "replace", 147 | "marker": "#define state_index(x) (((*((uint64_t *)x) >> 4) & (TOTALBLOCKS - 1)) << 4)", 148 | "parameters": { 149 | "text": [ 150 | "#define state_index(x,mul) (((*((uint64_t *)x) >> 4) & ((int)(TOTALBLOCKS*(mul)) - 1)) << 4)" 151 | ] 152 | } 153 | }, 154 | { 155 | "action": "replace", 156 | "marker": "j = state_index(a); \\", 157 | "parameters": { 158 | "text": [ 159 | " j = state_index(a, memory_multiplier); \\" 160 | ] 161 | } 162 | }, 163 | { 164 | "action": "replace", 165 | "marker": "j = state_index(c); \\", 166 | "parameters": { 167 | "text": [ 168 | " j = state_index(c, memory_multiplier); \\" 169 | ] 170 | } 171 | }, 172 | { 173 | "action": "replace", 174 | "marker": "for(i = 0; i < MEMORY / INIT_SIZE_BYTE; i++)", 175 | "parameters": { 176 | "text": [ 177 | " for(i = 0; i < (MEMORY * memory_multiplier) / INIT_SIZE_BYTE; i++)" 178 | ] 179 | } 180 | }, 181 | { 182 | "action": "replace", 183 | "marker": "for(i = 0; i < ITER / 2; i++)", 184 | "parameters": { 185 | "text": [ 186 | " for(i = 0; i < (ITER * memory_multiplier) / 2; i++)" 187 | ] 188 | } 189 | }, 190 | { 191 | "action": "replace", 192 | "marker": "void cn_slow_hash(const void *data, size_t length, char *hash) {", 193 | "parameters": { 194 | "text": [ 195 | "void cn_slow_hash(const void *data, size_t length, char *hash) {", 196 | " cn_slow_hash_with_multiplier(data, length, hash, 1);", 197 | "}", 198 | "", 199 | "void cn_slow_hash_with_multiplier_test(const void *data, size_t length, char *hash) {", 200 | " cn_slow_hash_with_multiplier(data, length, hash, 0.5);", 201 | "}", 202 | "", 203 | "void cn_slow_hash_with_multiplier(const void *data, size_t length, char *hash, double memory_multiplier) {" 204 | ] 205 | } 206 | }, 207 | { 208 | "action": "replace", 209 | "marker": "void cn_slow_hash(const void *data, size_t length, char *hash)", 210 | "parameters": { 211 | "text": [ 212 | "void cn_slow_hash(const void *data, size_t length, char *hash)", 213 | "{", 214 | " cn_slow_hash_with_multiplier(data, length, hash, 1);", 215 | "}", 216 | "", 217 | "void cn_slow_hash_with_multiplier_test(const void *data, size_t length, char *hash)", 218 | "{", 219 | " cn_slow_hash_with_multiplier(data, length, hash, 0.5);", 220 | "}", 221 | "", 222 | "void cn_slow_hash_with_multiplier(const void *data, size_t length, char *hash, double memory_multiplier)" 223 | ] 224 | } 225 | }, 226 | { 227 | "action": "replace", 228 | "marker": "for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) {", 229 | "parameters": { 230 | "text": [ 231 | " for (i = 0; i < (MEMORY * memory_multiplier) / INIT_SIZE_BYTE; i++) {" 232 | ] 233 | } 234 | }, 235 | { 236 | "action": "replace", 237 | "marker": "for (i = 0; i < ITER / 2; i++) {", 238 | "parameters": { 239 | "text": [ 240 | " for (i = 0; i < (ITER * memory_multiplier) / 2; i++) {" 241 | ] 242 | } 243 | }, 244 | { 245 | "action": "replace", 246 | "marker": "j = e2i(a, MEMORY / AES_BLOCK_SIZE);", 247 | "parameters": { 248 | "text": [ 249 | " j = e2i(a, (MEMORY * memory_multiplier) / AES_BLOCK_SIZE);" 250 | ] 251 | } 252 | }, 253 | { 254 | "action": "replace", 255 | "marker": "assert(j == e2i(a, MEMORY / AES_BLOCK_SIZE));", 256 | "parameters": { 257 | "text": [ 258 | " assert(j == e2i(a, (MEMORY * memory_multiplier) / AES_BLOCK_SIZE));" 259 | ] 260 | } 261 | } 262 | ] 263 | }, 264 | 265 | 266 | { 267 | "path": "/src/crypto/hash-ops.h", 268 | "changes": [ 269 | { 270 | "action": "add_below", 271 | "marker": "void cn_slow_hash(const void *data, size_t length, char *hash);", 272 | "parameters": { 273 | "text": [ 274 | "void cn_slow_hash_with_multiplier_test(const void *data, size_t length, char *hash);", 275 | "void cn_slow_hash_with_multiplier(const void *data, size_t length, char *hash, double memory_multiplier);" 276 | ] 277 | } 278 | } 279 | ] 280 | }, 281 | { 282 | "path": "/src/crypto/hash.h", 283 | "changes": [ 284 | { 285 | "action": "add_above", 286 | "marker": "inline void cn_slow_hash(const void *data, std::size_t length, hash &hash) {", 287 | "parameters": { 288 | "text": [ 289 | "inline void cn_slow_hash_with_multiplier_test(const void *data, std::size_t length, hash &hash) {", 290 | " cn_slow_hash_with_multiplier_test(data, length, reinterpret_cast(&hash));", 291 | "}", 292 | "", 293 | "inline void cn_slow_hash_with_multiplier(const void *data, std::size_t length, hash &hash, double memory_multiplier) {", 294 | " cn_slow_hash_with_multiplier(data, length, reinterpret_cast(&hash), memory_multiplier);", 295 | "}", 296 | "" 297 | ] 298 | } 299 | } 300 | ] 301 | }, 302 | 303 | { 304 | "path": "/src/cryptonote_basic/cryptonote_basic_impl.h", 305 | "changes": [ 306 | { 307 | "action": "add_below", 308 | "marker": "bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint8_t version);", 309 | "parameters": { 310 | "text": [ 311 | " bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint8_t version, size_t height);" 312 | ] 313 | } 314 | } 315 | ] 316 | }, 317 | { 318 | "path": "/src/cryptonote_basic/cryptonote_basic_impl.cpp", 319 | "changes": [ 320 | { 321 | "action": "replace", 322 | "marker": "const int emission_speed_factor = EMISSION_SPEED_FACTOR_PER_MINUTE - (target_minutes-1);", 323 | "parameters": { 324 | "text": [ 325 | "int emission_speed_factor = EMISSION_SPEED_FACTOR_PER_MINUTE - (target_minutes-1);", 326 | "emission_speed_factor = height < MAINNET_HARDFORK_V1HF ? EMISSION_SPEED_FACTOR_PER_MINUTE - (target_minutes-1) : EMISSION_SPEED_FACTOR_PER_MINUTE_V1HF - (target_minutes-1);" 327 | ] 328 | } 329 | }, 330 | { 331 | "action": "replace", 332 | "marker": "bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint8_t version) {", 333 | "parameters": { 334 | "text": [ 335 | "bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint8_t version) {", 336 | " return get_block_reward(median_size, current_block_size, already_generated_coins, reward, version, 0);", 337 | "}", 338 | "", 339 | "bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint8_t version, size_t height) {" 340 | ] 341 | } 342 | } 343 | ] 344 | }, 345 | { 346 | "path": "/src/cryptonote_core/blockchain.cpp", 347 | "changes": [ 348 | { 349 | "action": "replace", 350 | "marker": "if (!get_block_reward(epee::misc_utils::median(last_blocks_sizes), cumulative_block_size, already_generated_coins, base_reward, version))", 351 | "parameters": { 352 | "text": [ 353 | " if (!get_block_reward(epee::misc_utils::median(last_blocks_sizes), cumulative_block_size, already_generated_coins, base_reward, version, m_db->height()))" 354 | ] 355 | } 356 | }, 357 | { 358 | "action": "replace", 359 | "marker": "if (!get_block_reward(median, 1, already_generated_coins, base_reward, version))", 360 | "parameters": { 361 | "text": [ 362 | " if (!get_block_reward(median, 1, already_generated_coins, base_reward, version, m_db->height()))" 363 | ] 364 | } 365 | }, 366 | { 367 | "action": "replace", 368 | "marker": "return next_difficulty(timestamps, difficulties, target);", 369 | "parameters": { 370 | "text": [ 371 | "return next_difficulty(timestamps, difficulties, target, m_db->height());" 372 | ] 373 | } 374 | }, 375 | { 376 | "action": "replace", 377 | "marker": "if (!m_tx_pool.fill_block_template(b, median_size, already_generated_coins, txs_size, fee, expected_reward, m_hardfork->get_current_version()))", 378 | "parameters": { 379 | "text": [ 380 | " if (!m_tx_pool.fill_block_template(b, median_size, already_generated_coins, txs_size, fee, expected_reward, m_hardfork->get_current_version(), height))" 381 | ] 382 | } 383 | }, 384 | { 385 | "action": "replace", 386 | "marker": "return get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;", 387 | "parameters": { 388 | "text": [ 389 | " uint64_t difficulty_target = DIFFICULTY_TARGET_V1;", 390 | " if (m_db->height() >= MAINNET_HARDFORK_V1HF)", 391 | " difficulty_target = DIFFICULTY_TARGET_V1HF;", 392 | " if (get_current_hard_fork_version() >= 2)", 393 | " difficulty_target = DIFFICULTY_TARGET_V2;", 394 | "", 395 | "return difficulty_target;" 396 | ] 397 | } 398 | } 399 | ] 400 | }, 401 | { 402 | "path": "/src/cryptonote_basic/cryptonote_format_utils.cpp", 403 | "changes": [ 404 | { 405 | "action": "replace", 406 | "marker": "crypto::cn_slow_hash(bd.data(), bd.size(), res);", 407 | "parameters": { 408 | "text": [ 409 | " double memory_multiplier = 1;", 410 | " if (height >= MAINNET_HARDFORK_V1HF)", 411 | " memory_multiplier = MEMORY_MULTIPLIER_V1HF;", 412 | " crypto::cn_slow_hash_with_multiplier(bd.data(), bd.size(), res, memory_multiplier);" 413 | ] 414 | } 415 | } 416 | ] 417 | }, 418 | { 419 | "path": "/src/cryptonote_core/cryptonote_tx_utils.cpp", 420 | "changes": [ 421 | { 422 | "action": "replace", 423 | "marker": "if(!get_block_reward(median_size, current_block_size, already_generated_coins, block_reward, hard_fork_version))", 424 | "parameters": { 425 | "text": [ 426 | " if(!get_block_reward(median_size, current_block_size, already_generated_coins, block_reward, hard_fork_version, height))" 427 | ] 428 | } 429 | } 430 | ] 431 | }, 432 | 433 | { 434 | "path": "/src/wallet/wallet2.cpp", 435 | "changes": [ 436 | { 437 | "description": "NO_FEE_PER_KB", 438 | "action": "replace", 439 | "marker": "uint64_t needed_fee = calculate_fee(fee_per_kb, estimated_tx_size, fee_multiplier);", 440 | "parameters": { 441 | "text": [ 442 | " uint64_t needed_fee = 0;", 443 | " if (NO_FEE_PER_KB_FEE_MAX_HEIGHT <= m_blockchain.size())", 444 | " needed_fee = calculate_fee(DEFAULT_FEE, 1, fee_multiplier);", 445 | " else", 446 | " needed_fee = calculate_fee(fee_per_kb, estimated_tx_size, fee_multiplier);" 447 | ] 448 | } 449 | } 450 | ] 451 | }, 452 | 453 | { 454 | "path": "/src/wallet/wallet2.cpp", 455 | "multiline": true, 456 | "changes": [ 457 | { 458 | "description": "NO_FEE_PER_KB", 459 | "action": "replace", 460 | "marker": "transfer\\(dst_vector, fake_outs_count, unused_transfers_indices, unlock_time, needed_fee, extra, tx, ptx, trusted_daemon\\);[^a]+auto txBlob = t_serializable_object_to_blob\\(ptx.tx\\);[^n]+needed_fee = calculate_fee\\(fee_per_kb, txBlob, fee_multiplier\\);", 461 | "parameters": { 462 | "text": [ 463 | "transfer(dst_vector, fake_outs_count, unused_transfers_indices, unlock_time, needed_fee, extra, tx, ptx, trusted_daemon);", 464 | " auto txBlob = t_serializable_object_to_blob(ptx.tx);", 465 | " if (NO_FEE_PER_KB_FEE_MAX_HEIGHT <= m_blockchain.size())", 466 | " needed_fee = calculate_fee(DEFAULT_FEE, 1, fee_multiplier);", 467 | " else", 468 | " needed_fee = calculate_fee(fee_per_kb, txBlob, fee_multiplier);" 469 | ] 470 | } 471 | } 472 | ] 473 | }, 474 | 475 | { 476 | "path": "/src/cryptonote_core/tx_pool.h", 477 | "changes": [ 478 | { 479 | "action": "add_below", 480 | "marker": "bool fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t &expected_reward, uint8_t version);", 481 | "parameters": { 482 | "text": [ 483 | " bool fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t &expected_reward, uint8_t version, size_t height);" 484 | ] 485 | } 486 | } 487 | ] 488 | }, 489 | 490 | { 491 | "path": "/src/cryptonote_core/tx_pool.cpp", 492 | "changes": [ 493 | { 494 | "description": "NO_FEE_PER_KB", 495 | "action": "add_below", 496 | "marker": "fee = inputs_amount - outputs_amount;", 497 | "parameters": { 498 | "text": [ 499 | " if (!kept_by_block && fee < MINIMUM_RELAY_FEE)", 500 | " {", 501 | " LOG_PRINT_L1(\"transaction fee is not enough: \" << print_money(fee) << \", minumim fee: \" << print_money(DEFAULT_FEE));", 502 | " tvc.m_verifivation_failed = true;", 503 | " return false;", 504 | " }" 505 | ] 506 | } 507 | }, 508 | { 509 | "action": "replace", 510 | "marker": "bool tx_memory_pool::fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t &expected_reward, uint8_t version)", 511 | "parameters": { 512 | "text": [ 513 | " bool tx_memory_pool::fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t &expected_reward, uint8_t version)", 514 | " {", 515 | " return fill_block_template(bl, median_size, already_generated_coins, total_size, fee, expected_reward, version, 0);", 516 | " }", 517 | " bool tx_memory_pool::fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t &expected_reward, uint8_t version, size_t height)" 518 | ] 519 | } 520 | }, 521 | { 522 | "action": "replace", 523 | "marker": "get_block_reward(median_size, total_size, already_generated_coins, best_coinbase, version);", 524 | "parameters": { 525 | "text": [ 526 | " get_block_reward(median_size, total_size, already_generated_coins, best_coinbase, version, height);" 527 | ] 528 | } 529 | }, 530 | { 531 | "action": "replace", 532 | "marker": "if(!get_block_reward(median_size, total_size + meta.blob_size, already_generated_coins, block_reward, version))", 533 | "parameters": { 534 | "text": [ 535 | " if(!get_block_reward(median_size, total_size + meta.blob_size, already_generated_coins, block_reward, version, height))" 536 | ] 537 | } 538 | } 539 | ] 540 | }, 541 | { 542 | "path": "/src/cryptonote_basic/difficulty.h", 543 | "changes": [ 544 | { 545 | "action": "add_below", 546 | "marker": "difficulty_type next_difficulty(std::vector timestamps, std::vector cumulative_difficulties, size_t target_seconds);", 547 | "parameters": { 548 | "text": [ 549 | " difficulty_type next_difficulty(std::vector timestamps, std::vector cumulative_difficulties, size_t target_seconds, uint64_t height);" 550 | ] 551 | } 552 | } 553 | ] 554 | }, 555 | { 556 | "path": "/src/cryptonote_basic/difficulty.cpp", 557 | "changes": [ 558 | { 559 | "action": "replace", 560 | "marker": "difficulty_type next_difficulty(std::vector timestamps, std::vector cumulative_difficulties, size_t target_seconds) {", 561 | "parameters": { 562 | "text": [ 563 | "", 564 | " difficulty_type next_difficulty(std::vector timestamps, std::vector cumulative_difficulties, size_t target_seconds) {", 565 | " return next_difficulty(timestamps, cumulative_difficulties, target_seconds, 0);", 566 | " }", 567 | "", 568 | " difficulty_type next_difficulty(std::vector timestamps, std::vector cumulative_difficulties, size_t target_seconds, uint64_t height) {" 569 | ] 570 | } 571 | }, 572 | { 573 | "action": "replace", 574 | "marker": "return (low + time_span - 1) / time_span;", 575 | "parameters": { 576 | "text": [ 577 | "", 578 | " difficulty_type new_diff = (low + time_span - 1) / time_span;", 579 | "", 580 | " if (height >= MAINNET_HARDFORK_V1HF && height < MAINNET_HARDFORK_V1HF+DIFFICULTY_WINDOW_V1HF) {", 581 | " new_diff += new_diff*(MAINNET_HARDFORK_V1HF+DIFFICULTY_WINDOW_V1HF-height)*(POW_SPEED_MULTIPLIER_V1HF-1)/DIFFICULTY_WINDOW_V1HF;", 582 | " }", 583 | "", 584 | " return new_diff;" 585 | ] 586 | } 587 | } 588 | ] 589 | }, 590 | 591 | { 592 | "path": "/tests/performance_tests/CMakeLists.txt", 593 | "changes": [ 594 | { 595 | "action": "add_below", 596 | "marker": "cn_slow_hash.h", 597 | "parameters": { 598 | "text": [ 599 | " cn_slow_hash_with_multiplier_test.h" 600 | ] 601 | } 602 | } 603 | ] 604 | }, 605 | { 606 | "path": "/tests/hash/CMakeLists.txt", 607 | "changes": [ 608 | { 609 | "action": "replace", 610 | "marker": "foreach (hash IN ITEMS fast slow tree extra-blake extra-groestl extra-jh extra-skein)", 611 | "parameters": { 612 | "text": [ 613 | "foreach (hash IN ITEMS fast slow slow-with-multiplier tree extra-blake extra-groestl extra-jh extra-skein)" 614 | ] 615 | } 616 | } 617 | ] 618 | }, 619 | { 620 | "path": "/tests/hash/main.cpp", 621 | "changes": [ 622 | { 623 | "action": "replace", 624 | "marker": "} hashes[] = {{\"fast\", cn_fast_hash}, {\"slow\", cn_slow_hash}, {\"tree\", hash_tree},", 625 | "parameters": { 626 | "text": [ 627 | "} hashes[] = {{\"fast\", cn_fast_hash}, {\"slow\", cn_slow_hash}, {\"slow-with-multiplier\", cn_slow_hash_with_multiplier_test}, {\"tree\", hash_tree}," 628 | ] 629 | } 630 | } 631 | ] 632 | }, 633 | { 634 | "path": "/tests/performance_tests/main.cpp", 635 | "changes": [ 636 | { 637 | "action": "add_below", 638 | "marker": "#include \"cn_slow_hash.h\"", 639 | "parameters": { 640 | "text": [ 641 | "#include \"cn_slow_hash_with_multiplier_test.h\"" 642 | ] 643 | } 644 | }, 645 | { 646 | "action": "add_below", 647 | "marker": "test_cn_slow_hash);", 648 | "parameters": { 649 | "text": [ 650 | " TEST_PERFORMANCE0(test_cn_slow_hash_with_multiplier_test);" 651 | ] 652 | } 653 | } 654 | ] 655 | }, 656 | { 657 | "path": "/tests/performance_tests/cn_slow_hash_with_multiplier_test.h", 658 | "action": "add", 659 | "source": "/aeon/files/tests/performance_tests/cn_slow_hash_with_multiplier_test.h" 660 | }, 661 | { 662 | "path": "/tests/hash/tests-slow-with-multiplier.txt", 663 | "action": "add", 664 | "source": "/aeon/files/tests/hash/tests-slow-with-multiplier.txt" 665 | }, 666 | 667 | 668 | { 669 | "path": "/src/blocks/blocks.dat", 670 | "action": "add", 671 | "source": "/aeon/files/blocks.dat" 672 | }, 673 | { 674 | "action": "bulk_replace", 675 | "find": "monerod", 676 | "replace": "aeond", 677 | "file_pattern": "*" 678 | }, 679 | { 680 | "action": "bulk_replace", 681 | "find": "#monero-dev", 682 | "replace": "#aeon", 683 | "file_pattern": "*" 684 | }, 685 | { 686 | "action": "bulk_replace", 687 | "find": "monero-wallet-cli", 688 | "replace": "aeon-wallet-cli", 689 | "file_pattern": "*" 690 | }, 691 | { 692 | "action": "bulk_replace", 693 | "find": "monero-wallet-rpc", 694 | "replace": "aeon-wallet-rpc", 695 | "file_pattern": "*" 696 | }, 697 | { 698 | "action": "bulk_replace", 699 | "find": "monero-blockchain-export", 700 | "replace": "aeon-blockchain-export", 701 | "file_pattern": "*" 702 | }, 703 | { 704 | "action": "bulk_replace", 705 | "find": "monero-blockchain-import", 706 | "replace": "aeon-blockchain-import", 707 | "file_pattern": "*" 708 | }, 709 | { 710 | "action": "bulk_replace", 711 | "find": "monero-gen-trusted-multisig", 712 | "replace": "aeon-gen-trusted-multisig", 713 | "file_pattern": "*" 714 | }, 715 | { 716 | "action": "bulk_replace", 717 | "find": "https://github.com/monero-project/monero", 718 | "replace": "https://github.com/aeonix/aeon", 719 | "file_pattern": "*" 720 | } 721 | ] 722 | } 723 | -------------------------------------------------------------------------------- /extensions/aeon/files/blocks.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/forknote/monero-generator/1f9f58b924df539825478ce8af97b3387e7ff76e/extensions/aeon/files/blocks.dat -------------------------------------------------------------------------------- /extensions/aeon/files/tests/hash/tests-slow-with-multiplier.txt: -------------------------------------------------------------------------------- 1 | afffe6c3084b0de799f6851389619bfe36be4705e4fb9e5039f8044b0decf8ea 63617665617420656d70746f72 2 | -------------------------------------------------------------------------------- /extensions/aeon/files/tests/performance_tests/cn_slow_hash_with_multiplier_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, The Aeon Project 2 | // 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without modification, are 6 | // permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, this list of 9 | // conditions and the following disclaimer. 10 | // 11 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list 12 | // of conditions and the following disclaimer in the documentation and/or other 13 | // materials provided with the distribution. 14 | // 15 | // 3. Neither the name of the copyright holder nor the names of its contributors may be 16 | // used to endorse or promote products derived from this software without specific 17 | // prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 20 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 22 | // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 27 | // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers 30 | 31 | #pragma once 32 | 33 | #include "string_tools.h" 34 | #include "crypto/crypto.h" 35 | #include "cryptonote_basic/cryptonote_basic.h" 36 | 37 | class test_cn_slow_hash_with_multiplier_test 38 | { 39 | public: 40 | static const size_t loop_count = 10; 41 | 42 | #pragma pack(push, 1) 43 | struct data_t 44 | { 45 | char data[13]; 46 | }; 47 | #pragma pack(pop) 48 | 49 | static_assert(13 == sizeof(data_t), "Invalid structure size"); 50 | 51 | bool init() 52 | { 53 | if (!epee::string_tools::hex_to_pod("63617665617420656d70746f72", m_data)) 54 | return false; 55 | 56 | if (!epee::string_tools::hex_to_pod("afffe6c3084b0de799f6851389619bfe36be4705e4fb9e5039f8044b0decf8ea", m_expected_hash)) 57 | return false; 58 | 59 | return true; 60 | } 61 | 62 | bool test() 63 | { 64 | crypto::hash hash; 65 | crypto::cn_slow_hash_with_multiplier_test(&m_data, sizeof(m_data), hash); 66 | 67 | return hash == m_expected_hash; 68 | } 69 | 70 | private: 71 | data_t m_data; 72 | crypto::hash m_expected_hash; 73 | }; 74 | -------------------------------------------------------------------------------- /extensions/blockchain-explorer.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "blockchain-explorer.json", 3 | "description": "Adds json rpc methods for block and transaction actions", 4 | "required": [ 5 | "core/monero.json" 6 | ], 7 | "files": [ 8 | { 9 | "path": "/src/blockchain_db/blockchain_db.h", 10 | "changes": [ 11 | { 12 | "action": "add_below", 13 | "marker": "virtual uint64_t get_block_already_generated_coins(const uint64_t& height) const = 0;", 14 | "parameters": { 15 | "text": [ 16 | "virtual uint64_t get_block_already_generated_transactions(const uint64_t& height) const = 0;" 17 | ] 18 | } 19 | } 20 | ] 21 | }, 22 | { 23 | "path": "/src/blockchain_db/lmdb/db_lmdb.h", 24 | "changes": [ 25 | { 26 | "action": "add_below", 27 | "marker": "virtual uint64_t get_block_already_generated_coins(const uint64_t& height) const;", 28 | "parameters": { 29 | "text": [ 30 | "virtual uint64_t get_block_already_generated_transactions(const uint64_t& height) const;" 31 | ] 32 | } 33 | } 34 | ] 35 | }, 36 | { 37 | "path": "/src/blockchain_db/lmdb/db_lmdb.cpp", 38 | "changes": [ 39 | { 40 | "action": "add_below", 41 | "marker": "uint64_t bi_coins;", 42 | "parameters": { 43 | "text": [ 44 | "uint64_t bi_txs;" 45 | ] 46 | } 47 | }, 48 | { 49 | "action": "add_below", 50 | "marker": "bi.bi_coins = coins_generated;", 51 | "parameters": { 52 | "text": [ 53 | " bi.bi_txs = m_num_txs;" 54 | ] 55 | } 56 | }, 57 | { 58 | "action": "add_above", 59 | "marker": "crypto::hash BlockchainLMDB::get_block_hash_from_height(const uint64_t& height) const", 60 | "parameters": { 61 | "text": [ 62 | "uint64_t BlockchainLMDB::get_block_already_generated_transactions(const uint64_t& height) const", 63 | "{", 64 | " LOG_PRINT_L3(\"BlockchainLMDB::\" << __func__);", 65 | " check_open();", 66 | "", 67 | " TXN_PREFIX_RDONLY();", 68 | " RCURSOR(block_info);", 69 | "", 70 | " MDB_val_set(result, height);", 71 | " auto get_result = mdb_cursor_get(m_cur_block_info, (MDB_val *)&zerokval, &result, MDB_GET_BOTH);", 72 | " if (get_result == MDB_NOTFOUND)", 73 | " {", 74 | " throw0(BLOCK_DNE(std::string(\"Attempt to get generated coins from height \").append(boost::lexical_cast(height)).append(\" failed -- block size not in db\").c_str()));", 75 | " }", 76 | " else if (get_result)", 77 | " throw0(DB_ERROR(\"Error attempting to retrieve a total generated coins from the db\"));", 78 | "", 79 | " mdb_block_info *bi = (mdb_block_info *)result.mv_data;", 80 | " uint64_t ret = bi->bi_txs;", 81 | " TXN_POSTFIX_RDONLY();", 82 | " return ret;", 83 | "}", 84 | "" 85 | ] 86 | } 87 | } 88 | ] 89 | }, 90 | { 91 | "path": "/src/cryptonote_core/blockchain.h", 92 | "changes": [ 93 | { 94 | "action": "add_below", 95 | "marker": "Blockchain(tx_memory_pool& tx_pool);", 96 | "parameters": { 97 | "text": [ 98 | " void get_last_n_blocks_sizes_from_height(size_t h, std::vector& sz, size_t count) const;", 99 | " uint64_t get_block_granted_full_reward_zone_by_block_version(size_t major_version);" 100 | ] 101 | } 102 | } 103 | ] 104 | }, 105 | { 106 | "path": "/src/cryptonote_core/blockchain.cpp", 107 | "changes": [ 108 | { 109 | "action": "add_below", 110 | "marker": "static const uint64_t testnet_hard_fork_version_1_till = 624633;", 111 | "parameters": { 112 | "text": [ 113 | "//------------------------------------------------------------------", 114 | "// get the block sizes of the last blocks, and return by reference with max height .", 115 | "void Blockchain::get_last_n_blocks_sizes_from_height(size_t h, std::vector& sz, size_t count) const", 116 | "{", 117 | " LOG_PRINT_L3(\"Blockchain::\" << __func__);", 118 | " CRITICAL_REGION_LOCAL(m_blockchain_lock);", 119 | "", 120 | " // this function is meaningless for an empty blockchain...granted it should never be empty", 121 | " if(h == 0)", 122 | " return;", 123 | "", 124 | " m_db->block_txn_start(true);", 125 | " // add size of last blocks to vector (or less, if blockchain size < count)", 126 | " size_t start_offset = h - std::min(h, count);", 127 | " for(size_t i = start_offset; i < h; i++)", 128 | " {", 129 | " sz.push_back(m_db->get_block_size(i));", 130 | " }", 131 | " m_db->block_txn_stop();", 132 | "}", 133 | "", 134 | "uint64_t Blockchain::get_block_granted_full_reward_zone_by_block_version(size_t major_version)", 135 | "{", 136 | " uint64_t full_reward_zone = major_version < 2 ? CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 : CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2;", 137 | "", 138 | " return full_reward_zone;", 139 | "}", 140 | "" 141 | ] 142 | } 143 | } 144 | ] 145 | }, 146 | { 147 | "path": "/src/rpc/core_rpc_server.h", 148 | "changes": [ 149 | { 150 | "action": "add_below", 151 | "marker": "MAP_JON_RPC_WE(\"get_version\", on_get_version, COMMAND_RPC_GET_VERSION)", 152 | "parameters": { 153 | "text": [ 154 | " MAP_JON_RPC_WE(\"f_blocks_list_json\", f_on_blocks_list_json, F_COMMAND_RPC_GET_BLOCKS_LIST)", 155 | " MAP_JON_RPC_WE(\"f_block_json\", f_on_block_json, F_COMMAND_RPC_GET_BLOCK_DETAILS)", 156 | " MAP_JON_RPC_WE(\"f_transaction_json\", f_on_transaction_json, F_COMMAND_RPC_GET_TRANSACTION_DETAILS)", 157 | " MAP_JON_RPC_WE(\"f_pool_json\", f_on_transactions_pool_json, F_COMMAND_RPC_GET_POOL)" 158 | ] 159 | } 160 | }, 161 | { 162 | "action": "add_above", 163 | "marker": "private:", 164 | "parameters": { 165 | "text": [ 166 | " bool f_on_blocks_list_json(const F_COMMAND_RPC_GET_BLOCKS_LIST::request& req, F_COMMAND_RPC_GET_BLOCKS_LIST::response& res, epee::json_rpc::error& error_resp);", 167 | " bool f_on_block_json(const F_COMMAND_RPC_GET_BLOCK_DETAILS::request& req, F_COMMAND_RPC_GET_BLOCK_DETAILS::response& res, epee::json_rpc::error& error_resp);", 168 | " bool f_on_transaction_json(const F_COMMAND_RPC_GET_TRANSACTION_DETAILS::request& req, F_COMMAND_RPC_GET_TRANSACTION_DETAILS::response& res, epee::json_rpc::error& error_resp);", 169 | " bool f_on_transactions_pool_json(const F_COMMAND_RPC_GET_POOL::request& req, F_COMMAND_RPC_GET_POOL::response& res, epee::json_rpc::error& error_resp);", 170 | " bool f_getMixin(const transaction& transaction, uint64_t& mixin);", 171 | "" 172 | ] 173 | } 174 | } 175 | ] 176 | }, 177 | { 178 | "path": "/src/rpc/core_rpc_server.cpp", 179 | "changes": [ 180 | { 181 | "action": "add_above", 182 | "marker": "const command_line::arg_descriptor core_rpc_server::arg_rpc_bind_ip = {", 183 | "parameters": { 184 | "text": [ 185 | " bool core_rpc_server::f_on_blocks_list_json(const F_COMMAND_RPC_GET_BLOCKS_LIST::request& req, F_COMMAND_RPC_GET_BLOCKS_LIST::response& res, epee::json_rpc::error& error_resp) {", 186 | " if (m_core.get_current_blockchain_height() <= req.height) {", 187 | " error_resp.code = CORE_RPC_ERROR_CODE_TOO_BIG_HEIGHT;", 188 | " error_resp.message = std::string(\"To big height: \") + std::to_string(req.height) + \", current blockchain height = \" + std::to_string(m_core.get_current_blockchain_height());", 189 | " return false;", 190 | " }", 191 | "", 192 | " uint32_t print_blocks_count = 30;", 193 | " uint32_t last_height = req.height - print_blocks_count;", 194 | " if (req.height <= print_blocks_count) {", 195 | " last_height = 0;", 196 | " }", 197 | "", 198 | " for (uint32_t i = req.height; i >= last_height; i--) {", 199 | " crypto::hash block_hash = m_core.get_block_id_by_height(static_cast(i));", 200 | " block blk;", 201 | " if (!m_core.get_block_by_hash(block_hash, blk)) {", 202 | " error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;", 203 | " error_resp.message = \"Internal error: can't get block by height. Height = \" + std::to_string(i) + '.';", 204 | " return false;", 205 | " }", 206 | "", 207 | " size_t blokBlobSize = m_core.get_blockchain_storage().get_db().get_block_size(i);", 208 | "", 209 | " f_block_short_response block_short;", 210 | " block_short.cumul_size = blokBlobSize;", 211 | " block_short.timestamp = blk.timestamp;", 212 | " block_short.height = i;", 213 | " block_short.hash = string_tools::pod_to_hex(block_hash);", 214 | " block_short.tx_count = blk.tx_hashes.size() + 1;", 215 | "", 216 | " res.blocks.push_back(block_short);", 217 | "", 218 | " if (i == 0)", 219 | " break;", 220 | " }", 221 | "", 222 | " res.status = CORE_RPC_STATUS_OK;", 223 | " return true;", 224 | " }", 225 | "", 226 | " bool core_rpc_server::f_on_block_json(const F_COMMAND_RPC_GET_BLOCK_DETAILS::request& req, F_COMMAND_RPC_GET_BLOCK_DETAILS::response& res, epee::json_rpc::error& error_resp) {", 227 | " crypto::hash hash;", 228 | "", 229 | " if(!check_core_busy())", 230 | " {", 231 | " error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;", 232 | " error_resp.message = \"Core is busy.\";", 233 | " return false;", 234 | " }", 235 | "", 236 | " try {", 237 | " uint32_t height = boost::lexical_cast(req.hash);", 238 | " hash = m_core.get_block_id_by_height(height);", 239 | " } catch (boost::bad_lexical_cast &) {", 240 | " if (!parse_hash256(req.hash, hash)) {", 241 | " error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;", 242 | " error_resp.message = \"Failed to parse hex representation of block hash. Hex = \" + req.hash + '.';", 243 | " return false;", 244 | " }", 245 | " }", 246 | "", 247 | " block blk;", 248 | " if (!m_core.get_block_by_hash(hash, blk)) {", 249 | " error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;", 250 | " error_resp.message = \"Internal error: can't get block by hash. Hash = \" + req.hash + '.';", 251 | " return false;", 252 | " }", 253 | "", 254 | " if (blk.miner_tx.vin.front().type() != typeid(txin_gen)) {", 255 | " error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;", 256 | " error_resp.message = \"Internal error: coinbase transaction in the block has the wrong type\";", 257 | " return false;", 258 | " }", 259 | "", 260 | " block_header_response block_header;", 261 | " res.block.height = boost::get(blk.miner_tx.vin.front()).height;", 262 | " fill_block_header_response(blk, false, res.block.height, hash, block_header);", 263 | "", 264 | " res.block.major_version = block_header.major_version;", 265 | " res.block.minor_version = block_header.minor_version;", 266 | " res.block.timestamp = block_header.timestamp;", 267 | " res.block.prev_hash = block_header.prev_hash;", 268 | " res.block.nonce = block_header.nonce;", 269 | " res.block.hash = string_tools::pod_to_hex(hash);", 270 | " res.block.depth = m_core.get_current_blockchain_height() - res.block.height - 1;", 271 | " res.block.difficulty = m_core.get_blockchain_storage().block_difficulty(static_cast(res.block.height));", 272 | "", 273 | " res.block.reward = block_header.reward;", 274 | "", 275 | " std::vector blocksSizes;", 276 | " m_core.get_blockchain_storage().get_last_n_blocks_sizes_from_height(res.block.height + 1, blocksSizes, CRYPTONOTE_REWARD_BLOCKS_WINDOW);", 277 | " res.block.sizeMedian = epee::misc_utils::median(blocksSizes);", 278 | "", 279 | " uint64_t blockSize = m_core.get_blockchain_storage().get_db().get_block_size(res.block.height);", 280 | " if (!blockSize) {", 281 | " return false;", 282 | " }", 283 | " res.block.blockSize = blockSize;", 284 | "", 285 | " uint64_t alreadyGeneratedCoins = m_core.get_blockchain_storage().get_db().get_block_already_generated_coins(res.block.height);", 286 | " if (!alreadyGeneratedCoins) {", 287 | " return false;", 288 | " }", 289 | " res.block.alreadyGeneratedCoins = std::to_string(alreadyGeneratedCoins);", 290 | "", 291 | " uint64_t alreadyGeneratedTransactions = m_core.get_blockchain_storage().get_db().get_block_already_generated_transactions(res.block.height);", 292 | " if (!alreadyGeneratedTransactions) {", 293 | " return false;", 294 | " }", 295 | " // +1 for coinbase tx", 296 | " res.block.alreadyGeneratedTransactions = alreadyGeneratedTransactions + blk.tx_hashes.size() + 1;", 297 | "", 298 | " uint64_t prevBlockGeneratedCoins = 0;", 299 | " if (res.block.height > 0) {", 300 | " prevBlockGeneratedCoins = m_core.get_blockchain_storage().get_db().get_block_already_generated_coins(res.block.height - 1);", 301 | " if (!prevBlockGeneratedCoins) {", 302 | " return false;", 303 | " }", 304 | " }", 305 | " uint64_t maxReward = 0;", 306 | " uint64_t realReward = 0;", 307 | " int64_t emissionChange = 0;", 308 | " uint64_t blockGrantedFullRewardZone = m_core.get_blockchain_storage().get_block_granted_full_reward_zone_by_block_version(block_header.major_version);", 309 | " res.block.effectiveSizeMedian = std::max(res.block.sizeMedian, blockGrantedFullRewardZone);", 310 | "", 311 | " if (!cryptonote::get_block_reward(0, 0, prevBlockGeneratedCoins, maxReward, res.block.major_version)) {", 312 | " return false;", 313 | " }", 314 | " if (!cryptonote::get_block_reward(res.block.sizeMedian, res.block.blockSize, prevBlockGeneratedCoins, realReward, res.block.major_version)) {", 315 | " return false;", 316 | " }", 317 | "", 318 | " // This is base_reward + tx fees", 319 | " // uint64_t currentReward = get_block_reward(blk);", 320 | "", 321 | " res.block.baseReward = maxReward;", 322 | " if (maxReward == 0 && realReward == 0) {", 323 | " res.block.penalty = static_cast(0);", 324 | " } else {", 325 | " if (maxReward < realReward) {", 326 | " return false;", 327 | " }", 328 | " res.block.penalty = static_cast(maxReward - realReward) / static_cast(maxReward);", 329 | " }", 330 | "", 331 | " res.block.transactionsCumulativeSize = 0;", 332 | "", 333 | " // Base transaction adding", 334 | " f_transaction_short_response transaction_short;", 335 | " transaction_short.hash = string_tools::pod_to_hex(get_transaction_hash(blk.miner_tx));", 336 | " transaction_short.fee = 0;", 337 | " transaction_short.amount_out = get_outs_money_amount(blk.miner_tx);", 338 | " transaction_short.size = get_object_blobsize(blk.miner_tx);", 339 | " res.block.transactions.push_back(transaction_short);", 340 | "", 341 | " res.block.transactionsCumulativeSize += get_object_blobsize(blk.miner_tx);", 342 | "", 343 | " std::list missed_txs;", 344 | " std::list txs;", 345 | " m_core.get_transactions(blk.tx_hashes, txs, missed_txs);", 346 | "", 347 | " res.block.totalFeeAmount = 0;", 348 | "", 349 | " for (const transaction& tx : txs) {", 350 | " f_transaction_short_response transaction_short;", 351 | " uint64_t amount_in = 0;", 352 | " get_inputs_money_amount(tx, amount_in);", 353 | " uint64_t amount_out = get_outs_money_amount(tx);", 354 | "", 355 | " transaction_short.hash = string_tools::pod_to_hex(get_transaction_hash(tx));", 356 | " transaction_short.fee = amount_in - amount_out;", 357 | " transaction_short.amount_out = amount_out;", 358 | " transaction_short.size = get_object_blobsize(tx);", 359 | " res.block.transactions.push_back(transaction_short);", 360 | "", 361 | " res.block.transactionsCumulativeSize += get_object_blobsize(tx);", 362 | " res.block.totalFeeAmount += transaction_short.fee;", 363 | " }", 364 | "", 365 | " res.status = CORE_RPC_STATUS_OK;", 366 | " return true;", 367 | " }", 368 | "", 369 | " bool core_rpc_server::f_on_transaction_json(const F_COMMAND_RPC_GET_TRANSACTION_DETAILS::request& req, F_COMMAND_RPC_GET_TRANSACTION_DETAILS::response& res, epee::json_rpc::error& error_resp) {", 370 | " crypto::hash hash;", 371 | "", 372 | " if (!parse_hash256(req.hash, hash)) {", 373 | " error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;", 374 | " error_resp.message = \"Failed to parse hex representation of transaction hash. Hex = \" + req.hash + '.';", 375 | " return false;", 376 | " }", 377 | "", 378 | " std::vector tx_ids;", 379 | " tx_ids.push_back(hash);", 380 | "", 381 | " std::list missed_txs;", 382 | " std::list txs;", 383 | " m_core.get_transactions(tx_ids, txs, missed_txs);", 384 | "", 385 | " transaction tx;", 386 | "", 387 | " if (1 == txs.size()) {", 388 | " tx = txs.front();", 389 | " } else {", 390 | " error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;", 391 | " error_resp.message = \"transaction wasn't found. Hash = \" + req.hash + '.';", 392 | " return false;", 393 | " }", 394 | "", 395 | " res.tx.version = tx.version;", 396 | " res.tx.unlock_time = tx.unlock_time;", 397 | "", 398 | " for (const txin_v& txin : tx.vin) {", 399 | " if (txin.type() != typeid(txin_to_key)) {", 400 | " continue;", 401 | " }", 402 | " f_tx_vin input;", 403 | " input.amount = boost::get(txin).amount;", 404 | " input.k_image = string_tools::pod_to_hex(boost::get(txin).k_image);", 405 | " res.tx.vin.push_back(input);", 406 | " }", 407 | "", 408 | " for (const tx_out& txout : tx.vout) {", 409 | " f_tx_vout output;", 410 | " output.amount = txout.amount;", 411 | " txout_to_key tx_out_to_key = boost::get(txout.target);", 412 | " output.key = string_tools::pod_to_hex(tx_out_to_key.key);", 413 | " res.tx.vout.push_back(output);", 414 | " }", 415 | "", 416 | " uint32_t blockHeight = m_core.get_blockchain_storage().get_db().get_tx_block_height(hash);", 417 | " crypto::hash blockHash = m_core.get_block_id_by_height(blockHeight);", 418 | " if (blockHeight) {", 419 | " block blk;", 420 | " if (m_core.get_block_by_hash(blockHash, blk)) {", 421 | " uint64_t tx_cumulative_block_size = m_core.get_blockchain_storage().get_db().get_block_size(blockHeight);", 422 | " uint64_t blokBlobSize = get_object_blobsize(blk);", 423 | " uint64_t minerTxBlobSize = get_object_blobsize(blk.miner_tx);", 424 | " f_block_short_response block_short;", 425 | "", 426 | " block_short.cumul_size = blokBlobSize + tx_cumulative_block_size - minerTxBlobSize;", 427 | " block_short.timestamp = blk.timestamp;", 428 | " block_short.height = blockHeight;", 429 | " block_short.hash = string_tools::pod_to_hex(blockHash);", 430 | " block_short.tx_count = blk.tx_hashes.size() + 1;", 431 | " res.block = block_short;", 432 | " }", 433 | " }", 434 | "", 435 | " uint64_t amount_in = 0;", 436 | " get_inputs_money_amount(tx, amount_in);", 437 | " uint64_t amount_out = get_outs_money_amount(tx);", 438 | "", 439 | " crypto::hash tx_hash = get_transaction_hash(tx);", 440 | " res.txDetails.hash = string_tools::pod_to_hex(tx_hash);", 441 | " res.txDetails.fee = amount_in - amount_out;", 442 | " if (amount_in == 0)", 443 | " res.txDetails.fee = 0;", 444 | " res.txDetails.amount_out = amount_out;", 445 | " res.txDetails.size = get_object_blobsize(tx);", 446 | "", 447 | " uint64_t mixin;", 448 | " if (!f_getMixin(tx, mixin)) {", 449 | " return false;", 450 | " }", 451 | " res.txDetails.mixin = mixin;", 452 | "", 453 | " std::vector tx_extra_fields;", 454 | " parse_tx_extra(tx.extra, tx_extra_fields);", 455 | "", 456 | " tx_extra_nonce extra_nonce;", 457 | " crypto::hash paymentId;", 458 | "", 459 | " // EDIT THIS PART FOR ENCRYPTED PAYMENT_ID", 460 | " if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce)) {", 461 | " if (get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, paymentId)) {", 462 | " res.txDetails.paymentId = string_tools::pod_to_hex(paymentId);", 463 | " } else {", 464 | " res.txDetails.paymentId = \"\";", 465 | " }", 466 | " }", 467 | "", 468 | " res.status = CORE_RPC_STATUS_OK;", 469 | " return true;", 470 | " }", 471 | "", 472 | " bool core_rpc_server::f_on_transactions_pool_json(const F_COMMAND_RPC_GET_POOL::request& req, F_COMMAND_RPC_GET_POOL::response& res, epee::json_rpc::error& error_resp) {", 473 | " // res.transactions = m_core.print_pool(true);", 474 | " res.status = CORE_RPC_STATUS_OK;", 475 | " return true;", 476 | " }", 477 | "", 478 | " bool core_rpc_server::f_getMixin(const transaction& transaction, uint64_t& mixin) {", 479 | " mixin = 0;", 480 | " for (const txin_v& txin : transaction.vin) {", 481 | " if (txin.type() != typeid(txin_to_key)) {", 482 | " continue;", 483 | " }", 484 | " uint64_t currentMixin = boost::get(txin).key_offsets.size();", 485 | " if (currentMixin > mixin) {", 486 | " mixin = currentMixin;", 487 | " }", 488 | " }", 489 | " return true;", 490 | " }", 491 | "" 492 | ] 493 | } 494 | } 495 | ] 496 | }, 497 | { 498 | "path": "/src/rpc/core_rpc_server_commands_defs.h", 499 | "changes": [ 500 | { 501 | "action": "add_above", 502 | "marker": "struct COMMAND_RPC_GET_HEIGHT", 503 | "parameters": { 504 | "text": [ 505 | "", 506 | " struct f_transaction_short_response {", 507 | " std::string hash;", 508 | " uint64_t fee;", 509 | " uint64_t amount_out;", 510 | " uint64_t size;", 511 | "", 512 | " BEGIN_KV_SERIALIZE_MAP()", 513 | " KV_SERIALIZE(hash)", 514 | " KV_SERIALIZE(fee)", 515 | " KV_SERIALIZE(amount_out)", 516 | " KV_SERIALIZE(size)", 517 | " END_KV_SERIALIZE_MAP()", 518 | " };", 519 | "", 520 | " struct f_tx_vin", 521 | " {", 522 | " uint64_t amount;", 523 | " std::string k_image;", 524 | "", 525 | " BEGIN_KV_SERIALIZE_MAP()", 526 | " KV_SERIALIZE(amount)", 527 | " KV_SERIALIZE(k_image)", 528 | " END_KV_SERIALIZE_MAP()", 529 | " };", 530 | "", 531 | " struct f_tx_vout", 532 | " {", 533 | " uint64_t amount;", 534 | " std::string key;", 535 | "", 536 | " BEGIN_KV_SERIALIZE_MAP()", 537 | " KV_SERIALIZE(amount)", 538 | " KV_SERIALIZE(key)", 539 | " END_KV_SERIALIZE_MAP()", 540 | " };", 541 | "", 542 | " struct f_transaction {", 543 | " uint64_t version;", 544 | " uint64_t unlock_time;", 545 | " std::vector vin;", 546 | " std::vector vout;", 547 | "", 548 | " BEGIN_KV_SERIALIZE_MAP()", 549 | " KV_SERIALIZE(version)", 550 | " KV_SERIALIZE(unlock_time)", 551 | " KV_SERIALIZE(vin)", 552 | " KV_SERIALIZE(vout)", 553 | " END_KV_SERIALIZE_MAP()", 554 | " };", 555 | "", 556 | " struct f_transaction_details_response {", 557 | " std::string hash;", 558 | " uint64_t size;", 559 | " std::string paymentId;", 560 | " uint64_t mixin;", 561 | " uint64_t fee;", 562 | " uint64_t amount_out;", 563 | "", 564 | " BEGIN_KV_SERIALIZE_MAP()", 565 | " KV_SERIALIZE(hash)", 566 | " KV_SERIALIZE(size)", 567 | " KV_SERIALIZE(paymentId)", 568 | " KV_SERIALIZE(mixin)", 569 | " KV_SERIALIZE(fee)", 570 | " KV_SERIALIZE(amount_out)", 571 | " END_KV_SERIALIZE_MAP()", 572 | " };", 573 | "", 574 | " struct f_block_short_response {", 575 | " uint64_t timestamp;", 576 | " uint32_t height;", 577 | " std::string hash;", 578 | " uint64_t tx_count;", 579 | " uint64_t cumul_size;", 580 | "", 581 | " BEGIN_KV_SERIALIZE_MAP()", 582 | " KV_SERIALIZE(timestamp)", 583 | " KV_SERIALIZE(height)", 584 | " KV_SERIALIZE(hash)", 585 | " KV_SERIALIZE(cumul_size)", 586 | " KV_SERIALIZE(tx_count)", 587 | " END_KV_SERIALIZE_MAP()", 588 | " };", 589 | "", 590 | " struct f_block_details_response {", 591 | " uint8_t major_version;", 592 | " uint8_t minor_version; ", 593 | " uint64_t timestamp;", 594 | " std::string prev_hash;", 595 | " uint32_t nonce;", 596 | " bool orphan_status;", 597 | " uint32_t height;", 598 | " uint64_t depth;", 599 | " std::string hash;", 600 | " uint64_t difficulty;", 601 | " uint64_t reward;", 602 | " uint64_t blockSize;", 603 | " uint64_t sizeMedian;", 604 | " uint64_t effectiveSizeMedian;", 605 | " uint64_t transactionsCumulativeSize;", 606 | " std::string alreadyGeneratedCoins;", 607 | " uint64_t alreadyGeneratedTransactions;", 608 | " uint64_t baseReward;", 609 | " double penalty;", 610 | " uint64_t totalFeeAmount;", 611 | " std::vector transactions;", 612 | "", 613 | " BEGIN_KV_SERIALIZE_MAP()", 614 | " KV_SERIALIZE(major_version)", 615 | " KV_SERIALIZE(minor_version)", 616 | " KV_SERIALIZE(timestamp)", 617 | " KV_SERIALIZE(prev_hash)", 618 | " KV_SERIALIZE(nonce)", 619 | " KV_SERIALIZE(orphan_status)", 620 | " KV_SERIALIZE(height)", 621 | " KV_SERIALIZE(depth)", 622 | " KV_SERIALIZE(hash)", 623 | " KV_SERIALIZE(difficulty)", 624 | " KV_SERIALIZE(reward)", 625 | " KV_SERIALIZE(blockSize)", 626 | " KV_SERIALIZE(sizeMedian)", 627 | " KV_SERIALIZE(effectiveSizeMedian)", 628 | " KV_SERIALIZE(transactionsCumulativeSize)", 629 | " KV_SERIALIZE(alreadyGeneratedCoins)", 630 | " KV_SERIALIZE(alreadyGeneratedTransactions)", 631 | " KV_SERIALIZE(baseReward)", 632 | " KV_SERIALIZE(penalty)", 633 | " KV_SERIALIZE(transactions)", 634 | " KV_SERIALIZE(totalFeeAmount)", 635 | " END_KV_SERIALIZE_MAP()", 636 | " };", 637 | "" 638 | ] 639 | } 640 | }, 641 | { 642 | "action": "add_above", 643 | "marker": "struct COMMAND_RPC_GET_VERSION", 644 | "parameters": { 645 | "text": [ 646 | "struct F_COMMAND_RPC_GET_BLOCKS_LIST {", 647 | " struct request {", 648 | " uint64_t height;", 649 | "", 650 | " BEGIN_KV_SERIALIZE_MAP()", 651 | " KV_SERIALIZE(height)", 652 | " END_KV_SERIALIZE_MAP()", 653 | " };", 654 | "", 655 | " struct response {", 656 | " std::vector blocks; //transactions blobs as hex", 657 | " std::string status;", 658 | "", 659 | " BEGIN_KV_SERIALIZE_MAP()", 660 | " KV_SERIALIZE(blocks)", 661 | " KV_SERIALIZE(status)", 662 | " END_KV_SERIALIZE_MAP()", 663 | " };", 664 | "};", 665 | "", 666 | "struct F_COMMAND_RPC_GET_BLOCK_DETAILS {", 667 | " struct request {", 668 | " std::string hash;", 669 | "", 670 | " BEGIN_KV_SERIALIZE_MAP()", 671 | " KV_SERIALIZE(hash)", 672 | " END_KV_SERIALIZE_MAP()", 673 | " };", 674 | "", 675 | " struct response {", 676 | " f_block_details_response block;", 677 | " std::string status;", 678 | "", 679 | " BEGIN_KV_SERIALIZE_MAP()", 680 | " KV_SERIALIZE(block)", 681 | " KV_SERIALIZE(status)", 682 | " END_KV_SERIALIZE_MAP()", 683 | " };", 684 | "};", 685 | "", 686 | "struct F_COMMAND_RPC_GET_TRANSACTION_DETAILS {", 687 | " struct request {", 688 | " std::string hash;", 689 | "", 690 | " BEGIN_KV_SERIALIZE_MAP()", 691 | " KV_SERIALIZE(hash)", 692 | " END_KV_SERIALIZE_MAP()", 693 | " };", 694 | "", 695 | " struct response {", 696 | " f_transaction tx;", 697 | " f_transaction_details_response txDetails;", 698 | " f_block_short_response block;", 699 | " std::string status;", 700 | "", 701 | " BEGIN_KV_SERIALIZE_MAP()", 702 | " KV_SERIALIZE(tx)", 703 | " KV_SERIALIZE(txDetails)", 704 | " KV_SERIALIZE(block)", 705 | " KV_SERIALIZE(status)", 706 | " END_KV_SERIALIZE_MAP()", 707 | " };", 708 | "};", 709 | "", 710 | "struct F_COMMAND_RPC_GET_POOL {", 711 | " typedef std::vector request;", 712 | "", 713 | " struct response {", 714 | " std::vector transactions; //transactions blobs as hex", 715 | " std::string status;", 716 | "", 717 | " BEGIN_KV_SERIALIZE_MAP()", 718 | " KV_SERIALIZE(transactions)", 719 | " KV_SERIALIZE(status)", 720 | " END_KV_SERIALIZE_MAP()", 721 | " };", 722 | "};", 723 | "" 724 | ] 725 | } 726 | } 727 | ] 728 | }, 729 | { 730 | "path": "/tests/unit_tests/blockchain_db.cpp", 731 | "changes": [ 732 | { 733 | "action": "add_below", 734 | "marker": "ASSERT_EQ(t_coins[0], this->m_db->get_block_already_generated_coins(0));", 735 | "parameters": { 736 | "text": [ 737 | " ASSERT_EQ(t_coins[0], this->m_db->get_block_already_generated_transactions(0));" 738 | ] 739 | } 740 | } 741 | ] 742 | }, 743 | { 744 | "path": "/tests/unit_tests/hardfork.cpp", 745 | "changes": [ 746 | { 747 | "action": "add_below", 748 | "marker": "virtual uint64_t get_block_already_generated_coins(const uint64_t& height) const { return 10000000000; }", 749 | "parameters": { 750 | "text": [ 751 | " virtual uint64_t get_block_already_generated_transactions(const uint64_t& height) const { return 100; }" 752 | ] 753 | } 754 | } 755 | ] 756 | } 757 | ] 758 | } 759 | -------------------------------------------------------------------------------- /extensions/bytecoin-clone.json: -------------------------------------------------------------------------------- 1 | { 2 | "TODO": "Not working. It need a lot of finishing work.", 3 | "file": "bytecoin-clone.json", 4 | "description": "Changes needed to run Bytecoin clone", 5 | "required": [ 6 | "core/monero.json" 7 | ], 8 | "files": [ 9 | { 10 | "path": "/src/cryptonote_config.h", 11 | "changes": [ 12 | { 13 | "action": "add_below", 14 | "marker": "#define CRYPTONOTE_NAME", 15 | "parameters": { 16 | "text": [ 17 | "#define BYTECOIN_CLONE %s" 18 | ], 19 | "text_alt": [ 20 | "#define BYTECOIN_CLONE 0" 21 | ], 22 | "var": "BYTECOIN_CLONE" 23 | } 24 | } 25 | ] 26 | }, 27 | 28 | { 29 | "path": "/src/crypto/hash.h", 30 | "changes": [ 31 | { 32 | "action": "add_above", 33 | "marker": "inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {", 34 | "parameters": { 35 | "text": [ 36 | "inline void tree_branch(const hash *hashes, size_t count, hash *branch) {", 37 | " tree_branch(reinterpret_cast(hashes), count, reinterpret_cast(branch));", 38 | "}", 39 | "", 40 | "inline void tree_hash_from_branch(const hash *branch, size_t depth, const hash &leaf, const void *path, hash &root_hash) {", 41 | " tree_hash_from_branch(reinterpret_cast(branch), depth, reinterpret_cast(&leaf), path, reinterpret_cast(&root_hash));", 42 | "}", 43 | "" 44 | ] 45 | } 46 | } 47 | ] 48 | }, 49 | { 50 | "path": "/src/crypto/hash-ops.h", 51 | "changes": [ 52 | { 53 | "action": "add_above", 54 | "marker": "void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash);", 55 | "parameters": { 56 | "text": [ 57 | "size_t tree_depth(size_t count);", 58 | "void tree_branch(const char (*hashes)[HASH_SIZE], size_t count, char (*branch)[HASH_SIZE]);", 59 | "void tree_hash_from_branch(const char (*branch)[HASH_SIZE], size_t depth, const char *leaf, const void *path, char *root_hash);" 60 | ] 61 | } 62 | } 63 | ] 64 | }, 65 | 66 | 67 | 68 | { 69 | "path": "/src/crypto/tree-hash.c", 70 | "changes": [ 71 | { 72 | "action": "add_above", 73 | "marker": "void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash) {", 74 | "parameters": { 75 | "text": [ 76 | "", 77 | "size_t tree_depth(size_t count) {", 78 | " size_t i;", 79 | " size_t depth = 0;", 80 | " assert(count > 0);", 81 | " for (i = sizeof(size_t) << 2; i > 0; i >>= 1) {", 82 | " if (count >> i > 0) {", 83 | " count >>= i;", 84 | " depth += i;", 85 | " }", 86 | " }", 87 | " return depth;", 88 | "}", 89 | "", 90 | "void tree_branch(const char (*hashes)[HASH_SIZE], size_t count, char (*branch)[HASH_SIZE]) {", 91 | " size_t i, j;", 92 | " size_t cnt = 1;", 93 | " size_t depth = 0;", 94 | " char (*ints)[HASH_SIZE];", 95 | " assert(count > 0);", 96 | " for (i = sizeof(size_t) << 2; i > 0; i >>= 1) {", 97 | " if (cnt << i <= count) {", 98 | " cnt <<= i;", 99 | " depth += i;", 100 | " }", 101 | " }", 102 | " assert(cnt == 1ULL << depth);", 103 | " assert(depth == tree_depth(count));", 104 | " ints = alloca((cnt - 1) * HASH_SIZE);", 105 | " memcpy(ints, hashes + 1, (2 * cnt - count - 1) * HASH_SIZE);", 106 | " for (i = 2 * cnt - count, j = 2 * cnt - count - 1; j < cnt - 1; i += 2, ++j) {", 107 | " cn_fast_hash(hashes[i], 2 * HASH_SIZE, ints[j]);", 108 | " }", 109 | " assert(i == count);", 110 | " while (depth > 0) {", 111 | " assert(cnt == 1ULL << depth);", 112 | " cnt >>= 1;", 113 | " --depth;", 114 | " memcpy(branch[depth], ints[0], HASH_SIZE);", 115 | " for (i = 1, j = 0; j < cnt - 1; i += 2, ++j) {", 116 | " cn_fast_hash(ints[i], 2 * HASH_SIZE, ints[j]);", 117 | " }", 118 | " }", 119 | "}", 120 | "", 121 | "void tree_hash_from_branch(const char (*branch)[HASH_SIZE], size_t depth, const char *leaf, const void *path, char *root_hash) {", 122 | " if (depth == 0) {", 123 | " memcpy(root_hash, leaf, HASH_SIZE);", 124 | " } else {", 125 | " char buffer[2][HASH_SIZE];", 126 | " int from_leaf = 1;", 127 | " char *leaf_path, *branch_path;", 128 | " while (depth > 0) {", 129 | " --depth;", 130 | " if (path && (((const char *) path)[depth >> 3] & (1 << (depth & 7))) != 0) {", 131 | " leaf_path = buffer[1];", 132 | " branch_path = buffer[0];", 133 | " } else {", 134 | " leaf_path = buffer[0];", 135 | " branch_path = buffer[1];", 136 | " }", 137 | " if (from_leaf) {", 138 | " memcpy(leaf_path, leaf, HASH_SIZE);", 139 | " from_leaf = 0;", 140 | " } else {", 141 | " cn_fast_hash(buffer, 2 * HASH_SIZE, leaf_path);", 142 | " }", 143 | " memcpy(branch_path, branch[depth], HASH_SIZE);", 144 | " }", 145 | " cn_fast_hash(buffer, 2 * HASH_SIZE, root_hash);", 146 | " }", 147 | "}", 148 | "" 149 | ] 150 | } 151 | } 152 | ] 153 | }, 154 | { 155 | "path": "/src/cryptonote_basic/cryptonote_format_utils.h", 156 | "changes": [ 157 | { 158 | "action": "add_above", 159 | "marker": "bool add_extra_nonce_to_tx_extra(std::vector& tx_extra, const blobdata& extra_nonce);", 160 | "parameters": { 161 | "text": [ 162 | "bool add_merge_mining_tag_to_tx_extra(std::vector& tx_extra, const tx_extra_merge_mining_tag& mm_tag);", 163 | "bool get_merge_mining_tag_to_tx_extra(std::vector& tx_extra, const tx_extra_merge_mining_tag& mm_tag);" 164 | ] 165 | } 166 | } 167 | ] 168 | }, 169 | { 170 | "path": "/src/cryptonote_basic/cryptonote_format_utils.cpp", 171 | "changes": [ 172 | { 173 | "action": "add_above", 174 | "marker": "bool add_extra_nonce_to_tx_extra(std::vector& tx_extra, const blobdata& extra_nonce)", 175 | "parameters": { 176 | "text": [ 177 | "bool add_merge_mining_tag_to_tx_extra(std::vector& tx_extra, const tx_extra_merge_mining_tag& mm_tag) {", 178 | " const uint8_t* mm_tag_ptr = reinterpret_cast(&mm_tag);", 179 | "", 180 | " tx_extra.push_back(TX_EXTRA_MERGE_MINING_TAG);", 181 | " std::copy(mm_tag_ptr, mm_tag_ptr + sizeof(mm_tag), std::back_inserter(tx_extra));", 182 | " return true;", 183 | "}", 184 | "", 185 | "bool get_merge_mining_tag_to_tx_extra(const std::vector& tx_extra, tx_extra_merge_mining_tag& mm_tag) {", 186 | " std::vector tx_extra_fields;", 187 | " parse_tx_extra(tx_extra, tx_extra_fields);", 188 | "", 189 | " return find_tx_extra_field_by_type(tx_extra_fields, mm_tag);", 190 | "}", 191 | "" 192 | ] 193 | } 194 | } 195 | ] 196 | }, 197 | 198 | { 199 | "path": "/src/cryptonote_basic/cryptonote_boost_serialization.h", 200 | "changes": [ 201 | { 202 | "action": "add_above", 203 | "marker": "#include ", 204 | "parameters": { 205 | "text": [ 206 | "//remove", 207 | " #include " 208 | ] 209 | } 210 | }, 211 | { 212 | "action": "add_above", 213 | "marker": "a & b.major_version;", 214 | "parameters": { 215 | "text": [ 216 | "std::ostream &gout00 = std::cout << \"REALLY HERE: \" << std::endl;" 217 | ] 218 | } 219 | }, 220 | { 221 | "action": "add_above", 222 | "marker": "a & b.miner_tx;", 223 | "parameters": { 224 | "text": [ 225 | "std::ostream &gout01 = std::cout << \"REALLY HERE 2: \" << std::endl;" 226 | ] 227 | } 228 | } 229 | ] 230 | }, 231 | 232 | 233 | { 234 | "path": "/src/cryptonote_basic/cryptonote_basic.h", 235 | "changes": [ 236 | { 237 | "action": "add_above", 238 | "marker": "#include ", 239 | "parameters": { 240 | "text": [ 241 | "//remove", 242 | " #include ", 243 | "#include " 244 | ] 245 | } 246 | }, 247 | { 248 | "action": "add_below", 249 | "marker": "#include \"cryptonote_config.h\"", 250 | "parameters": { 251 | "text": [ 252 | "#include \"cryptonote_basic/cryptonote_format_utils.h\"" 253 | ] 254 | } 255 | }, 256 | { 257 | "action": "replace", 258 | "marker": "block(): block_header(), hash_valid(false) {}", 259 | "parameters": { 260 | "text": [ 261 | "block(): block_header(), parent_block(), hash_valid(false), is_input(true) {}" 262 | ] 263 | } 264 | }, 265 | { 266 | "action": "replace", 267 | "marker": "block(const block &b): block_header(b), hash_valid(false), miner_tx(b.miner_tx), tx_hashes(b.tx_hashes) { if (b.is_hash_valid()) { hash = b.hash; set_hash_valid(true); } }", 268 | "parameters": { 269 | "text": [ 270 | " block(const block &b): block_header(b), hash_valid(false), is_input(false), parent_block(b.parent_block), miner_tx(b.miner_tx), tx_hashes(b.tx_hashes) { if (b.is_hash_valid()) { hash = b.hash; set_hash_valid(true); } }" 271 | ] 272 | } 273 | }, 274 | { 275 | "action": "add_above", 276 | "marker": "struct block_header", 277 | "parameters": { 278 | "text": [ 279 | "struct parent_block", 280 | "{", 281 | " uint8_t major_version;", 282 | " uint8_t minor_version;", 283 | " crypto::hash previous_block_hash;", 284 | " uint16_t transaction_count;", 285 | " std::vector base_transaction_branch;", 286 | " transaction_prefix base_transaction; //base transaction", 287 | " std::vector blockchain_branch;", 288 | "};", 289 | "", 290 | "struct parent_block_serializer {", 291 | " parent_block_serializer(parent_block& _parent_block, uint64_t& _timestamp, uint32_t& _nonce, bool _hashing_serialization, bool _header_only, bool _is_input) :", 292 | " parent_block(_parent_block), timestamp(_timestamp), nonce(_nonce), hashing_serialization(_hashing_serialization), header_only(_header_only, is_input(_is_input)) { }", 293 | "", 294 | " parent_block& parent_block;", 295 | " uint64_t& timestamp;", 296 | " uint32_t& nonce;", 297 | " bool hashing_serialization;", 298 | " bool header_only;", 299 | " bool is_input;", 300 | "", 301 | 302 | 303 | " BEGIN_SERIALIZE()", 304 | " VARINT_FIELD(parent_block.major_version)", 305 | " VARINT_FIELD(parent_block.minor_version)", 306 | " VARINT_FIELD(timestamp)", 307 | " FIELD(parent_block.previous_block_hash)", 308 | " FIELD(nonce)", 309 | 310 | 311 | " if (hashing_serialization) {", 312 | " crypto::hash minerTxHash;", 313 | " if (!get_transaction_hash(parent_block.base_transaction, minerTxHash)) {", 314 | "// throw std::runtime_error(\"Get transaction hash error\");", 315 | " }", 316 | 317 | " crypto::hash merkleRoot;", 318 | " crypto::tree_hash_from_branch(parent_block.base_transaction_branch.data(), parent_block.base_transaction_branch.size(), minerTxHash, 0, merkleRoot);", 319 | " FIELD(merkleRoot)", 320 | " }", 321 | " uint64_t txNum = static_cast(parent_block.transaction_count);", 322 | " VARINT_FIELD(txNum)", 323 | " parent_block.transaction_count = static_cast(txNum);", 324 | " if (parent_block.transaction_count < 1) {", 325 | "// throw std::runtime_error(\"Wrong transactions number\");", 326 | " }", 327 | "", 328 | " if (header_only) {", 329 | " return;", 330 | " }", 331 | "", 332 | " size_t branchSize = crypto::tree_depth(parent_block.transaction_count);", 333 | "// if (serializer.type() == ISerializer::OUTPUT) {", 334 | " if (is_input) {", 335 | " if (parent_block.base_transaction_branch.size() != branchSize) {", 336 | "// throw std::runtime_error(\"Wrong miner transaction branch size\");", 337 | " }", 338 | " } else {", 339 | " parent_block.base_transaction_branch.resize(branchSize);", 340 | " }", 341 | "", 342 | "// serializer(parent_block.base_transaction_branch, \"baseTransactionBranch\");", 343 | " //TODO: Make arrays with computable size! This code won't work with json serialization!", 344 | " for (crypto::hash& hash: parent_block.base_transaction_branch) {", 345 | " FIELD(hash)", 346 | " }", 347 | " FIELD(parent_block.base_transaction)", 348 | "", 349 | " tx_extra_merge_mining_tag mm_tag;", 350 | " if (!get_merge_mining_tag_to_tx_extra(parent_block.base_transaction.extra, mm_tag)) {", 351 | " throw std::runtime_error(\"Can't get extra merge mining tag\");", 352 | " }", 353 | "", 354 | " if (mm_tag.depth > 8 * sizeof(crypto::hash)) {", 355 | " throw std::runtime_error(\"Wrong merge mining tag depth\");", 356 | " }", 357 | "", 358 | "// if (serializer.type() == ISerializer::OUTPUT) {", 359 | " if (is_input) {", 360 | " if (mm_tag.depth != parent_block.base_transaction_branch.size()) {", 361 | " throw std::runtime_error(\"Blockchain branch size must be equal to merge mining tag depth\");", 362 | " }", 363 | " } else {", 364 | " parent_block.base_transaction_branch.resize(mm_tag.depth);", 365 | " }", 366 | "", 367 | "// serializer(parent_block.base_transaction_branch, \"blockchainBranch\");", 368 | " //TODO: Make arrays with computable size! This code won't work with json serialization!", 369 | " for (crypto::hash& hash: parent_block.base_transaction_branch) {", 370 | " FIELD(hash)", 371 | " }", 372 | " END_SERIALIZE()", 373 | "};", 374 | "" 375 | ] 376 | } 377 | }, 378 | { 379 | "action": "add_above", 380 | "marker": "transaction miner_tx;", 381 | "parameters": { 382 | "text": [ 383 | " parent_block parent_block;" 384 | ] 385 | } 386 | }, 387 | { 388 | "action": "add_above", 389 | "marker": "FIELD(miner_tx)", 390 | "parameters": { 391 | "text": [ 392 | "if (major_version >= 2 && BYTECOIN_CLONE == 1) {", 393 | 394 | "std::ostream &gout21 = std::cout << \"major_version: \" << std::to_string(major_version) << std::endl;", 395 | "std::ostream &gout22 = std::cout << \"minor_version: \" << std::to_string(minor_version) << std::endl;", 396 | 397 | 398 | " parent_block_serializer parent_block_serializer = {parent_block, timestamp, nonce, false, false, is_input};", 399 | 400 | "std::ostream &gout11 = std::cout << \"parent_block.major_version: \" << std::to_string(parent_block.major_version) << std::endl;", 401 | "std::ostream &gout12 = std::cout << \"parent_block.minor_version: \" << std::to_string(parent_block.minor_version) << std::endl;", 402 | 403 | "std::ostream &gout01 = std::cout << \"parentBlock.major_version: \" << std::to_string(parent_block_serializer.parent_block.major_version) << std::endl;", 404 | "std::ostream &gout02 = std::cout << \"parentBlock.minor_version: \" << std::to_string(parent_block_serializer.parent_block.minor_version) << std::endl;", 405 | "std::ostream &gout03 = std::cout << \"parentBlock.transaction_count: \" << std::to_string(parent_block_serializer.parent_block.transaction_count) << std::endl;", 406 | "std::ostream &gout1 = std::cout << \"timestamp: \" << parent_block_serializer.timestamp << std::endl;", 407 | "std::ostream &gout2 = std::cout << \"nonce: \" << parent_block_serializer.nonce << std::endl;", 408 | 409 | "struct parent_block_serializer* strucPtr=&parent_block_serializer;", 410 | "unsigned char* charPtr=(unsigned char*)strucPtr;", 411 | "int i;", 412 | "printf(\"structure size : %zu bytes\\n\",sizeof(struct parent_block_serializer));", 413 | "for(i=0;iget_ideal_version();", 432 | "parameters": { 433 | "text": [ 434 | "std::cout << \"BYTECOIN_CLONE: \" << BYTECOIN_CLONE << std::endl;", 435 | "std::cout << \"b.major_version: \" << b.major_version << std::endl;", 436 | "if (b.major_version == 1 && BYTECOIN_CLONE == 1) {", 437 | " // check upgrade height to populate correct minor version", 438 | "} else if (b.major_version >= 2 && BYTECOIN_CLONE == 1) {", 439 | " // check upgrade height to populate correct minor version", 440 | "", 441 | " b.parent_block.major_version = 1;", 442 | " b.parent_block.minor_version = 0;", 443 | " b.parent_block.transaction_count = 1;", 444 | 445 | "std::ostream &gout01 = std::cout << \"b.parent_block.major_version: \" << std::to_string(b.parent_block.major_version) << std::endl;", 446 | "std::ostream &gout02 = std::cout << \"b.parent_block.minor_version: \" << std::to_string(b.parent_block.minor_version) << std::endl;", 447 | 448 | "", 449 | " tx_extra_merge_mining_tag mm_tag = boost::value_initialized();", 450 | " if (!add_merge_mining_tag_to_tx_extra(b.parent_block.base_transaction.extra, mm_tag)) {", 451 | " LOG_ERROR(\"Failed to append merge mining tag to extra of the parent block miner transaction\");", 452 | " return false;", 453 | " }", 454 | "}", 455 | "" 456 | ] 457 | } 458 | } 459 | ] 460 | }, 461 | 462 | { 463 | "path": "/src/cryptonote_basic/cryptonote_basic.h", 464 | "multiline": true, 465 | "changes": [ 466 | { 467 | "action": "replace", 468 | "marker": "(struct block: public block_header)[^@]+(mutable std::atomic hash_valid;)", 469 | "parameters": { 470 | "text": [ 471 | " struct block: public block_header", 472 | " {", 473 | " private:", 474 | " // hash cash", 475 | " mutable std::atomic hash_valid;", 476 | " mutable std::atomic is_input;", 477 | " " 478 | ] 479 | } 480 | } 481 | ] 482 | }, 483 | 484 | { 485 | "path": "/src/cryptonote_basic/cryptonote_basic.h", 486 | "multiline": true, 487 | "changes": [ 488 | { 489 | "action": "replace", 490 | "marker": " (VARINT_FIELD\\(major_version\\))[^@]+(FIELD\\(nonce\\))", 491 | "parameters": { 492 | "text": [ 493 | " VARINT_FIELD(major_version)", 494 | " if (BYTECOIN_CLONE == 1 && major_version > 3) {", 495 | " throw std::runtime_error(\"Wrong major version\");", 496 | " }", 497 | " VARINT_FIELD(minor_version)", 498 | " if (BYTECOIN_CLONE == 0 || (BYTECOIN_CLONE == 1&& major_version == 1)) {", 499 | " VARINT_FIELD(timestamp)", 500 | " FIELD(prev_id)", 501 | " FIELD(nonce)", 502 | " } else if (major_version >= 2) {", 503 | " FIELD(prev_id)", 504 | " } else {", 505 | " throw std::runtime_error(\"Wrong major version\");", 506 | " }" 507 | ] 508 | } 509 | } 510 | ] 511 | } 512 | ] 513 | } 514 | -------------------------------------------------------------------------------- /extensions/core/monero.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "core/monero.json", 3 | "description": "Makes essensial parameters editable.", 4 | "required": [], 5 | "files": [ 6 | { 7 | "path": "/src/cryptonote_config.h", 8 | "changes": [ 9 | { 10 | "action": "replace", 11 | "marker": "#define CRYPTONOTE_NAME", 12 | "parameters": { 13 | "text": [ 14 | "#define CRYPTONOTE_NAME \"%s\"" 15 | ], 16 | "var": "CRYPTONOTE_NAME" 17 | } 18 | }, 19 | { 20 | "action": "replace", 21 | "marker": "uint16_t const P2P_DEFAULT_PORT = 18080;", 22 | "parameters": { 23 | "text": [ 24 | "uint16_t const P2P_DEFAULT_PORT = %s;" 25 | ], 26 | "var": "MAINNET_P2P_DEFAULT_PORT" 27 | } 28 | }, 29 | { 30 | "action": "replace", 31 | "marker": "uint16_t const RPC_DEFAULT_PORT = 18081;", 32 | "parameters": { 33 | "text": [ 34 | "uint16_t const RPC_DEFAULT_PORT = %s;" 35 | ], 36 | "var": "MAINNET_RPC_DEFAULT_PORT" 37 | } 38 | }, 39 | { 40 | "action": "replace", 41 | "marker": "uint16_t const ZMQ_RPC_DEFAULT_PORT = 18082;", 42 | "parameters": { 43 | "text": [ 44 | "uint16_t const ZMQ_RPC_DEFAULT_PORT = %s;" 45 | ], 46 | "var": "MAINNET_ZMQ_RPC_DEFAULT_PORT" 47 | } 48 | }, 49 | 50 | 51 | { 52 | "action": "replace", 53 | "marker": "uint16_t const P2P_DEFAULT_PORT = 28080;", 54 | "parameters": { 55 | "mandatory": false, 56 | "text": [ 57 | "uint16_t const P2P_DEFAULT_PORT = %s;" 58 | ], 59 | "var": "TESTNET_P2P_DEFAULT_PORT" 60 | } 61 | }, 62 | { 63 | "action": "replace", 64 | "marker": "uint16_t const RPC_DEFAULT_PORT = 28081;", 65 | "parameters": { 66 | "mandatory": false, 67 | "text": [ 68 | "uint16_t const RPC_DEFAULT_PORT = %s;" 69 | ], 70 | "var": "TESTNET_RPC_DEFAULT_PORT" 71 | } 72 | }, 73 | { 74 | "action": "replace", 75 | "marker": "uint16_t const ZMQ_RPC_DEFAULT_PORT = 28082;", 76 | "parameters": { 77 | "mandatory": false, 78 | "text": [ 79 | "uint16_t const ZMQ_RPC_DEFAULT_PORT = %s;" 80 | ], 81 | "var": "TESTNET_ZMQ_RPC_DEFAULT_PORT" 82 | } 83 | }, 84 | 85 | 86 | { 87 | "action": "replace", 88 | "marker": "uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 18;", 89 | "parameters": { 90 | "text": [ 91 | "uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = %s;" 92 | ], 93 | "var": "CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX" 94 | } 95 | }, 96 | 97 | { 98 | "action": "replace", 99 | "marker": "uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = 19;", 100 | "parameters": { 101 | "text": [ 102 | "uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = %s;" 103 | ], 104 | "var": "CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX" 105 | } 106 | }, 107 | { 108 | "action": "replace", 109 | "marker": "uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = 42;", 110 | "parameters": { 111 | "text": [ 112 | "uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = %s;" 113 | ], 114 | "var": "CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX" 115 | } 116 | }, 117 | { 118 | "action": "replace", 119 | "marker": "0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x10", 120 | "parameters": { 121 | "text": [ 122 | "%s" 123 | ], 124 | "var": "MAINNET_NETWORK_ID" 125 | } 126 | }, 127 | { 128 | "action": "replace", 129 | "marker": "0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x11", 130 | "parameters": { 131 | "mandatory": false, 132 | "text": [ 133 | "%s" 134 | ], 135 | "var": "TESTNET_NETWORK_ID" 136 | } 137 | }, 138 | { 139 | "action": "replace", 140 | "marker": "std::string const GENESIS_TX = \"013c01ff0001ffffffffffff03029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121017767aafcde9be00dcfd098715ebcf7f410daebc582fda69d24a28e9d0bc890d1\";", 141 | "parameters": { 142 | "text": [ 143 | "std::string const GENESIS_TX = \"%s\";" 144 | ], 145 | "var": "MAINNET_GENESIS_TX" 146 | } 147 | }, 148 | { 149 | "action": "replace", 150 | "marker": " std::string const GENESIS_TX = \"013c01ff0001ffffffffffff03029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121017767aafcde9be00dcfd098715ebcf7f410daebc582fda69d24a28e9d0bc890d1\";", 151 | "parameters": { 152 | "mandatory": false, 153 | "text": [ 154 | "std::string const GENESIS_TX = \"%s\";" 155 | ], 156 | "var": "TESTNET_GENESIS_TX" 157 | } 158 | }, 159 | { 160 | "action": "replace", 161 | "marker": "uint32_t const GENESIS_NONCE = 10000;", 162 | "parameters": { 163 | "mandatory": false, 164 | "text": [ 165 | " uint32_t const GENESIS_NONCE = %s;" 166 | ], 167 | "var": "MAINNET_GENESIS_NONCE" 168 | } 169 | }, 170 | { 171 | "action": "replace", 172 | "marker": " uint32_t const GENESIS_NONCE = 10001;", 173 | "parameters": { 174 | "mandatory": false, 175 | "text": [ 176 | " uint32_t const GENESIS_NONCE = %s;" 177 | ], 178 | "var": "TESTNET_GENESIS_NONCE" 179 | } 180 | }, 181 | { 182 | "action": "replace", 183 | "marker": "#define MONEY_SUPPLY", 184 | "parameters": { 185 | "mandatory": false, 186 | "text": [ 187 | "#define MONEY_SUPPLY ((uint64_t)(%s))" 188 | ], 189 | "var": "MONEY_SUPPLY" 190 | } 191 | }, 192 | { 193 | "action": "replace", 194 | "marker": "#define FINAL_SUBSIDY_PER_MINUTE", 195 | "parameters": { 196 | "mandatory": false, 197 | "text": [ 198 | "#define FINAL_SUBSIDY_PER_MINUTE ((uint64_t)(%s))" 199 | ], 200 | "var": "FINAL_SUBSIDY_PER_MINUTE" 201 | } 202 | }, 203 | { 204 | "action": "replace", 205 | "marker": "#define DIFFICULTY_TARGET_V2", 206 | "parameters": { 207 | "mandatory": false, 208 | "text": [ 209 | "#define DIFFICULTY_TARGET_V2 %s" 210 | ], 211 | "var": "DIFFICULTY_TARGET_V2" 212 | } 213 | }, 214 | { 215 | "action": "replace", 216 | "marker": "#define DIFFICULTY_TARGET_V1", 217 | "parameters": { 218 | "mandatory": false, 219 | "text": [ 220 | "#define DIFFICULTY_TARGET_V1 %s" 221 | ], 222 | "var": "DIFFICULTY_TARGET_V1" 223 | } 224 | }, 225 | { 226 | "action": "replace", 227 | "marker": "#define DIFFICULTY_WINDOW", 228 | "parameters": { 229 | "mandatory": false, 230 | "text": [ 231 | "#define DIFFICULTY_WINDOW %s" 232 | ], 233 | "var": "DIFFICULTY_WINDOW" 234 | } 235 | }, 236 | { 237 | "action": "replace", 238 | "marker": "#define DIFFICULTY_CUT", 239 | "parameters": { 240 | "mandatory": false, 241 | "text": [ 242 | "#define %s" 243 | ], 244 | "var": "DIFFICULTY_CUT" 245 | } 246 | }, 247 | { 248 | "action": "replace", 249 | "marker": "#define DIFFICULTY_LAG", 250 | "parameters": { 251 | "mandatory": false, 252 | "text": [ 253 | "#define DIFFICULTY_LAG %s" 254 | ], 255 | "var": "DIFFICULTY_LAG" 256 | } 257 | }, 258 | { 259 | "action": "replace", 260 | "marker": "#define CRYPTONOTE_DISPLAY_DECIMAL_POINT", 261 | "parameters": { 262 | "mandatory": false, 263 | "text": [ 264 | "#define CRYPTONOTE_DISPLAY_DECIMAL_POINT %s" 265 | ], 266 | "var": "CRYPTONOTE_DISPLAY_DECIMAL_POINT" 267 | } 268 | }, 269 | { 270 | "action": "replace", 271 | "marker": "#define COIN", 272 | "parameters": { 273 | "mandatory": false, 274 | "text": [ 275 | "#define COIN ((uint64_t)(%s))" 276 | ], 277 | "var": "COIN" 278 | } 279 | }, 280 | { 281 | "action": "replace", 282 | "marker": "uint64_t const DEFAULT_DUST_THRESHOLD = ((uint64_t)2000000000);", 283 | "parameters": { 284 | "mandatory": false, 285 | "text": [ 286 | "uint64_t const DEFAULT_DUST_THRESHOLD = ((uint64_t)(%s));" 287 | ], 288 | "var": "DEFAULT_DUST_THRESHOLD" 289 | } 290 | }, 291 | { 292 | "action": "replace", 293 | "marker": "#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 60000", 294 | "parameters": { 295 | "mandatory": false, 296 | "text": [ 297 | "#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 %s" 298 | ], 299 | "var": "CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2" 300 | } 301 | }, 302 | { 303 | "action": "replace", 304 | "marker": "#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 20000", 305 | "parameters": { 306 | "mandatory": false, 307 | "text": [ 308 | "#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 %s" 309 | ], 310 | "var": "CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1" 311 | } 312 | }, 313 | { 314 | "action": "replace", 315 | "marker": "#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5 300000", 316 | "parameters": { 317 | "mandatory": false, 318 | "text": [ 319 | "#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5 %s" 320 | ], 321 | "var": "CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5" 322 | } 323 | }, 324 | { 325 | "action": "replace", 326 | "marker": "#define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW 60", 327 | "parameters": { 328 | "mandatory": false, 329 | "text": [ 330 | "#define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW %s" 331 | ], 332 | "var": "CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW" 333 | } 334 | }, 335 | { 336 | "action": "replace", 337 | "marker": "#define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE 10", 338 | "parameters": { 339 | "mandatory": false, 340 | "text": [ 341 | "#define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE %s" 342 | ], 343 | "var": "CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE" 344 | } 345 | }, 346 | { 347 | "action": "replace", 348 | "marker": "#define EMISSION_SPEED_FACTOR_PER_MINUTE (20)", 349 | "parameters": { 350 | "mandatory": false, 351 | "text": [ 352 | "#define EMISSION_SPEED_FACTOR_PER_MINUTE (%s)" 353 | ], 354 | "var": "EMISSION_SPEED_FACTOR_PER_MINUTE" 355 | } 356 | } 357 | ] 358 | }, 359 | 360 | { 361 | "path": "/src/p2p/net_node.inl", 362 | "multiline": true, 363 | "changes": [ 364 | { 365 | "action": "replace", 366 | "marker": "(std::set full_addrs;)[^@]+(return full_addrs;)", 367 | "parameters": { 368 | "text": [ 369 | "\\1\\n if (nettype == cryptonote::TESTNET) {\\n } else {\\n%MAINNET_SEED_NODES%\\n }\\n \\2" 370 | ] 371 | } 372 | } 373 | ] 374 | }, 375 | { 376 | "path": "/src/p2p/net_node.inl", 377 | "changes": [ 378 | { 379 | "action": "replace", 380 | "marker": "%MAINNET_SEED_NODES%", 381 | "parameters": { 382 | "text": [ 383 | "%s" 384 | ], 385 | "var": "MAINNET_SEED_NODES" 386 | } 387 | } 388 | ] 389 | }, 390 | { 391 | "path": "/src/checkpoints/checkpoints.cpp", 392 | "multiline": true, 393 | "changes": [ 394 | { 395 | "action": "replace", 396 | "marker": "(static const std::vector dns_urls = {)[^}]+(};)", 397 | "parameters": { 398 | "text": [ 399 | "\\1\\n\\2" 400 | ] 401 | } 402 | }, 403 | { 404 | "action": "replace", 405 | "marker": "(static const std::vector testnet_dns_urls = {)[^}]+(};)", 406 | "parameters": { 407 | "text": [ 408 | "\\1\\n\\2" 409 | ] 410 | } 411 | }, 412 | { 413 | "action": "replace", 414 | "marker": "(bool checkpoints::init_default_checkpoints\\(network_type nettype\\))[^@]+(bool checkpoints::load_checkpoints_from_json\\(const std::string &json_hashfile_fullpath\\))", 415 | "parameters": { 416 | "text": [ 417 | "\\1\\n{\\n if (nettype == TESTNET) {\\n return true; \\n} \\nif (nettype == STAGENET) {\\n return true; \\n} \\n%MAINNET_CHECKPOINTS%\\n return true;\\n}\\n\\n\\2" 418 | ] 419 | } 420 | } 421 | ] 422 | }, 423 | { 424 | "path": "/src/checkpoints/checkpoints.cpp", 425 | "changes": [ 426 | { 427 | "action": "replace", 428 | "marker": "%MAINNET_CHECKPOINTS%", 429 | "parameters": { 430 | "text": [ 431 | "%s" 432 | ], 433 | "replace_text_alt": [ 434 | "" 435 | ], 436 | "var": "MAINNET_CHECKPOINTS" 437 | } 438 | } 439 | ] 440 | }, 441 | { 442 | "path": "/src/common/updates.cpp", 443 | "multiline": true, 444 | "changes": [ 445 | { 446 | "action": "replace", 447 | "marker": "(static const std::vector dns_urls = {)[^@]+(};)", 448 | "parameters": { 449 | "text": [ 450 | "\\1\\n\\2" 451 | ] 452 | } 453 | } 454 | ] 455 | }, 456 | 457 | 458 | { 459 | "path": "/src/cryptonote_basic/cryptonote_basic_impl.cpp", 460 | "changes": [ 461 | { 462 | "action": "replace", 463 | "marker": "if (base_reward < FINAL_SUBSIDY_PER_MINUTE*target_minutes)", 464 | "parameters": { 465 | "text": [ 466 | " if (base_reward <= FINAL_SUBSIDY_PER_MINUTE*target_minutes)" 467 | ] 468 | } 469 | } 470 | ] 471 | }, 472 | 473 | { 474 | "path": "/src/cryptonote_core/blockchain.cpp", 475 | "multiline": true, 476 | "changes": [ 477 | { 478 | "action": "replace", 479 | "marker": "(} mainnet_hard_forks\\[\\] = {)[^;]+(};)", 480 | "parameters": { 481 | "text": [ 482 | "\\1\\n%MAINNET_HARDFORKS%\\n\\2" 483 | ] 484 | } 485 | }, 486 | { 487 | "action": "replace", 488 | "marker": "(} testnet_hard_forks\\[\\] = {)[^;]+(};)", 489 | "parameters": { 490 | "text": [ 491 | "\\1\\n%TESTNET_HARDFORKS%\\n\\2" 492 | ] 493 | } 494 | } 495 | ] 496 | }, 497 | { 498 | "path": "/src/cryptonote_core/blockchain.cpp", 499 | "changes": [ 500 | 501 | { 502 | "action": "add_above", 503 | "marker": "bool valid = hash == m_blocks_hash_of_hashes[n];", 504 | "parameters": { 505 | "text": [ 506 | "MWARNING(\"block: \" << height << \" - \" << epee::string_tools::pod_to_hex(hashes.front()));", 507 | "MWARNING(\"block: \" << height + hashes.size() << \" - \" << epee::string_tools::pod_to_hex(hashes.back()));", 508 | "MWARNING(\"first_index: \" << first_index << \" - \" << last_index);" 509 | ] 510 | } 511 | }, 512 | 513 | { 514 | "action": "replace", 515 | "marker": "%MAINNET_HARDFORKS%", 516 | "parameters": { 517 | "text": [ 518 | "%s" 519 | ], 520 | "var": "MAINNET_HARDFORKS" 521 | } 522 | }, 523 | { 524 | "action": "replace", 525 | "marker": "%TESTNET_HARDFORKS%", 526 | "parameters": { 527 | "text": [ 528 | "%s" 529 | ], 530 | "replace_text_alt": [ 531 | "" 532 | ], 533 | "var": "TESTNET_HARDFORKS" 534 | } 535 | }, 536 | { 537 | "action": "replace", 538 | "marker": "static const uint64_t mainnet_hard_fork_version_1_till = 1009826;", 539 | "parameters": { 540 | "text": [ 541 | "static const uint64_t mainnet_hard_fork_version_1_till = ((uint64_t)(%s));" 542 | ], 543 | "var": "MAINNET_HARDFORK_V1_LAST_BLOCK" 544 | } 545 | }, 546 | { 547 | "action": "replace", 548 | "marker": "static const uint64_t testnet_hard_fork_version_1_till = 624633;", 549 | "parameters": { 550 | "text": [ 551 | "static const uint64_t testnet_hard_fork_version_1_till = ((uint64_t)(%s));" 552 | ], 553 | "replace_text_alt": [ 554 | "static const uint64_t testnet_hard_fork_version_1_till = ((uint64_t)(-1));" 555 | ], 556 | "var": "TESTNET_HARDFORK_V1_LAST_BLOCK" 557 | } 558 | }, 559 | { 560 | "action": "replace", 561 | "marker": "LOG_ERROR(\"WARNING: local blockchain failed to pass a MoneroPulse checkpoint, and you could be on a fork. You should either sync up from scratch, OR download a fresh blockchain bootstrap, OR enable checkpoint enforcing with the --enforce-dns-checkpointing command-line option\");", 562 | "parameters": { 563 | "text": [ 564 | " LOG_ERROR(\"WARNING: local blockchain failed to pass a %sPulse checkpoint, and you could be on a fork. You should either sync up from scratch, OR download a fresh blockchain bootstrap, OR enable checkpoint enforcing with the --enforce-dns-checkpointing command-line option\");" 565 | ], 566 | "var": "COIN_NAME" 567 | } 568 | } 569 | ] 570 | }, 571 | { 572 | "path": "/src/blockchain_db/blockchain_db.cpp", 573 | "changes": [ 574 | { 575 | "description": "Monero fixes should apply to Monero only", 576 | "action": "replace", 577 | "marker": "if (height() > 202612)", 578 | "parameters": { 579 | "text": [ 580 | " if (height() > 202612 && strcmp(CRYPTONOTE_NAME, \"monero\")) == 0)" 581 | ] 582 | } 583 | }, 584 | { 585 | "description": "Monero fixes should apply to Monero only", 586 | "action": "replace", 587 | "marker": "if (height() > 685498)", 588 | "parameters": { 589 | "text": [ 590 | " if (height() > 685498 && strcmp(CRYPTONOTE_NAME, \"monero\")) == 0)" 591 | ] 592 | } 593 | } 594 | ] 595 | }, 596 | { 597 | "path": "/src/cryptonote_basic/cryptonote_format_utils.cpp", 598 | "changes": [ 599 | { 600 | "description": "Monero fixes should apply to Monero only", 601 | "action": "replace", 602 | "marker": "if (string_tools::pod_to_hex(block_blob_hash) == correct_blob_hash_202612)", 603 | "parameters": { 604 | "text": [ 605 | " if (string_tools::pod_to_hex(block_blob_hash) == correct_blob_hash_202612 && strcmp(CRYPTONOTE_NAME, \"monero\")) == 0" 606 | ] 607 | } 608 | }, 609 | { 610 | "description": "Monero fixes should apply to Monero only", 611 | "action": "replace", 612 | "marker": "if (string_tools::pod_to_hex(res) == existing_block_id_202612)", 613 | "parameters": { 614 | "text": [ 615 | " if (string_tools::pod_to_hex(res) == existing_block_id_202612 && strcmp(CRYPTONOTE_NAME, \"monero\")) == 0)" 616 | ] 617 | } 618 | } 619 | ] 620 | }, 621 | { 622 | "path": "/src/common/dns_utils.cpp", 623 | "changes": [ 624 | { 625 | "action": "replace", 626 | "marker": "LOG_PRINT_L0(\"WARNING: no two valid MoneroPulse DNS checkpoint records were received\");", 627 | "parameters": { 628 | "text": [ 629 | " LOG_PRINT_L0(\"WARNING: no two valid %sPulse DNS checkpoint records were received\");" 630 | ], 631 | "var": "COIN_NAME" 632 | } 633 | }, 634 | { 635 | "action": "replace", 636 | "marker": "LOG_PRINT_L0(\"WARNING: no two MoneroPulse DNS checkpoint records matched\");", 637 | "parameters": { 638 | "text": [ 639 | " LOG_PRINT_L0(\"WARNING: no two %sPulse DNS checkpoint records matched\");" 640 | ], 641 | "var": "COIN_NAME" 642 | } 643 | } 644 | ] 645 | }, 646 | { 647 | "path": "/src/blocks/blocks.dat", 648 | "action": "remove" 649 | }, 650 | { 651 | "path": "/src/blocks/checkpoints.dat", 652 | "action": "remove" 653 | }, 654 | { 655 | "path": "/src/blocks/testnet_blocks.dat", 656 | "action": "remove" 657 | }, 658 | { 659 | "path": "/src/blocks/blocks.dat", 660 | "action": "add", 661 | "source": "/monero/files/blocks.dat" 662 | }, 663 | { 664 | "path": "/src/blocks/checkpoints.dat", 665 | "action": "add", 666 | "source": "/monero/files/checkpoints.dat" 667 | }, 668 | { 669 | "path": "/src/blocks/testnet_blocks.dat", 670 | "action": "add", 671 | "source": "/monero/files/testnet_blocks.dat" 672 | } 673 | ] 674 | } 675 | -------------------------------------------------------------------------------- /extensions/core/monero/files/blocks.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/forknote/monero-generator/1f9f58b924df539825478ce8af97b3387e7ff76e/extensions/core/monero/files/blocks.dat -------------------------------------------------------------------------------- /extensions/core/monero/files/checkpoints.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/forknote/monero-generator/1f9f58b924df539825478ce8af97b3387e7ff76e/extensions/core/monero/files/checkpoints.dat -------------------------------------------------------------------------------- /extensions/core/monero/files/testnet_blocks.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/forknote/monero-generator/1f9f58b924df539825478ce8af97b3387e7ff76e/extensions/core/monero/files/testnet_blocks.dat -------------------------------------------------------------------------------- /extensions/donations.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "donations.json", 3 | "description": "Donation address for a dev team", 4 | "required": [ 5 | ], 6 | "files": [ 7 | { 8 | "path": "/src/cryptonote_config.h", 9 | "changes": [ 10 | { 11 | "action": "add_below", 12 | "marker": "#define PER_KB_FEE_QUANTIZATION_DECIMALS", 13 | "parameters": { 14 | "text": [ 15 | "#define CONFIG_DONATION_ADDRESS \"%s\"" 16 | ], 17 | "replace_text_alt": [ 18 | "#define CONFIG_DONATION_ADDRESS \"\"" 19 | ], 20 | "var": "CONFIG_DONATION_ADDRESS" 21 | } 22 | } 23 | ] 24 | }, 25 | 26 | { 27 | "path": "/src/cryptonote_basic/miner.cpp", 28 | "changes": [ 29 | { 30 | "action": "add_below", 31 | "marker": "const command_line::arg_descriptor arg_bg_mining_enable = {\"bg-mining-enable\", \"enable/disable background mining\", true, true};", 32 | "parameters": { 33 | "text": [ 34 | "// the 3rd and 4rd parameter are just copy paste. I don't know what they do", 35 | " const command_line::arg_descriptor arg_donate = {\"donate\", \"Enable background donation mining\", true, true};" 36 | ] 37 | } 38 | }, 39 | { 40 | "action": "replace", 41 | "marker": "if(command_line::has_arg(vm, arg_start_mining))", 42 | "parameters": { 43 | "text": [ 44 | " if(command_line::has_arg(vm, arg_start_mining) || command_line::has_arg(vm, arg_donate))" 45 | ] 46 | } 47 | }, 48 | { 49 | "action": "replace", 50 | "marker": "if(!cryptonote::get_account_address_from_str(info, testnet, command_line::get_arg(vm, arg_start_mining)) || info.is_subaddress)", 51 | "parameters": { 52 | "text": [ 53 | " if(command_line::has_arg(vm, arg_donate))", 54 | " {", 55 | " if (!cryptonote::get_account_address_from_str(info, testnet, std::string(CONFIG_DONATION_ADDRESS)))", 56 | " {", 57 | " LOG_ERROR(\"Internal error: malformed donation address\");", 58 | " return false;", 59 | " }", 60 | " }", 61 | " else if(!cryptonote::get_account_address_from_str(info, testnet, command_line::get_arg(vm, arg_start_mining)) || info.is_subaddress)" 62 | ] 63 | } 64 | }, 65 | { 66 | "action": "add_below", 67 | "marker": "command_line::add_arg(desc, arg_bg_mining_enable);", 68 | "parameters": { 69 | "text": [ 70 | " command_line::add_arg(desc, arg_donate);" 71 | ] 72 | } 73 | } 74 | ] 75 | } 76 | ] 77 | } 78 | -------------------------------------------------------------------------------- /extensions/enable-cors.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "enable-cors.json", 3 | "description": "Adds CORS support", 4 | "required": [ 5 | "core/monero.json" 6 | ], 7 | "files": [ 8 | { 9 | "path": "/contrib/epee/include/net/http_server_handlers_map2.h", 10 | "changes": [ 11 | { 12 | "action": "add_below", 13 | "marker": "response.m_response_comment = \"Ok\"; \\", 14 | "parameters": { 15 | "text": [ 16 | " response.m_additional_fields.push_back(std::make_pair(\"Access-Control-Allow-Origin\", \"*\")); \\" 17 | ] 18 | } 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /extensions/versionized-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "versionized-parameters.json", 3 | "description": "Change parameters when hardfork.", 4 | "required": [], 5 | "files": [ 6 | { 7 | "path": "/src/cryptonote_config.h", 8 | "changes": [ 9 | { 10 | "action": "add_below", 11 | "marker": "#define DIFFICULTY_WINDOW 720", 12 | "parameters": { 13 | "text": [ 14 | "#define DIFFICULTY_WINDOW_V2 %s" 15 | ], 16 | "replace_text_alt": [ 17 | "#define DIFFICULTY_WINDOW_V2 DIFFICULTY_WINDOW" 18 | ], 19 | "var": "DIFFICULTY_WINDOW_V2" 20 | } 21 | }, 22 | { 23 | "action": "add_below", 24 | "marker": "#define EMISSION_SPEED_FACTOR_PER_MINUTE (20)", 25 | "parameters": { 26 | "text": [ 27 | "#define EMISSION_SPEED_FACTOR_PER_MINUTE_V2 (%s)" 28 | ], 29 | "replace_text_alt": [ 30 | "#define EMISSION_SPEED_FACTOR_PER_MINUTE_V2 EMISSION_SPEED_FACTOR_PER_MINUTE" 31 | ], 32 | "var": "EMISSION_SPEED_FACTOR_PER_MINUTE_V2" 33 | } 34 | } 35 | ] 36 | }, 37 | { 38 | "path": "/src/cryptonote_config.h", 39 | "changes": [ 40 | { 41 | "action": "add_below", 42 | "marker": "#define DIFFICULTY_WINDOW 720", 43 | "parameters": { 44 | "text": [ 45 | "#define DIFFICULTY_WINDOW_V1 %s" 46 | ], 47 | "replace_text_alt": [ 48 | "#define DIFFICULTY_WINDOW_V1 DIFFICULTY_WINDOW" 49 | ], 50 | "var": "DIFFICULTY_WINDOW_V1" 51 | } 52 | }, 53 | { 54 | "action": "add_below", 55 | "marker": "#define EMISSION_SPEED_FACTOR_PER_MINUTE (20)", 56 | "parameters": { 57 | "text": [ 58 | "#define EMISSION_SPEED_FACTOR_PER_MINUTE_V1 (%s)" 59 | ], 60 | "replace_text_alt": [ 61 | "#define EMISSION_SPEED_FACTOR_PER_MINUTE_V1 EMISSION_SPEED_FACTOR_PER_MINUTE" 62 | ], 63 | "var": "EMISSION_SPEED_FACTOR_PER_MINUTE_V1" 64 | } 65 | } 66 | ] 67 | }, 68 | { 69 | "path": "/src/cryptonote_basic/cryptonote_basic_impl.cpp", 70 | "changes": [ 71 | { 72 | "action": "replace", 73 | "marker": "const int emission_speed_factor = EMISSION_SPEED_FACTOR_PER_MINUTE - (target_minutes-1);", 74 | "parameters": { 75 | "text": [ 76 | "const int emission_speed_factor = version < 2 ? EMISSION_SPEED_FACTOR_PER_MINUTE_V1 - (target_minutes-1) : EMISSION_SPEED_FACTOR_PER_MINUTE_V2 - (target_minutes-1);" 77 | ] 78 | } 79 | } 80 | ] 81 | } 82 | ] 83 | } 84 | -------------------------------------------------------------------------------- /generator.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | 4 | # Bash script for automatic generation and deployment 5 | 6 | # Exit immediately if an error occurs, or if an undeclared variable is used 7 | set -o errexit 8 | 9 | [ "$OSTYPE" != "win"* ] || die "Install MinGW to use on Windows" 10 | 11 | # For bold text 12 | if [ "$OSTYPE" != "msys" ]; then 13 | bold=$(tput bold) 14 | normal=$(tput sgr0) 15 | fi 16 | 17 | # Set directory vars 18 | . "vars.cfg" 19 | 20 | # Perform cleanup on exit 21 | function finish { 22 | # Remove temporary files if exist 23 | echo "Remove temporary files..." 24 | rm -f "${UPDATES_PATH}" 25 | rm -f "${BASH_CONFIG}" 26 | rm -rf "${TEMP_PATH}" 27 | } 28 | trap finish EXIT 29 | 30 | # Generate source code and compile 31 | function generate_coin { 32 | # Define coin paths 33 | export BASE_COIN_PATH="${WORK_FOLDERS_PATH}/${__CONFIG_base_coin_name}" 34 | export NEW_COIN_PATH="${WORK_FOLDERS_PATH}/${__CONFIG_core_CRYPTONOTE_NAME}" 35 | if [ -d "${BASE_COIN_PATH}" ]; then 36 | cd "${BASE_COIN_PATH}" 37 | echo "Updating ${__CONFIG_base_coin_name}..." 38 | git checkout master 39 | git pull 40 | cd "${PROJECT_DIR}" 41 | else 42 | echo "Cloning ${__CONFIG_base_coin_name}..." 43 | git clone "${__CONFIG_base_coin_git}" "${BASE_COIN_PATH}" 44 | fi 45 | 46 | if [[ ! -z $BRANCH ]]; then 47 | cd "${BASE_COIN_PATH}" 48 | git checkout ${BRANCH} 49 | cd "${PROJECT_DIR}" 50 | fi 51 | 52 | # Exit if base coin does not exists 53 | if [ ! -d "${BASE_COIN_PATH}" ]; then 54 | echo "Base coin does not exists" 55 | echo "Abort clone generation" 56 | exit 4 57 | fi 58 | 59 | echo "Make temporary ${__CONFIG_base_coin_name} copy..." 60 | [ -d "${TEMP_PATH}" ] || mkdir -p "${TEMP_PATH}" 61 | cp -af "${BASE_COIN_PATH}/." "${TEMP_PATH}" 62 | cp ${BASE_COIN_PATH}/src/blocks/* ${TEMP_PATH}/src/blocks 63 | 64 | # Extensions 65 | echo "Personalize base coin source..." 66 | export __CONFIG_extensions_text="${__CONFIG_extensions[@]}" 67 | for extension in "${__CONFIG_extensions[@]}" 68 | do 69 | echo "${bold}Execute ${EXTENSIONS_PATH}/${extension}${normal}" 70 | python "lib/file-modification.py" --extension "${EXTENSIONS_PATH}/${extension}" --config=$CONFIG_FILE --source=${TEMP_PATH} 71 | done 72 | 73 | [ -d "${NEW_COIN_PATH}" ] || mkdir -p "${NEW_COIN_PATH}" 74 | 75 | echo "Create patch" 76 | cd "${WORK_FOLDERS_PATH}"; 77 | EXCLUDE_FROM_DIFF="-x '.git'" 78 | if [ -d "${BASE_COIN_PATH}/build" ]; then 79 | EXCLUDE_FROM_DIFF="${EXCLUDE_FROM_DIFF} -x 'build'" 80 | fi 81 | diff -Naur -x .git ${NEW_COIN_PATH##${WORK_FOLDERS_PATH}/} ${TEMP_PATH##${WORK_FOLDERS_PATH}/} > "${UPDATES_PATH}" || [ $? -eq 1 ] 82 | 83 | echo "Apply patch" 84 | [ -d "${NEW_COIN_PATH}" ] || mkdir -p "${NEW_COIN_PATH}" 85 | if [ ! -z "${UPDATES_PATH}" ]; then 86 | # Generate new coin 87 | cd "${NEW_COIN_PATH}" && patch -s -p1 < "${UPDATES_PATH}" && cd "${SCRIPTS_PATH}" 88 | chmod -R 755 ${NEW_COIN_PATH} 89 | cp ${TEMP_PATH}/src/blocks/* ${NEW_COIN_PATH}/src/blocks 90 | 91 | bash "${SCRIPTS_PATH}/compile.sh" -c "${COMPILE_ARGS}" -z 92 | fi 93 | 94 | if [[ ! -z $BRANCH ]]; then 95 | cd "${BASE_COIN_PATH}" 96 | git checkout master 97 | fi 98 | } 99 | 100 | # Usage info 101 | show_help() { 102 | cat << EOF 103 | Usage: ${0##*/} [-h] [-f FILE] [-c ] 104 | Reads a config file and creates and compiles Cryptonote coin. "config.json" as default 105 | 106 | -h display this help and exit 107 | -f config file 108 | -b branch 109 | -c compile arguments 110 | EOF 111 | } 112 | 113 | # A POSIX variable 114 | OPTIND=1 # Reset in case getopts has been used previously in the shell. 115 | 116 | # Initialize our own variables: 117 | CONFIG_FILE='config.json' 118 | COMPILE_ARGS='' 119 | 120 | while getopts "h?f:b:c:" opt; do 121 | case "$opt" in 122 | h|\?) 123 | show_help 124 | exit 0 125 | ;; 126 | f) CONFIG_FILE=${OPTARG} 127 | ;; 128 | b) BRANCH=${OPTARG} 129 | ;; 130 | c) COMPILE_ARGS=${OPTARG} 131 | ;; 132 | esac 133 | done 134 | 135 | shift $((OPTIND-1)) 136 | 137 | # Setting config file 138 | if [[ "${CONFIG_FILE}" != /* ]]; then 139 | CONFIG_FILE="${CONFIG_PATH}/${CONFIG_FILE}" 140 | fi 141 | 142 | if [ ! -f ${CONFIG_FILE} ]; then 143 | echo "ERROR: config file does not exits" 144 | exit 145 | fi 146 | 147 | [ -d "${WORK_FOLDERS_PATH}" ] || mkdir -p "${WORK_FOLDERS_PATH}" 148 | 149 | # Get environment environment_variables 150 | python "lib/environment_variables.py" --config=$CONFIG_FILE --output=$BASH_CONFIG 151 | if [ ! -f ${BASH_CONFIG} ]; then 152 | echo "Config file was not translated to bash." 153 | echo "Abort coin generation" 154 | exit 3 155 | fi 156 | source ${BASH_CONFIG} 157 | 158 | generate_coin 159 | -------------------------------------------------------------------------------- /install_dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Template: OpenBazaar 4 | # 5 | # install_dependencies.sh - Setup your Cryptonote development environment in one step. 6 | # 7 | # This script will only get better as its tested on more development environments 8 | # if you can't modify it to make it better, please open an issue with a full 9 | # error report at https://github.com/forknote/monero-generator.git/issues/new 10 | # 11 | # Credits: Forknote 12 | # 13 | # Code borrowed from: 14 | # https://github.com/OpenBazaar/OpenBazaar/blob/develop/configure.sh 15 | # https://github.com/Quanttek/install_monero/blob/master/install_monero.sh 16 | 17 | #exit on error 18 | set -e 19 | 20 | function command_exists { 21 | # this should be a very portable way of checking if something is on the path 22 | # usage: "if command_exists foo; then echo it exists; fi" 23 | type "$1" &> /dev/null 24 | } 25 | 26 | function brewDoctor { 27 | if ! brew doctor; then 28 | echo "" 29 | echo "'brew doctor' did not exit cleanly! This may be okay. Read above." 30 | echo "" 31 | read -p "Press [Enter] to continue anyway or [ctrl + c] to exit and do what the doctor says..." 32 | fi 33 | } 34 | 35 | function brewUpgrade { 36 | echo "If your homebrew packages are outdated, we recommend upgrading them now. This may take some time." 37 | read -r -p "Do you want to do this? [y/N] " response 38 | if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]] 39 | then 40 | if ! brew upgrade; then 41 | echo "" 42 | echo "There were errors when attempting to 'brew upgrade' and there could be issues with the installation of Cryptonote generator." 43 | echo "" 44 | read -p "Press [Enter] to continue anyway or [ctrl + c] to exit and fix those errors." 45 | fi 46 | fi 47 | } 48 | 49 | function installMac { 50 | # print commands (useful for debugging) 51 | # set -x #disabled because the echos and stdout are verbose enough to see progress 52 | 53 | # install brew if it is not installed, otherwise upgrade it 54 | if ! command_exists brew ; then 55 | echo "installing brew..." 56 | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 57 | else 58 | echo "updating, upgrading, checking brew..." 59 | brew update 60 | brewDoctor 61 | brewUpgrade 62 | brew prune 63 | fi 64 | 65 | # install gpg/sqlite3/python/wget/openssl/zmq if they aren't installed 66 | brew tap jmuncaster/homebrew-header-only 67 | for dep in cmake boost python libevent pkgconfig jmuncaster/header-only/cppzmq 68 | do 69 | if ! command_exists $dep ; then 70 | brew install $dep 71 | fi 72 | done 73 | 74 | doneMessage 75 | } 76 | 77 | function unsupportedOS { 78 | echo "Unsupported OS. Only MacOSX and Ubuntu are supported." 79 | } 80 | 81 | function installUbuntu { 82 | . /etc/lsb-release 83 | 84 | # print commands 85 | set -x 86 | 87 | if [[ $DISTRIB_RELEASE == 16.04* ]] ; then 88 | sudo apt-get update 89 | sudo apt-get -y install build-essential python-dev gcc-4.9 g++-4.9 git cmake pkg-config libboost1.58-all-dev libunbound-dev libevent-dev libssl-dev libzmq3-dev 90 | export CXXFLAGS="-std=gnu++11" 91 | 92 | doneMessage 93 | elif [[ $DISTRIB_RELEASE == 16.10* ]] ; then 94 | sudo apt-get update 95 | sudo apt-get -y install build-essential python-dev gcc-4.9 g++-4.9 git cmake pkg-config libboost1.61-all-dev libunbound-dev libevent-dev libssl-dev 96 | export CXXFLAGS="-std=gnu++11" 97 | 98 | doneMessage 99 | else 100 | echo "Only Ubuntu 16.04 and 16.10 is supported" 101 | fi 102 | } 103 | 104 | function doneMessage { 105 | echo "Cryptonote generator configuration finished." 106 | echo "type 'bash generator.sh [-h] [-f FILE] [-c ]' to generate Cryptonote coin." 107 | } 108 | 109 | if [[ $OSTYPE == darwin* ]] ; then 110 | installMac 111 | elif [[ $OSTYPE == linux-gnu || $OSTYPE == linux-gnueabihf ]]; then 112 | installUbuntu 113 | else 114 | unsupportedOS 115 | fi 116 | -------------------------------------------------------------------------------- /lib/environment_variables.py: -------------------------------------------------------------------------------- 1 | import json 2 | import argparse 3 | import sys 4 | 5 | 6 | def convert_to_bash ( entity, prefix ): 7 | for key, value in entity.iteritems(): 8 | if isinstance(value, dict): 9 | convert_to_bash(entity[key], prefix + key + '_') 10 | elif isinstance(value, list): 11 | print "export " + str(prefix) + str(key) + "=(" + " ".join(json.dumps(str(item)) for item in value) + ")" 12 | elif isinstance(value, int): 13 | print "export " + str(prefix) + str(key) + "=" + str(value) 14 | else: 15 | print "export " + str(prefix) + str(key) + "=" + str(json.dumps(value)) + "" 16 | 17 | parser = argparse.ArgumentParser() 18 | 19 | parser.add_argument('--config', action='store', dest='config_file', 20 | default='config.json', 21 | help='Configuration filename. Format: json' 22 | ) 23 | parser.add_argument('--output', action='store', dest='output', 24 | default='config.cfg', 25 | help='Output path. Format: string' 26 | ) 27 | 28 | args = parser.parse_args() 29 | 30 | json_data=open(args.config_file) 31 | config = json.load(json_data) 32 | json_data.close() 33 | 34 | f = open(args.output, 'w+') 35 | sys.stdout = f 36 | convert_to_bash(config, '__CONFIG_') 37 | sys.stdout = sys.__stdout__ 38 | f.close() 39 | -------------------------------------------------------------------------------- /lib/file-modification.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import fileinput 3 | import fnmatch 4 | import itertools 5 | import json 6 | import os 7 | from stat import * 8 | import re 9 | import shutil 10 | import sys 11 | 12 | 13 | class bcolors: 14 | HEADER = '\033[95m' 15 | OKBLUE = '\033[94m' 16 | OKGREEN = '\033[92m' 17 | WARNING = '\033[93m' 18 | FAIL = '\033[91m' 19 | ENDC = '\033[0m' 20 | BOLD = '\033[1m' 21 | UNDERLINE = '\033[4m' 22 | 23 | reload(sys) 24 | sys.setdefaultencoding('utf8') 25 | 26 | def reverse_enumerate(iterable): 27 | """ 28 | Enumerate over an iterable in reverse order while retaining proper indexes 29 | """ 30 | return itertools.izip(reversed(xrange(len(iterable))), reversed(iterable)) 31 | 32 | def findReplace(directory, find, replace, filePattern): 33 | for path, dirs, files in os.walk(os.path.abspath(directory)): 34 | for filename in fnmatch.filter(files, filePattern): 35 | filepath = os.path.join(path, filename) 36 | stats = os.stat(filepath) 37 | if ".git" in filepath: 38 | continue 39 | with open(filepath) as f: 40 | s = f.read() 41 | s = s.decode('utf-8', errors='ignore').encode('utf-8').replace(find, replace) 42 | with open(filepath, "w") as f: 43 | f.write(s) 44 | 45 | def text_creator(change): 46 | replace_text = '' 47 | if 'var' in change['parameters'].keys(): 48 | if change['parameters']['var'] in config['core'].keys(): 49 | aggregated_var = "" 50 | if 'separator' in change['parameters'].keys(): 51 | for element in config['core'][change['parameters']['var']]: 52 | if 'quote_it' in change['parameters'].keys() and change['parameters']['quote_it'] == True: 53 | aggregated_var += "\"" + element + "\"" 54 | else: 55 | aggregated_var += element 56 | aggregated_var += change['parameters']['separator'] 57 | aggregated_var = aggregated_var[:-len(change['parameters']['separator'])] 58 | else: 59 | aggregated_var = config['core'][change['parameters']['var']] 60 | replace_text = "\n".join(change['parameters']['text']).replace("%s", str(aggregated_var)) + "\n" 61 | elif 'replace_text_alt' in change['parameters'].keys(): 62 | replace_text = '\n'.join(change['parameters']['replace_text_alt']) + "\n" 63 | elif 'mandatory' in change['parameters'].keys() and change['parameters']['mandatory'] == False: 64 | sys.__stdout__.write("NONE\n") 65 | return None 66 | else: 67 | sys.__stdout__.write(bcolors.FAIL + "ERROR: variable is not in the config file - " + change['parameters']['var']+ bcolors.ENDC + "\n") 68 | sys.exit(2) 69 | else: 70 | replace_text = '\n'.join(change['parameters']['text']) + "\n" 71 | 72 | # sys.__stdout__.write("Replace text: " + replace_text + "\n") 73 | return replace_text 74 | 75 | parser = argparse.ArgumentParser() 76 | parser.add_argument('--extension', action='store', dest='extension_file', 77 | help='Extension filename. Format: json' 78 | ) 79 | parser.add_argument('--config', action='store', dest='config_file', 80 | default='config.json', 81 | help='Configuration filename. Format: json' 82 | ) 83 | parser.add_argument('--source', action='store', dest='source', 84 | default='tmp', 85 | help='Working folder containing the base coin source' 86 | ) 87 | args = parser.parse_args() 88 | 89 | try: 90 | extension_json_data = open(args.extension_file) 91 | except IOError as e: 92 | print "I/O error({0}): {1} - {2}".format(e.errno, e.strerror, args.extension_file) 93 | sys.exit(2) 94 | else: 95 | try: 96 | extension = json.load(extension_json_data) 97 | except ValueError as e: 98 | print "Not a valid JSON file: " + args.extension_file 99 | sys.exit(3) 100 | else: 101 | extension_json_data.close() 102 | 103 | try: 104 | config_json_data = open(args.config_file) 105 | except IOError as e: 106 | print "I/O error({0}): {1} - {2}".format(e.errno, e.strerror, args.config_file) 107 | sys.exit(2) 108 | else: 109 | try: 110 | config = json.load(config_json_data) 111 | except ValueError as e: 112 | print "Not a valid JSON file: " + args.config_file 113 | sys.exit(3) 114 | else: 115 | config_json_data.close() 116 | 117 | required_extensions = [i for i in extension['required']] 118 | loaded_extensions = config['extensions'][:(config['extensions'].index(extension['file']))] 119 | 120 | if not (set(required_extensions) <= set(loaded_extensions)): 121 | print bcolors.FAIL + "ERROR: Required extension not loaded: required" + str(required_extensions) + " loaded" + str(loaded_extensions) + bcolors.ENDC + "\n" 122 | exit(3) 123 | 124 | 125 | for file in extension['files']: 126 | # Bulk replace text 127 | 128 | if 'action' in file.keys() and file['action'] == 'bulk_replace': 129 | if 'find' in file.keys() and 'replace' in file.keys() and 'file_pattern' in file.keys(): 130 | sys.__stdout__.write("- Bulk replacing " + file['find'] + " with " + file['replace'] + "\n") 131 | findReplace(args.source, file['find'], file['replace'], file['file_pattern']) 132 | else: 133 | sys.__stdout__.write(bcolors.FAIL + "ERROR: find, replace and file_pattern are mandatory with bulk_replace" + bcolors.ENDC + "\n") 134 | exit(4) 135 | continue 136 | 137 | # Add new file to output source 138 | if 'action' in file.keys() and 'source' in file.keys() and file['action'] == 'add': 139 | source_path = os.path.dirname(os.path.realpath(args.extension_file)) + file['source'] 140 | if (os.path.isfile(source_path)): 141 | sys.__stdout__.write("- Adding file " + source_path + "\n") 142 | shutil.copyfile(source_path,args.source + file['path']) 143 | else: 144 | sys.__stdout__.write(bcolors.FAIL + "ERROR: file does not exists - " + source_path + bcolors.ENDC + "\n") 145 | exit(4) 146 | continue 147 | 148 | # Remove file from base repository 149 | if 'action' in file.keys() and 'path' in file.keys() and file['action'] == 'remove': 150 | path = args.source + file['path'] 151 | if (os.path.isfile(path)): 152 | sys.__stdout__.write("- Removing file " + path + "\n") 153 | os.remove(path) 154 | else: 155 | sys.__stdout__.write(bcolors.FAIL + "ERROR: file does not exists - " + path + bcolors.ENDC + "\n") 156 | exit(4) 157 | continue 158 | 159 | 160 | # If multiline, get the whole file 161 | if 'multiline' in file.keys() and file['multiline'] == True: 162 | work_file = open(args.source + file['path'], 'r') 163 | work_file_content = work_file.read() 164 | work_file.close() 165 | 166 | # Start pre-tests 167 | sys.__stdout__.write("- Making pre-tests in file " + args.source + file['path'] + "\n") 168 | changes = list(file['changes']) 169 | for index, change in reverse_enumerate(changes): 170 | TEMPLATE_re = re.compile(r"%s" % change['marker'], re.MULTILINE) 171 | match = TEMPLATE_re.search(work_file_content) 172 | if match: 173 | sys.__stdout__.write(" + Pretest: marker exists - " + change['marker'] + "\n") 174 | del changes[index] 175 | 176 | for index, change in reverse_enumerate(changes): 177 | if 'may_not_exist' in change and change['may_not_exist']: 178 | sys.__stdout__.write(bcolors.WARNING + "WARNING: marker not found - " + change['marker'] + bcolors.ENDC + "\n") 179 | del changes[index] 180 | 181 | for change in changes: 182 | sys.__stdout__.write(bcolors.FAIL + "ERROR: marker not found - " + change['marker'] + bcolors.ENDC + "\n") 183 | sys.exit(2) 184 | # End pre-tests 185 | 186 | sys.__stdout__.write("- Making changes in file " + args.source + file['path'] + "\n") 187 | changes = list(file['changes']) 188 | for change in changes: 189 | sys.__stdout__.write(" + Replaced text at marker: " + change['marker'] + "\n") 190 | replace_text = text_creator(change) 191 | if replace_text is not None: 192 | TEMPLATE_re = re.compile(r"%s" % change['marker'], re.DOTALL) 193 | work_file_content = TEMPLATE_re.sub(replace_text, work_file_content) + "\n" 194 | 195 | work_file = open(args.source + file['path'], "w") 196 | work_file.write(work_file_content) 197 | work_file.close() 198 | # If not multiline - check line by line 199 | else: 200 | # Start pre-tests 201 | sys.__stdout__.write("- Making pre-tests in file " + args.source + file['path'] + "\n") 202 | changes = list(file['changes']) 203 | for line in fileinput.input([args.source + file['path']], inplace=True): 204 | for index, change in reverse_enumerate(changes): 205 | if change['marker'] in line: 206 | sys.__stdout__.write(" + Pretest: marker exists - " + change['marker'] + "\n") 207 | del changes[index] 208 | sys.stdout.write(line) 209 | 210 | for index, change in reverse_enumerate(changes): 211 | if 'may_not_exist' in change and change['may_not_exist']: 212 | sys.__stdout__.write(bcolors.WARNING + "WARNING: marker not found - " + change['marker'] + bcolors.ENDC + "\n") 213 | del changes[index] 214 | 215 | for change in changes: 216 | sys.__stdout__.write(bcolors.FAIL + "ERROR: marker not found - " + change['marker'] + bcolors.ENDC + "\n") 217 | sys.exit(2) 218 | # End pre-tests 219 | 220 | 221 | sys.__stdout__.write("- Making changes in file " + args.source + file['path'] + "\n") 222 | changes = list(file['changes']) 223 | for line in fileinput.input([args.source + file['path']], inplace=True): 224 | add_after_line = "" 225 | delete_line = False 226 | for change in changes: 227 | if change['action'] == "replace": 228 | if change['marker'] in line: 229 | sys.__stdout__.write(" + Replacing line at marker: " + change['marker'] + "\n") 230 | replace_text = text_creator(change) 231 | if replace_text is not None: 232 | line = replace_text 233 | if change['action'] == "add_above": 234 | if change['marker'] in line: 235 | sys.__stdout__.write(" + Added text before marker: " + change['marker'] + "\n") 236 | replace_text = text_creator(change) 237 | if replace_text is not None: 238 | add_before_line = replace_text 239 | sys.stdout.write(replace_text) 240 | if change['action'] == "delete": 241 | if change['marker'] in line: 242 | sys.__stdout__.write(" + Delete line at marker: " + change['marker'] + "\n") 243 | delete_line = True 244 | if change['action'] == "add_below": 245 | if change['marker'] in line: 246 | sys.__stdout__.write(" + Added text after marker: " + change['marker'] + "\n") 247 | replace_text = text_creator(change) 248 | if replace_text is not None: 249 | add_after_line = replace_text 250 | 251 | if delete_line != True: 252 | sys.stdout.write(line) 253 | if add_after_line != "": 254 | sys.stdout.write(add_after_line) 255 | -------------------------------------------------------------------------------- /vars.cfg: -------------------------------------------------------------------------------- 1 | export PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 2 | export WORK_FOLDERS_PATH="${PROJECT_DIR}/generated_files" 3 | export SCRIPTS_PATH="${PROJECT_DIR}" 4 | export EXTENSIONS_PATH="${SCRIPTS_PATH}/extensions" 5 | export TESTS_PATH="${SCRIPTS_PATH}/tests" 6 | export CONFIG_PATH="${SCRIPTS_PATH}" 7 | export TEMP_PATH="${WORK_FOLDERS_PATH}/tmp" 8 | export UPDATES_PATH="${WORK_FOLDERS_PATH}/updates.forknote.monero.patch" 9 | export BASH_CONFIG="${WORK_FOLDERS_PATH}/config.cfg" 10 | 11 | export CUSTOM_CUSTOMIZE_SCRIPT_PATH="${SCRIPTS_PATH}/custom/customize.sh" 12 | export CUSTOM_CUSTOMIZE_TESTS_PATH="${SCRIPTS_PATH}/custom/customize-test.sh" 13 | export CUSTOM_GENERATE_SCRIPT_PATH="${SCRIPTS_PATH}/custom/generate.sh" 14 | --------------------------------------------------------------------------------