From 091cb0ee0593467c62d91225482d8d857ae399a7 Mon Sep 17 00:00:00 2001 From: zachhildreth Date: Wed, 24 Nov 2021 19:41:07 -0800 Subject: [PATCH 01/10] fix: dpops testnet code dpops testnet code --- src/cryptonote_config.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index db6a330429d..611200fec97 100755 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -191,11 +191,11 @@ // Seed Nodes -#define SEED_NODE_1 "us1.xcash.foundation:18280" -#define SEED_NODE_2 "europe1.xcash.foundation:18280" -#define SEED_NODE_3 "europe2.xcash.foundation:18280" -#define SEED_NODE_4 "europe3.xcash.foundation:18280" -#define SEED_NODE_5 "oceania1.xcash.foundation:18280" +#define SEED_NODE_1 "dpops-test-1.xcash.foundation:18280" +#define SEED_NODE_2 "dpops-test-2.xcash.foundation:18280" +#define SEED_NODE_3 "dpops-test-3.xcash.foundation:18280" +#define SEED_NODE_4 "dpops-test-4.xcash.foundation:18280" +#define SEED_NODE_5 "dpops-test-5.xcash.foundation:18280" /*#define SEED_NODE_1 "192.168.1.201:18280" #define SEED_NODE_2 "192.168.1.202:18280" @@ -217,7 +217,7 @@ full_addrs.insert(SEED_NODE_5); // Blockchain #define HF_VERSION_PROOF_OF_STAKE 13 -#define HF_BLOCK_HEIGHT_PROOF_OF_STAKE 800000 // The first block of the X-CASH proof of stake +#define HF_BLOCK_HEIGHT_PROOF_OF_STAKE 880000 // The first block of the X-CASH proof of stake #define BLOCK_TIME 5 // the block time in minutes #define BLOCKS_PER_DAY_FIVE_MINUTE_BLOCK_TIME 288 // The blocks per day with a 5 minute block time #define MAXIMUM_RESERVE_BYTES_LEGNTH 4096 // The maximum size in bytes for the reserve bytes in the block header @@ -260,16 +260,16 @@ full_addrs.insert(SEED_NODE_5); // Network data nodes #define NETWORK_DATA_NODES_AMOUNT 5 // The amount of network data nodes -#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_1 "XCA1a9usG2UKajV1Dqzp8fL1BbN3hzuaaJMYjCo7qDoC4C3Vvc5owiLAqKbVw2cRbwRqx3mgrau1Z7LkX6cxR2NC4ZmFBLe2Mf" -#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_2 "XCA1YhckQgqGQvMsS2xi4n3cHBPo39WYFC1AXskqaFB87Q6EX5LheKK6E3ZqQmD9CDFX8br8Mfvff7RqT6UcuUja46qKC1vEJb" -#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_3 "XCA1c2ahjRvBsp35ynTknNYczj9y42hN9ht1vNyns2FCTU4qbLqahtsTw2E7JTKLd3ecSGLe2zWJgCiwrMhecsbT38i3Smy9vW" -#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_4 "XCA1jN7CNCKEN1kDuqxiuUPyKWiVp68RsYxshdohaQ1k8NN11ZWX9dSJv3hx6qxfPaKVAnet4LTda9fsK81c9wRN5Aj78KyZEg" -#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_5 "XCA1hKDayQXECEA5Yja4a8CU6Suoo9XT9jET7Ng2Rx2z3fLsGy5iVQCL9hWWTi3TroJxihWY4j84n9WMJvpFvagW5hMNpq1jh9" -#define NETWORK_DATA_NODE_IP_ADDRESS_1 "us1.xcash.foundation" -#define NETWORK_DATA_NODE_IP_ADDRESS_2 "europe1.xcash.foundation" -#define NETWORK_DATA_NODE_IP_ADDRESS_3 "europe2.xcash.foundation" -#define NETWORK_DATA_NODE_IP_ADDRESS_4 "europe3.xcash.foundation" -#define NETWORK_DATA_NODE_IP_ADDRESS_5 "oceania1.xcash.foundation" +#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_1 "XCA1Sk2CRVQ9EoKzkv2mnzfAwgA4zvj2HfXJrzYYCtJAdLXDPuSr1UGEJPKSTGCan9fmNpqTGefkMGZ4JX3zUf357vm5VMzMir" +#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_2 "XCA1tDjMy6UCGfC5tCpRF6U7NZNFWrSdMbF9FrE4HdoXHGRSr3NJgHdicsdV6c6tsvRU2NmGYsAGf19VNWVhkrL73XH3AKx9Dw" +#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_3 "XCA1sLyHMW23w238zJdZJVWVfMZMYyMxW9ypPVSLyduk7Ee4UtCbXMG7yJzqaT7vP24jq4ceC5F8PFTjPZEYTrKb6DdfbaLTAa" +#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_4 "XCA1dYZmCGMFnmYppTHtWoQNB168NAjHmiU9WdWsB4mXiytoHiMyrYqYYBcHwewiLhYj6eij4r8BRSScNYphZRtz8RajVriGZC" +#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_5 "XCA1rgiYYcY1k37GBiWz5PiUbB7SzvVGqPiLoBCyHdmAN8hfs47N7ZzFWZrJsTy8Lj4QKh1fFLdr2SNVebqimW7j24J9dsWBhM" +#define NETWORK_DATA_NODE_IP_ADDRESS_1 "dpops-test-1.xcash.foundation" +#define NETWORK_DATA_NODE_IP_ADDRESS_2 "dpops-test-2.xcash.foundation" +#define NETWORK_DATA_NODE_IP_ADDRESS_3 "dpops-test-3.xcash.foundation" +#define NETWORK_DATA_NODE_IP_ADDRESS_4 "dpops-test-4.xcash.foundation" +#define NETWORK_DATA_NODE_IP_ADDRESS_5 "dpops-test-5.xcash.foundation" /*#define NETWORK_DATA_NODE_PUBLIC_ADDRESS_1 "XCA1pEWxj2q7gn7TJjae7JfsDhtnhydxsHhtADhDm4LbdE11rHVZqbX5MPGZ9tM7jQbDF4VKK89jSAqgL9Nxxjdh8RM5JEpZZP" #define NETWORK_DATA_NODE_PUBLIC_ADDRESS_2 "XCA1VSDHKCc4Qhvqb3fquebSYxfMeyGteQeAYtDSpaTcgquBY1bkKWtQ42tZG2w7Ak7GyqnaiTgWL4bMHE9Lwd2A3g2Recxz7B" @@ -321,7 +321,7 @@ namespace config uint16_t const RPC_DEFAULT_PORT = 18281; uint16_t const ZMQ_RPC_DEFAULT_PORT = 18282; boost::uuids::uuid const NETWORK_ID = { { - 0x10 ,0x10, 0x41, 0x53 , 0x48, 0x62 , 0x41, 0x65, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x10 + 0x10 ,0x10, 0x41, 0x53 , 0x48, 0x62 , 0x25, 0x65, 0x17, 0x31, 0x00, 0x82, 0x35, 0xA1, 0xA1, 0x10 } }; std::string const GENESIS_TX = "013c01ff0001b197bcc5c605029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd0880712101f1dde8d8d6c53e9d2e920d6e66432eaff6a85b2d25043fc29ef477b075b143df"; uint32_t const GENESIS_NONCE = 10000; From 8353c0975cbf44dea638bd92b84b64d2064e5df9 Mon Sep 17 00:00:00 2001 From: Zach Hildreth <41015215+zachhildreth@users.noreply.github.com> Date: Thu, 2 Dec 2021 10:55:08 -0800 Subject: [PATCH 02/10] Updated hashes Updated hashes --- src/cryptonote_core/blockchain.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index d91b0e1255e..0ebecf67276 100755 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -3965,6 +3965,10 @@ void check_data_hash(const std::size_t current_block_height,std::string &data_ha { data_hash = "b8276ef2194b7f7c2f3e28070ad5cf8292efbd20b502dc2dbcdc3e45d43fa84580dacc21065790fa224198d86f858add12eabbc6f38575a9f4d0d06ea4f9b781"; } + else if (current_block_height == 878085 && data_hash == "68ca7556a872231f5573c4a087b5e7b357cd552650a1ba0b675c6f79b6e6361739300200bf6062285872f9c26908fa5204ddb11aaa3ec59dbadaf6c4a6e2a17f") + { + data_hash = "bd8659d8e169b97e705cfbd2d0f1b882713a3a4cdba2a2ca2a76f44974d3bed66389d2d33027083bd1cdbacc15c17a392ca85cf42ec21afca40a6f5075c8e99e"; + } } bool verify_network_block(std::vector &block_verifiers_database_hashes, std::vector &block_verifiers_stealth_addresses, const block bl,const std::size_t current_block_height) From 64b4361862b22fea7cf410945d228ed4f6e43933 Mon Sep 17 00:00:00 2001 From: Zach Hildreth <41015215+zachhildreth@users.noreply.github.com> Date: Thu, 9 Dec 2021 09:34:16 -0800 Subject: [PATCH 03/10] Update cryptonote_config.h --- src/cryptonote_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 611200fec97..ab40f3c01bb 100755 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -321,7 +321,7 @@ namespace config uint16_t const RPC_DEFAULT_PORT = 18281; uint16_t const ZMQ_RPC_DEFAULT_PORT = 18282; boost::uuids::uuid const NETWORK_ID = { { - 0x10 ,0x10, 0x41, 0x53 , 0x48, 0x62 , 0x25, 0x65, 0x17, 0x31, 0x00, 0x82, 0x35, 0xA1, 0xA1, 0x10 + 0x10 ,0x11, 0x41, 0x52 , 0x48, 0x62 , 0x25, 0x65, 0x17, 0x31, 0x00, 0x82, 0x35, 0xA1, 0xA1, 0x10 } }; std::string const GENESIS_TX = "013c01ff0001b197bcc5c605029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd0880712101f1dde8d8d6c53e9d2e920d6e66432eaff6a85b2d25043fc29ef477b075b143df"; uint32_t const GENESIS_NONCE = 10000; From ec0cf406368dc3f93e606424a7ddba1d1681cd32 Mon Sep 17 00:00:00 2001 From: Zach Hildreth <41015215+zachhildreth@users.noreply.github.com> Date: Thu, 9 Dec 2021 10:04:57 -0800 Subject: [PATCH 04/10] change testnet to v14 We cant do the same v13 as mainnet due to the mainnet already being on v13 so the blocks copied from mainnet wont work. so we change the dpops testnet to v14 --- src/cryptonote_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index ab40f3c01bb..83e2341ae04 100755 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -216,7 +216,7 @@ full_addrs.insert(SEED_NODE_5); // XCASH DPOPS // Blockchain -#define HF_VERSION_PROOF_OF_STAKE 13 +#define HF_VERSION_PROOF_OF_STAKE 14 #define HF_BLOCK_HEIGHT_PROOF_OF_STAKE 880000 // The first block of the X-CASH proof of stake #define BLOCK_TIME 5 // the block time in minutes #define BLOCKS_PER_DAY_FIVE_MINUTE_BLOCK_TIME 288 // The blocks per day with a 5 minute block time From 86cb5d63b764382b72d3051bd5bf94c43be40b81 Mon Sep 17 00:00:00 2001 From: Zach Hildreth <41015215+zachhildreth@users.noreply.github.com> Date: Thu, 9 Dec 2021 10:11:32 -0800 Subject: [PATCH 05/10] change dpops testnet to v14 --- src/cryptonote_core/blockchain.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 0ebecf67276..a8371fa0b0d 100755 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -129,9 +129,13 @@ static const struct { // version 12 starts from block 281000, which is on or around Feb 15, 2019. This version changes the proof of work algorithm to Cryptonight HeavyX and changes the block time to 2 minutes. { 12, 281000, 0, 1549310115 }, + + // version 13 starts from block 800000, which is on or around Feb 04, 2021. This version changes the consensus mechanism from proof of work to delegated proof of privacy stake (DPOPS), changes the block time from 2 to 5 minutes, and double the block reward. + { 13, 800000, 0, 1561310115 }, - // version 13 starts from block 440875, which is on or around Feb 15, 2019. This version changes the consensus mechanism from proof of work to delegated proof of privacy stake (DPOPS), changes the block time from 2 to 5 minutes, and double the block reward. - { 13, HF_BLOCK_HEIGHT_PROOF_OF_STAKE, 0, 1561310115 }, + // version 14 starts from block 880000, which is on or around Jan 08, 2022. This version is dpops testnet + { 14, HF_BLOCK_HEIGHT_PROOF_OF_STAKE, 0, 1601310115 }, + }; static const uint64_t mainnet_hard_fork_version_1_till = 1; From 42eaad317d12895cda552316be2fb36f3f11fffc Mon Sep 17 00:00:00 2001 From: Zach Hildreth <41015215+zachhildreth@users.noreply.github.com> Date: Tue, 4 Jan 2022 15:24:05 -0800 Subject: [PATCH 06/10] Change testnet number of delegates Changed from 27/50 to 17/30 --- src/cryptonote_config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 83e2341ae04..da90ad922a5 100755 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -248,8 +248,8 @@ full_addrs.insert(SEED_NODE_5); // XCASH DPOPS #define BLOCK_VERIFIERS_TOTAL_AMOUNT 100 // The total amount of block verifiers -#define BLOCK_VERIFIERS_AMOUNT 50 // The amount of block verifiers in a round -#define BLOCK_VERIFIERS_VALID_AMOUNT 27 // The amount of block verifiers that need to vote true for the part of the round to be valid. +#define BLOCK_VERIFIERS_AMOUNT 30 // The amount of block verifiers in a round +#define BLOCK_VERIFIERS_VALID_AMOUNT 17 // The amount of block verifiers that need to vote true for the part of the round to be valid. #define BLOCK_VERIFIERS_VALID_AMOUNT_PERCENTAGE 0.55 // The amount of block verifiers in a percentage that need to vote true for the part of the round to be valid. From 269534b6c798b71bbbb3333c2d85b9b72e7d0e32 Mon Sep 17 00:00:00 2001 From: zachhildreth Date: Wed, 2 Feb 2022 18:10:23 -0800 Subject: [PATCH 07/10] fix: general update Fixed issue where loop for picking random network data node, would freeze if all network data nodes were down. Fixes #23 from the community issues. --- src/cryptonote_core/blockchain.cpp | 6 ++++++ src/simplewallet/simplewallet.cpp | 18 ++++++++++++++++++ src/wallet/api/wallet.cpp | 18 ++++++++++++++++++ src/wallet/wallet_rpc_server.cpp | 18 ++++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index a8371fa0b0d..1b4c2a84fd9 100755 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -4087,6 +4087,12 @@ bool get_network_block_database_hash(std::vector &block_verifiers_d // send the message to a random network data node for (count = 0; string.find("|") == std::string::npos && count < NETWORK_DATA_NODES_AMOUNT; count++) { + // check if they need to reset the network_data_nodes_array + if (network_data_nodes_array[NETWORK_DATA_NODES_AMOUNT-1] != 0) + { + std::fill(network_data_nodes_array, network_data_nodes_array+NETWORK_DATA_NODES_AMOUNT, 0); + } + do { // get a random network data node diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 12fe1efc408..58457651af5 100755 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -2318,6 +2318,12 @@ std::string get_current_block_verifiers_list() // send the message to a random network data node for (count = 0; string.find("|") == std::string::npos && count < NETWORK_DATA_NODES_AMOUNT; count++) { + // check if they need to reset the network_data_nodes_array + if (network_data_nodes_array[NETWORK_DATA_NODES_AMOUNT-1] != 0) + { + std::fill(network_data_nodes_array, network_data_nodes_array+NETWORK_DATA_NODES_AMOUNT, 0); + } + do { // get a random network data node @@ -3014,6 +3020,12 @@ bool simple_wallet::vote_status(const std::vector& args) // send the message to a random network data node for (count = 0; string.find("delegate_name: ") == std::string::npos && count < NETWORK_DATA_NODES_AMOUNT; count++) { + // check if they need to reset the network_data_nodes_array + if (network_data_nodes_array[NETWORK_DATA_NODES_AMOUNT-1] != 0) + { + std::fill(network_data_nodes_array, network_data_nodes_array+NETWORK_DATA_NODES_AMOUNT, 0); + } + do { // get a random network data node @@ -3128,6 +3140,12 @@ bool simple_wallet::revote(const std::vector& args) // send the message to a random network data node for (count = 0; string.find("delegate_name: ") == std::string::npos && count < NETWORK_DATA_NODES_AMOUNT; count++) { + // check if they need to reset the network_data_nodes_array + if (network_data_nodes_array[NETWORK_DATA_NODES_AMOUNT-1] != 0) + { + std::fill(network_data_nodes_array, network_data_nodes_array+NETWORK_DATA_NODES_AMOUNT, 0); + } + do { // get a random network data node diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 38941e869d6..94963f5f16a 100755 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -2363,6 +2363,12 @@ std::string get_current_block_verifiers_list() // send the message to a random network data node for (count = 0; string.find("|") == std::string::npos && count < NETWORK_DATA_NODES_AMOUNT; count++) { + // check if they need to reset the network_data_nodes_array + if (network_data_nodes_array[NETWORK_DATA_NODES_AMOUNT-1] != 0) + { + std::fill(network_data_nodes_array, network_data_nodes_array+NETWORK_DATA_NODES_AMOUNT, 0); + } + do { // get a random network data node @@ -2878,6 +2884,12 @@ std::string WalletImpl::vote_status() { // send the message to a random network data node for (count = 0; string.find("delegate_name: ") == std::string::npos && count < NETWORK_DATA_NODES_AMOUNT; count++) { + // check if they need to reset the network_data_nodes_array + if (network_data_nodes_array[NETWORK_DATA_NODES_AMOUNT-1] != 0) + { + std::fill(network_data_nodes_array, network_data_nodes_array+NETWORK_DATA_NODES_AMOUNT, 0); + } + do { // get a random network data node @@ -2971,6 +2983,12 @@ std::string WalletImpl::revote() { // send the message to a random network data node for (count = 0; string.find("delegate_name: ") == std::string::npos && count < NETWORK_DATA_NODES_AMOUNT; count++) { + // check if they need to reset the network_data_nodes_array + if (network_data_nodes_array[NETWORK_DATA_NODES_AMOUNT-1] != 0) + { + std::fill(network_data_nodes_array, network_data_nodes_array+NETWORK_DATA_NODES_AMOUNT, 0); + } + do { // get a random network data node diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 69f8618a9ea..365db28364f 100755 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -3443,6 +3443,12 @@ std::string get_current_block_verifiers_list() // send the message to a random network data node for (count = 0; string.find("|") == std::string::npos && count < NETWORK_DATA_NODES_AMOUNT; count++) { + // check if they need to reset the network_data_nodes_array + if (network_data_nodes_array[NETWORK_DATA_NODES_AMOUNT-1] != 0) + { + std::fill(network_data_nodes_array, network_data_nodes_array+NETWORK_DATA_NODES_AMOUNT, 0); + } + do { // get a random network data node @@ -4092,6 +4098,12 @@ bool wallet_rpc_server::on_vote_status(const wallet_rpc::COMMAND_RPC_VOTE_STATUS // send the message to a random network data node for (count = 0; string.find("delegate_name: ") == std::string::npos && count < NETWORK_DATA_NODES_AMOUNT; count++) { + // check if they need to reset the network_data_nodes_array + if (network_data_nodes_array[NETWORK_DATA_NODES_AMOUNT-1] != 0) + { + std::fill(network_data_nodes_array, network_data_nodes_array+NETWORK_DATA_NODES_AMOUNT, 0); + } + do { // get a random network data node @@ -4208,6 +4220,12 @@ bool wallet_rpc_server::on_revote(const wallet_rpc::COMMAND_RPC_REVOTE::request& // send the message to a random network data node for (count = 0; string.find("delegate_name: ") == std::string::npos && count < NETWORK_DATA_NODES_AMOUNT; count++) { + // check if they need to reset the network_data_nodes_array + if (network_data_nodes_array[NETWORK_DATA_NODES_AMOUNT-1] != 0) + { + std::fill(network_data_nodes_array, network_data_nodes_array+NETWORK_DATA_NODES_AMOUNT, 0); + } + do { // get a random network data node From 6487afcc5fc84949ef901c027b8d70bbb0379651 Mon Sep 17 00:00:00 2001 From: zachhildreth Date: Wed, 2 Feb 2022 22:22:12 -0800 Subject: [PATCH 08/10] fix: remove most mining code Removed most mining code, as some is still needed for producing blocks or deep function calls in core (you would need to rewrite functions). Will still try again to remove all, but this is pass 1 and we can test and see if antiviruses still pickup the program as a potential virus. Fixes #25 from the community request. --- src/cryptonote_basic/miner.cpp | 1 + src/cryptonote_core/cryptonote_core.h | 14 +-- src/daemon/command_parser_executor.cpp | 106 ------------------- src/daemon/command_parser_executor.h | 4 - src/daemon/command_server.cpp | 11 -- src/daemon/daemon.cpp | 2 - src/daemon/rpc_command_executor.cpp | 60 ----------- src/daemon/rpc_command_executor.h | 4 - src/rpc/core_rpc_server.cpp | 99 +---------------- src/rpc/core_rpc_server.h | 6 -- src/rpc/daemon_handler.cpp | 84 --------------- src/rpc/daemon_handler.h | 6 -- src/rpc/daemon_messages.cpp | 87 --------------- src/rpc/daemon_messages.h | 30 ------ src/simplewallet/simplewallet.cpp | 89 ---------------- src/simplewallet/simplewallet.h | 2 - src/wallet/api/wallet_manager.cpp | 48 --------- src/wallet/wallet_rpc_server.cpp | 51 +-------- src/wallet/wallet_rpc_server.h | 4 - src/wallet/wallet_rpc_server_commands_defs.h | 37 ------- 20 files changed, 5 insertions(+), 740 deletions(-) diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp index 14e59858933..d7efd2a9165 100755 --- a/src/cryptonote_basic/miner.cpp +++ b/src/cryptonote_basic/miner.cpp @@ -1067,3 +1067,4 @@ namespace cryptonote return boost::logic::tribool(boost::logic::indeterminate); } } + diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index a9ea5acb632..a06c18543c1 100755 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -219,19 +219,7 @@ namespace cryptonote virtual void on_transaction_relayed(const cryptonote::blobdata& tx); - /** - * @brief gets the miner instance - * - * @return a reference to the miner instance - */ - miner& get_miner(){return m_miner;} - - /** - * @brief gets the miner instance (const) - * - * @return a const reference to the miner instance - */ - const miner& get_miner()const{return m_miner;} + /** * @brief adds command line options to the given options set diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 9c2e3394ba7..e13989d048c 100755 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -261,112 +261,6 @@ bool t_command_parser_executor::print_transaction_pool_stats(const std::vector& args) -{ - if(!args.size()) - { - std::cout << "Please specify a wallet address to mine for: start_mining []" << std::endl; - return true; - } - - cryptonote::address_parse_info info; - cryptonote::network_type nettype = cryptonote::MAINNET; - if(!cryptonote::get_account_address_from_str(info, cryptonote::MAINNET, args.front())) - { - if(!cryptonote::get_account_address_from_str(info, cryptonote::TESTNET, args.front())) - { - if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, args.front())) - { - bool dnssec_valid; - std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(args.front(), dnssec_valid, - [](const std::string &url, const std::vector &addresses, bool dnssec_valid){return addresses[0];}); - if(!cryptonote::get_account_address_from_str(info, cryptonote::MAINNET, address_str)) - { - if(!cryptonote::get_account_address_from_str(info, cryptonote::TESTNET, address_str)) - { - if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, address_str)) - { - std::cout << "target account address has wrong format" << std::endl; - return true; - } - else - { - nettype = cryptonote::STAGENET; - } - } - else - { - nettype = cryptonote::TESTNET; - } - } - } - else - { - nettype = cryptonote::STAGENET; - } - } - else - { - nettype = cryptonote::TESTNET; - } - } - if (info.is_subaddress) - { - tools::fail_msg_writer() << "subaddress for mining reward is not yet supported!" << std::endl; - return true; - } - if(nettype != cryptonote::MAINNET) - std::cout << "Mining to a " << (nettype == cryptonote::TESTNET ? "testnet" : "stagenet") << " address, make sure this is intentional!" << std::endl; - uint64_t threads_count = 1; - bool do_background_mining = false; - bool ignore_battery = false; - if(args.size() > 4) - { - return false; - } - - if(args.size() == 4) - { - if(args[3] == "true" || command_line::is_yes(args[3]) || args[3] == "1") - { - ignore_battery = true; - } - else if(args[3] != "false" && !command_line::is_no(args[3]) && args[3] != "0") - { - return false; - } - } - - if(args.size() >= 3) - { - if(args[2] == "true" || command_line::is_yes(args[2]) || args[2] == "1") - { - do_background_mining = true; - } - else if(args[2] != "false" && !command_line::is_no(args[2]) && args[2] != "0") - { - return false; - } - } - - if(args.size() >= 2) - { - bool ok = epee::string_tools::get_xtype_from_string(threads_count, args[1]); - threads_count = (ok && 0 < threads_count) ? threads_count : 1; - } - - m_executor.start_mining(info.address, threads_count, nettype, do_background_mining, ignore_battery); - - return true; -} - -bool t_command_parser_executor::stop_mining(const std::vector& args) -{ - if (!args.empty()) return false; - - return m_executor.stop_mining(); -} - bool t_command_parser_executor::stop_daemon(const std::vector& args) { if (!args.empty()) return false; diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h index 82538690e30..8995f9a0d6c 100755 --- a/src/daemon/command_parser_executor.h +++ b/src/daemon/command_parser_executor.h @@ -93,10 +93,6 @@ class t_command_parser_executor final bool print_transaction_pool_stats(const std::vector& args); - bool start_mining(const std::vector& args); - - bool stop_mining(const std::vector& args); - bool stop_daemon(const std::vector& args); bool print_status(const std::vector& args); diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index a629f903442..9b3c4198228 100755 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -100,17 +100,6 @@ t_command_server::t_command_server( , "is_key_image_spent " , "Print whether a given key image is in the spent key images set." ); - m_command_lookup.set_handler( - "start_mining" - , std::bind(&t_command_parser_executor::start_mining, &m_parser, p::_1) - , "start_mining [] [do_background_mining] [ignore_battery]" - , "Start mining for specified address. Defaults to 1 thread and no background mining." - ); - m_command_lookup.set_handler( - "stop_mining" - , std::bind(&t_command_parser_executor::stop_mining, &m_parser, p::_1) - , "Stop mining." - ); m_command_lookup.set_handler( "print_pool" , std::bind(&t_command_parser_executor::print_transaction_pool_long, &m_parser, p::_1) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 0f5192f1a9f..c5b4b27d615 100755 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -198,7 +198,6 @@ bool t_daemon::run(bool interactive) for(auto& rpc : mp_internals->rpcs) rpc->stop(); - mp_internals->core.get().get_miner().stop(); MGINFO("Node stopped."); return true; } @@ -220,7 +219,6 @@ void t_daemon::stop() { throw std::runtime_error{"Can't stop stopped daemon"}; } - mp_internals->core.get().get_miner().stop(); mp_internals->p2p.stop(); for(auto& rpc : mp_internals->rpcs) rpc->stop(); diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index 5e14be6a2a3..aa51c8b52eb 100755 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -424,11 +424,6 @@ bool t_rpc_command_executor::show_status() { tools::fail_msg_writer() << make_error(fail_message, hfres.status); return true; } - if (!m_rpc_server->on_mining_status(mreq, mres)) - { - tools::fail_msg_writer() << fail_message.c_str(); - return true; - } if (mres.status == CORE_RPC_STATUS_BUSY) { @@ -1071,61 +1066,6 @@ bool t_rpc_command_executor::print_transaction_pool_stats() { return true; } -bool t_rpc_command_executor::start_mining(cryptonote::account_public_address address, uint64_t num_threads, cryptonote::network_type nettype, bool do_background_mining, bool ignore_battery) { - cryptonote::COMMAND_RPC_START_MINING::request req; - cryptonote::COMMAND_RPC_START_MINING::response res; - req.miner_address = cryptonote::get_account_address_as_str(nettype, false, address); - req.threads_count = num_threads; - req.do_background_mining = do_background_mining; - req.ignore_battery = ignore_battery; - - std::string fail_message = "Mining did not start"; - - if (m_is_rpc) - { - if (m_rpc_client->rpc_request(req, res, "/start_mining", fail_message.c_str())) - { - tools::success_msg_writer() << "Mining started"; - } - } - else - { - if (!m_rpc_server->on_start_mining(req, res) || res.status != CORE_RPC_STATUS_OK) - { - tools::fail_msg_writer() << make_error(fail_message, res.status); - return true; - } - } - - return true; -} - -bool t_rpc_command_executor::stop_mining() { - cryptonote::COMMAND_RPC_STOP_MINING::request req; - cryptonote::COMMAND_RPC_STOP_MINING::response res; - - std::string fail_message = "Mining did not stop"; - - if (m_is_rpc) - { - if (!m_rpc_client->rpc_request(req, res, "/stop_mining", fail_message.c_str())) - { - return true; - } - } - else - { - if (!m_rpc_server->on_stop_mining(req, res) || res.status != CORE_RPC_STATUS_OK) - { - tools::fail_msg_writer() << make_error(fail_message, res.status); - return true; - } - } - - tools::success_msg_writer() << "Mining stopped"; - return true; -} - bool t_rpc_command_executor::stop_daemon() { cryptonote::COMMAND_RPC_STOP_DAEMON::request req; diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h index 40df71fd681..2a88b000c38 100755 --- a/src/daemon/rpc_command_executor.h +++ b/src/daemon/rpc_command_executor.h @@ -105,10 +105,6 @@ class t_rpc_command_executor final { bool print_transaction_pool_stats(); - bool start_mining(cryptonote::account_public_address address, uint64_t num_threads, cryptonote::network_type nettype, bool do_background_mining = false, bool ignore_battery = false); - - bool stop_mining(); - bool stop_daemon(); bool print_status(); diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index b39726159f0..ab6128978c1 100755 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -755,93 +755,7 @@ namespace cryptonote //TODO: make sure that tx has reached other nodes here, probably wait to receive reflections from other nodes res.status = CORE_RPC_STATUS_OK; return true; - } - //------------------------------------------------------------------------------------------------------------------------------ - bool core_rpc_server::on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res) - { - PERF_TIMER(on_start_mining); - CHECK_CORE_READY(); - cryptonote::address_parse_info info; - if(!get_account_address_from_str(info, m_nettype, req.miner_address)) - { - res.status = "Failed, wrong address"; - LOG_PRINT_L0(res.status); - return true; - } - if (info.is_subaddress) - { - res.status = "Mining to subaddress isn't supported yet"; - LOG_PRINT_L0(res.status); - return true; - } - - unsigned int concurrency_count = boost::thread::hardware_concurrency() * 4; - - // if we couldn't detect threads, set it to a ridiculously high number - if(concurrency_count == 0) - { - concurrency_count = 257; - } - - // if there are more threads requested than the hardware supports - // then we fail and log that. - if(req.threads_count > concurrency_count) - { - res.status = "Failed, too many threads relative to CPU cores."; - LOG_PRINT_L0(res.status); - return true; - } - - boost::thread::attributes attrs; - attrs.set_stack_size(THREAD_STACK_SIZE); - - cryptonote::miner &miner= m_core.get_miner(); - if (miner.is_mining()) - { - res.status = "Already mining"; - return true; - } - if(!miner.start(info.address, static_cast(req.threads_count), attrs, req.do_background_mining, req.ignore_battery)) - { - res.status = "Failed, mining not started"; - LOG_PRINT_L0(res.status); - return true; - } - res.status = CORE_RPC_STATUS_OK; - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ - bool core_rpc_server::on_stop_mining(const COMMAND_RPC_STOP_MINING::request& req, COMMAND_RPC_STOP_MINING::response& res) - { - PERF_TIMER(on_stop_mining); - if(!m_core.get_miner().stop()) - { - res.status = "Failed, mining not stopped"; - LOG_PRINT_L0(res.status); - return true; - } - res.status = CORE_RPC_STATUS_OK; - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ - bool core_rpc_server::on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res) - { - PERF_TIMER(on_mining_status); - - const miner& lMiner = m_core.get_miner(); - res.active = lMiner.is_mining(); - res.is_background_mining_enabled = lMiner.get_is_background_mining_enabled(); - - if ( lMiner.is_mining() ) { - res.speed = lMiner.get_speed(); - res.threads_count = lMiner.get_threads_count(); - const account_public_address& lMiningAdr = lMiner.get_mining_address(); - res.address = get_account_address_as_str(m_nettype, false, lMiningAdr); - } - - res.status = CORE_RPC_STATUS_OK; - return true; - } + } //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_save_bc(const COMMAND_RPC_SAVE_BC::request& req, COMMAND_RPC_SAVE_BC::response& res) { @@ -888,15 +802,7 @@ namespace cryptonote bool core_rpc_server::on_set_log_hash_rate(const COMMAND_RPC_SET_LOG_HASH_RATE::request& req, COMMAND_RPC_SET_LOG_HASH_RATE::response& res) { PERF_TIMER(on_set_log_hash_rate); - if(m_core.get_miner().is_mining()) - { - m_core.get_miner().do_print_hashrate(req.visible); - res.status = CORE_RPC_STATUS_OK; - } - else - { - res.status = CORE_RPC_STATUS_NOT_MINING; - } + res.status = CORE_RPC_STATUS_NOT_MINING; return true; } //------------------------------------------------------------------------------------------------------------------------------ @@ -1228,7 +1134,6 @@ namespace cryptonote error_resp.message = "Wrong block blob"; return false; } - miner::find_nonce_for_given_block(b, template_res.difficulty, template_res.height); submit_req.front() = string_tools::buff_to_hex_nodelimer(block_to_blob(b)); r = on_submitblock(submit_req, submit_res, error_resp); diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h index d9bee963a3b..b94781c1659 100755 --- a/src/rpc/core_rpc_server.h +++ b/src/rpc/core_rpc_server.h @@ -95,9 +95,6 @@ namespace cryptonote MAP_URI_AUTO_JON2("/is_key_image_spent", on_is_key_image_spent, COMMAND_RPC_IS_KEY_IMAGE_SPENT) MAP_URI_AUTO_JON2("/send_raw_transaction", on_send_raw_tx, COMMAND_RPC_SEND_RAW_TX) MAP_URI_AUTO_JON2("/sendrawtransaction", on_send_raw_tx, COMMAND_RPC_SEND_RAW_TX) - MAP_URI_AUTO_JON2_IF("/start_mining", on_start_mining, COMMAND_RPC_START_MINING, !m_restricted) - MAP_URI_AUTO_JON2_IF("/stop_mining", on_stop_mining, COMMAND_RPC_STOP_MINING, !m_restricted) - MAP_URI_AUTO_JON2_IF("/mining_status", on_mining_status, COMMAND_RPC_MINING_STATUS, !m_restricted) MAP_URI_AUTO_JON2_IF("/save_bc", on_save_bc, COMMAND_RPC_SAVE_BC, !m_restricted) MAP_URI_AUTO_JON2_IF("/get_peer_list", on_get_peer_list, COMMAND_RPC_GET_PEER_LIST, !m_restricted) MAP_URI_AUTO_JON2_IF("/set_log_hash_rate", on_set_log_hash_rate, COMMAND_RPC_SET_LOG_HASH_RATE, !m_restricted) @@ -165,9 +162,6 @@ namespace cryptonote bool on_is_key_image_spent(const COMMAND_RPC_IS_KEY_IMAGE_SPENT::request& req, COMMAND_RPC_IS_KEY_IMAGE_SPENT::response& res, bool request_has_rpc_origin = true); bool on_get_indexes(const COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::request& req, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::response& res); bool on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res); - bool on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res); - bool on_stop_mining(const COMMAND_RPC_STOP_MINING::request& req, COMMAND_RPC_STOP_MINING::response& res); - bool on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res); bool on_get_outs_bin(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req, COMMAND_RPC_GET_OUTPUTS_BIN::response& res); bool on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res); bool on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res); diff --git a/src/rpc/daemon_handler.cpp b/src/rpc/daemon_handler.cpp index 509f2dfc0e5..6b5d5886169 100755 --- a/src/rpc/daemon_handler.cpp +++ b/src/rpc/daemon_handler.cpp @@ -348,56 +348,6 @@ namespace rpc return; } - void DaemonHandler::handle(const StartMining::Request& req, StartMining::Response& res) - { - cryptonote::address_parse_info info; - if(!get_account_address_from_str(info, m_core.get_nettype(), req.miner_address)) - { - res.error_details = "Failed, wrong address"; - LOG_PRINT_L0(res.error_details); - res.status = Message::STATUS_FAILED; - return; - } - if (info.is_subaddress) - { - res.error_details = "Failed, mining to subaddress isn't supported yet"; - LOG_PRINT_L0(res.error_details); - res.status = Message::STATUS_FAILED; - return; - } - - unsigned int concurrency_count = boost::thread::hardware_concurrency() * 4; - - // if we couldn't detect threads, set it to a ridiculously high number - if(concurrency_count == 0) - { - concurrency_count = 257; - } - - // if there are more threads requested than the hardware supports - // then we fail and log that. - if(req.threads_count > concurrency_count) - { - res.error_details = "Failed, too many threads relative to CPU cores."; - LOG_PRINT_L0(res.error_details); - res.status = Message::STATUS_FAILED; - return; - } - - boost::thread::attributes attrs; - attrs.set_stack_size(THREAD_STACK_SIZE); - - if(!m_core.get_miner().start(info.address, static_cast(req.threads_count), attrs, req.do_background_mining, req.ignore_battery)) - { - res.error_details = "Failed, mining not started"; - LOG_PRINT_L0(res.error_details); - res.status = Message::STATUS_FAILED; - return; - } - res.status = Message::STATUS_OK; - res.error_details = ""; - - } void DaemonHandler::handle(const GetInfo::Request& req, GetInfo::Response& res) { @@ -442,37 +392,6 @@ namespace rpc res.error_details = ""; } - void DaemonHandler::handle(const StopMining::Request& req, StopMining::Response& res) - { - if(!m_core.get_miner().stop()) - { - res.error_details = "Failed, mining not stopped"; - LOG_PRINT_L0(res.error_details); - res.status = Message::STATUS_FAILED; - return; - } - - res.status = Message::STATUS_OK; - res.error_details = ""; - } - - void DaemonHandler::handle(const MiningStatus::Request& req, MiningStatus::Response& res) - { - const cryptonote::miner& lMiner = m_core.get_miner(); - res.active = lMiner.is_mining(); - res.is_background_mining_enabled = lMiner.get_is_background_mining_enabled(); - - if ( lMiner.is_mining() ) { - res.speed = lMiner.get_speed(); - res.threads_count = lMiner.get_threads_count(); - const account_public_address& lMiningAdr = lMiner.get_mining_address(); - res.address = get_account_address_as_str(m_core.get_nettype(), false, lMiningAdr); - } - - res.status = Message::STATUS_OK; - res.error_details = ""; - } - void DaemonHandler::handle(const SaveBC::Request& req, SaveBC::Response& res) { if (!m_core.get_blockchain_storage().store_blockchain()) @@ -788,9 +707,6 @@ namespace rpc REQ_RESP_TYPES_MACRO(request_type, GetTxGlobalOutputIndices, req_json, resp_message, handle); REQ_RESP_TYPES_MACRO(request_type, SendRawTx, req_json, resp_message, handle); REQ_RESP_TYPES_MACRO(request_type, GetInfo, req_json, resp_message, handle); - REQ_RESP_TYPES_MACRO(request_type, StartMining, req_json, resp_message, handle); - REQ_RESP_TYPES_MACRO(request_type, StopMining, req_json, resp_message, handle); - REQ_RESP_TYPES_MACRO(request_type, MiningStatus, req_json, resp_message, handle); REQ_RESP_TYPES_MACRO(request_type, SaveBC, req_json, resp_message, handle); REQ_RESP_TYPES_MACRO(request_type, GetBlockHash, req_json, resp_message, handle); REQ_RESP_TYPES_MACRO(request_type, GetLastBlockHeader, req_json, resp_message, handle); diff --git a/src/rpc/daemon_handler.h b/src/rpc/daemon_handler.h index 972250f499f..9b0cd09a06b 100755 --- a/src/rpc/daemon_handler.h +++ b/src/rpc/daemon_handler.h @@ -68,14 +68,8 @@ class DaemonHandler : public RpcHandler void handle(const SendRawTx::Request& req, SendRawTx::Response& res); - void handle(const StartMining::Request& req, StartMining::Response& res); - void handle(const GetInfo::Request& req, GetInfo::Response& res); - void handle(const StopMining::Request& req, StopMining::Response& res); - - void handle(const MiningStatus::Request& req, MiningStatus::Response& res); - void handle(const SaveBC::Request& req, SaveBC::Response& res); void handle(const GetBlockHash::Request& req, GetBlockHash::Response& res); diff --git a/src/rpc/daemon_messages.cpp b/src/rpc/daemon_messages.cpp index f26c3e4d94d..7242f6e7c08 100755 --- a/src/rpc/daemon_messages.cpp +++ b/src/rpc/daemon_messages.cpp @@ -42,9 +42,6 @@ const char* const GetTransactions::name = "get_transactions"; const char* const KeyImagesSpent::name = "key_images_spent"; const char* const GetTxGlobalOutputIndices::name = "get_tx_global_output_indices"; const char* const SendRawTx::name = "send_raw_tx"; -const char* const StartMining::name = "start_mining"; -const char* const StopMining::name = "stop_mining"; -const char* const MiningStatus::name = "mining_status"; const char* const GetInfo::name = "get_info"; const char* const SaveBC::name = "save_bc"; const char* const GetBlockHash::name = "get_block_hash"; @@ -307,90 +304,6 @@ void SendRawTx::Response::fromJson(rapidjson::Value& val) GET_FROM_JSON_OBJECT(val, relayed, relayed); } -rapidjson::Value StartMining::Request::toJson(rapidjson::Document& doc) const -{ - auto val = Message::toJson(doc); - - auto& al = doc.GetAllocator(); - - INSERT_INTO_JSON_OBJECT(val, doc, miner_address, miner_address); - INSERT_INTO_JSON_OBJECT(val, doc, threads_count, threads_count); - INSERT_INTO_JSON_OBJECT(val, doc, do_background_mining, do_background_mining); - INSERT_INTO_JSON_OBJECT(val, doc, ignore_battery, ignore_battery); - - return val; -} - -void StartMining::Request::fromJson(rapidjson::Value& val) -{ - GET_FROM_JSON_OBJECT(val, miner_address, miner_address); - GET_FROM_JSON_OBJECT(val, threads_count, threads_count); - GET_FROM_JSON_OBJECT(val, do_background_mining, do_background_mining); - GET_FROM_JSON_OBJECT(val, ignore_battery, ignore_battery); -} - -rapidjson::Value StartMining::Response::toJson(rapidjson::Document& doc) const -{ - return Message::toJson(doc); -} - -void StartMining::Response::fromJson(rapidjson::Value& val) -{ -} - - -rapidjson::Value StopMining::Request::toJson(rapidjson::Document& doc) const -{ - return Message::toJson(doc); -} - -void StopMining::Request::fromJson(rapidjson::Value& val) -{ -} - -rapidjson::Value StopMining::Response::toJson(rapidjson::Document& doc) const -{ - return Message::toJson(doc); -} - -void StopMining::Response::fromJson(rapidjson::Value& val) -{ -} - - -rapidjson::Value MiningStatus::Request::toJson(rapidjson::Document& doc) const -{ - return Message::toJson(doc); -} - -void MiningStatus::Request::fromJson(rapidjson::Value& val) -{ -} - -rapidjson::Value MiningStatus::Response::toJson(rapidjson::Document& doc) const -{ - auto val = Message::toJson(doc); - - auto& al = doc.GetAllocator(); - - INSERT_INTO_JSON_OBJECT(val, doc, active, active); - INSERT_INTO_JSON_OBJECT(val, doc, speed, speed); - INSERT_INTO_JSON_OBJECT(val, doc, threads_count, threads_count); - INSERT_INTO_JSON_OBJECT(val, doc, address, address); - INSERT_INTO_JSON_OBJECT(val, doc, is_background_mining_enabled, is_background_mining_enabled); - - return val; -} - -void MiningStatus::Response::fromJson(rapidjson::Value& val) -{ - GET_FROM_JSON_OBJECT(val, active, active); - GET_FROM_JSON_OBJECT(val, speed, speed); - GET_FROM_JSON_OBJECT(val, threads_count, threads_count); - GET_FROM_JSON_OBJECT(val, address, address); - GET_FROM_JSON_OBJECT(val, is_background_mining_enabled, is_background_mining_enabled); -} - rapidjson::Value GetInfo::Request::toJson(rapidjson::Document& doc) const { diff --git a/src/rpc/daemon_messages.h b/src/rpc/daemon_messages.h index 98a365b894c..35fe22a2760 100755 --- a/src/rpc/daemon_messages.h +++ b/src/rpc/daemon_messages.h @@ -169,17 +169,6 @@ BEGIN_RPC_MESSAGE_CLASS(SendRawTx); END_RPC_MESSAGE_RESPONSE; END_RPC_MESSAGE_CLASS; -BEGIN_RPC_MESSAGE_CLASS(StartMining); - BEGIN_RPC_MESSAGE_REQUEST; - RPC_MESSAGE_MEMBER(std::string, miner_address); - RPC_MESSAGE_MEMBER(uint64_t, threads_count); - RPC_MESSAGE_MEMBER(bool, do_background_mining); - RPC_MESSAGE_MEMBER(bool, ignore_battery); - END_RPC_MESSAGE_REQUEST; - BEGIN_RPC_MESSAGE_RESPONSE; - END_RPC_MESSAGE_RESPONSE; -END_RPC_MESSAGE_CLASS; - BEGIN_RPC_MESSAGE_CLASS(GetInfo); BEGIN_RPC_MESSAGE_REQUEST; END_RPC_MESSAGE_REQUEST; @@ -188,25 +177,6 @@ BEGIN_RPC_MESSAGE_CLASS(GetInfo); END_RPC_MESSAGE_RESPONSE; END_RPC_MESSAGE_CLASS; -BEGIN_RPC_MESSAGE_CLASS(StopMining); - BEGIN_RPC_MESSAGE_REQUEST; - END_RPC_MESSAGE_REQUEST; - BEGIN_RPC_MESSAGE_RESPONSE; - END_RPC_MESSAGE_RESPONSE; -END_RPC_MESSAGE_CLASS; - -BEGIN_RPC_MESSAGE_CLASS(MiningStatus); - BEGIN_RPC_MESSAGE_REQUEST; - END_RPC_MESSAGE_REQUEST; - BEGIN_RPC_MESSAGE_RESPONSE; - RPC_MESSAGE_MEMBER(bool, active); - RPC_MESSAGE_MEMBER(uint64_t, speed); - RPC_MESSAGE_MEMBER(uint64_t, threads_count); - RPC_MESSAGE_MEMBER(std::string, address); - RPC_MESSAGE_MEMBER(bool, is_background_mining_enabled); - END_RPC_MESSAGE_RESPONSE; -END_RPC_MESSAGE_CLASS; - BEGIN_RPC_MESSAGE_CLASS(SaveBC); BEGIN_RPC_MESSAGE_REQUEST; END_RPC_MESSAGE_REQUEST; diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 58457651af5..624f46fb59d 100755 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -3298,13 +3298,6 @@ simple_wallet::simple_wallet() , m_in_manual_refresh(false) , m_current_subaddress_account(0) { - m_cmd_binder.set_handler("start_mining", - boost::bind(&simple_wallet::start_mining, this, _1), - tr("start_mining [] [bg_mining] [ignore_battery]"), - tr("Start mining in the daemon (bg_mining and ignore_battery are optional booleans).")); - m_cmd_binder.set_handler("stop_mining", - boost::bind(&simple_wallet::stop_mining, this, _1), - tr("Stop mining in the daemon.")); m_cmd_binder.set_handler("set_daemon", boost::bind(&simple_wallet::set_daemon, this, _1), tr("set_daemon [:] [trusted|untrusted]"), @@ -5032,88 +5025,6 @@ bool simple_wallet::save_watch_only(const std::vector &args/* = std } return true; } - -//---------------------------------------------------------------------------------------------------- -bool simple_wallet::start_mining(const std::vector& args) -{ - if (!m_wallet->is_trusted_daemon()) - { - fail_msg_writer() << tr("this command requires a trusted daemon. Enable with --trusted-daemon"); - return true; - } - - if (!try_connect_to_daemon()) - return true; - - if (!m_wallet) - { - fail_msg_writer() << tr("wallet is null"); - return true; - } - COMMAND_RPC_START_MINING::request req = AUTO_VAL_INIT(req); - req.miner_address = m_wallet->get_account().get_public_address_str(m_wallet->nettype()); - - bool ok = true; - size_t arg_size = args.size(); - if(arg_size >= 3) - { - if (!parse_bool_and_use(args[2], [&](bool r) { req.ignore_battery = r; })) - return true; - } - if(arg_size >= 2) - { - if (!parse_bool_and_use(args[1], [&](bool r) { req.do_background_mining = r; })) - return true; - } - if(arg_size >= 1) - { - uint16_t num = 1; - ok = string_tools::get_xtype_from_string(num, args[0]); - ok = ok && 1 <= num; - req.threads_count = num; - } - else - { - req.threads_count = 1; - } - - if (!ok) - { - fail_msg_writer() << tr("invalid arguments. Please use start_mining [] [do_bg_mining] [ignore_battery]"); - return true; - } - - COMMAND_RPC_START_MINING::response res; - bool r = m_wallet->invoke_http_json("/start_mining", req, res); - std::string err = interpret_rpc_response(r, res.status); - if (err.empty()) - success_msg_writer() << tr("Mining started in daemon"); - else - fail_msg_writer() << tr("mining has NOT been started: ") << err; - return true; -} -//---------------------------------------------------------------------------------------------------- -bool simple_wallet::stop_mining(const std::vector& args) -{ - if (!try_connect_to_daemon()) - return true; - - if (!m_wallet) - { - fail_msg_writer() << tr("wallet is null"); - return true; - } - - COMMAND_RPC_STOP_MINING::request req; - COMMAND_RPC_STOP_MINING::response res; - bool r = m_wallet->invoke_http_json("/stop_mining", req, res); - std::string err = interpret_rpc_response(r, res.status); - if (err.empty()) - success_msg_writer() << tr("Mining stopped in daemon"); - else - fail_msg_writer() << tr("mining has NOT been stopped: ") << err; - return true; -} //---------------------------------------------------------------------------------------------------- bool simple_wallet::set_daemon(const std::vector& args) { diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 200a381408c..89a501f4179 100755 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -140,8 +140,6 @@ namespace cryptonote bool set_segregation_height(const std::vector &args = std::vector()); bool set_ignore_fractional_outputs(const std::vector &args = std::vector()); bool help(const std::vector &args = std::vector()); - bool start_mining(const std::vector &args); - bool stop_mining(const std::vector &args); bool set_daemon(const std::vector &args); bool save_bc(const std::vector &args); bool refresh(const std::vector &args); diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp index 9a09c3e2721..2912b0fca53 100755 --- a/src/wallet/api/wallet_manager.cpp +++ b/src/wallet/api/wallet_manager.cpp @@ -265,19 +265,6 @@ uint64_t WalletManagerImpl::networkDifficulty() return ires.difficulty; } -double WalletManagerImpl::miningHashRate() -{ - cryptonote::COMMAND_RPC_MINING_STATUS::request mreq; - cryptonote::COMMAND_RPC_MINING_STATUS::response mres; - - epee::net_utils::http::http_simple_client http_client; - if (!epee::net_utils::invoke_http_json("/mining_status", mreq, mres, m_http_client)) - return 0.0; - if (!mres.active) - return 0.0; - return mres.speed; -} - uint64_t WalletManagerImpl::blockTarget() { cryptonote::COMMAND_RPC_GET_INFO::request ireq; @@ -288,41 +275,6 @@ uint64_t WalletManagerImpl::blockTarget() return ires.target; } -bool WalletManagerImpl::isMining() -{ - cryptonote::COMMAND_RPC_MINING_STATUS::request mreq; - cryptonote::COMMAND_RPC_MINING_STATUS::response mres; - - if (!epee::net_utils::invoke_http_json("/mining_status", mreq, mres, m_http_client)) - return false; - return mres.active; -} - -bool WalletManagerImpl::startMining(const std::string &address, uint32_t threads, bool background_mining, bool ignore_battery) -{ - cryptonote::COMMAND_RPC_START_MINING::request mreq; - cryptonote::COMMAND_RPC_START_MINING::response mres; - - mreq.miner_address = address; - mreq.threads_count = threads; - mreq.ignore_battery = ignore_battery; - mreq.do_background_mining = background_mining; - - if (!epee::net_utils::invoke_http_json("/start_mining", mreq, mres, m_http_client)) - return false; - return mres.status == CORE_RPC_STATUS_OK; -} - -bool WalletManagerImpl::stopMining() -{ - cryptonote::COMMAND_RPC_STOP_MINING::request mreq; - cryptonote::COMMAND_RPC_STOP_MINING::response mres; - - if (!epee::net_utils::invoke_http_json("/stop_mining", mreq, mres, m_http_client)) - return false; - return mres.status == CORE_RPC_STATUS_OK; -} - std::string WalletManagerImpl::resolveOpenAlias(const std::string &address, bool &dnssec_valid) const { std::vector addresses = tools::dns_utils::addresses_from_url(address, dnssec_valid); diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 365db28364f..0ab81dfa911 100755 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -2606,56 +2606,7 @@ namespace tools } return true; } - //------------------------------------------------------------------------------------------------------------------------------ - bool wallet_rpc_server::on_start_mining(const wallet_rpc::COMMAND_RPC_START_MINING::request& req, wallet_rpc::COMMAND_RPC_START_MINING::response& res, epee::json_rpc::error& er) - { - if (!m_wallet) return not_open(er); - if (!m_wallet->is_trusted_daemon()) - { - er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; - er.message = "This command requires a trusted daemon."; - return false; - } - - size_t max_mining_threads_count = (std::max)(tools::get_max_concurrency(), static_cast(2)); - if (req.threads_count < 1 || max_mining_threads_count < req.threads_count) - { - er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; - er.message = "The specified number of threads is inappropriate."; - return false; - } - - cryptonote::COMMAND_RPC_START_MINING::request daemon_req = AUTO_VAL_INIT(daemon_req); - daemon_req.miner_address = m_wallet->get_account().get_public_address_str(m_wallet->nettype()); - daemon_req.threads_count = req.threads_count; - daemon_req.do_background_mining = req.do_background_mining; - daemon_req.ignore_battery = req.ignore_battery; - - cryptonote::COMMAND_RPC_START_MINING::response daemon_res; - bool r = m_wallet->invoke_http_json("/start_mining", daemon_req, daemon_res); - if (!r || daemon_res.status != CORE_RPC_STATUS_OK) - { - er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; - er.message = "Couldn't start mining due to unknown error."; - return false; - } - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ - bool wallet_rpc_server::on_stop_mining(const wallet_rpc::COMMAND_RPC_STOP_MINING::request& req, wallet_rpc::COMMAND_RPC_STOP_MINING::response& res, epee::json_rpc::error& er) - { - if (!m_wallet) return not_open(er); - cryptonote::COMMAND_RPC_STOP_MINING::request daemon_req; - cryptonote::COMMAND_RPC_STOP_MINING::response daemon_res; - bool r = m_wallet->invoke_http_json("/stop_mining", daemon_req, daemon_res); - if (!r || daemon_res.status != CORE_RPC_STATUS_OK) - { - er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; - er.message = "Couldn't stop mining due to unknown error."; - return false; - } - return true; - } + //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::on_get_languages(const wallet_rpc::COMMAND_RPC_GET_LANGUAGES::request& req, wallet_rpc::COMMAND_RPC_GET_LANGUAGES::response& res, epee::json_rpc::error& er) { diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index a5df5143c7e..cd72640b7da 100755 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -128,8 +128,6 @@ namespace tools MAP_JON_RPC_WE("delete_address_book",on_delete_address_book,wallet_rpc::COMMAND_RPC_DELETE_ADDRESS_BOOK_ENTRY) MAP_JON_RPC_WE("refresh", on_refresh, wallet_rpc::COMMAND_RPC_REFRESH) MAP_JON_RPC_WE("rescan_spent", on_rescan_spent, wallet_rpc::COMMAND_RPC_RESCAN_SPENT) - MAP_JON_RPC_WE("start_mining", on_start_mining, wallet_rpc::COMMAND_RPC_START_MINING) - MAP_JON_RPC_WE("stop_mining", on_stop_mining, wallet_rpc::COMMAND_RPC_STOP_MINING) MAP_JON_RPC_WE("get_languages", on_get_languages, wallet_rpc::COMMAND_RPC_GET_LANGUAGES) MAP_JON_RPC_WE("create_wallet", on_create_wallet, wallet_rpc::COMMAND_RPC_CREATE_WALLET) MAP_JON_RPC_WE("open_wallet", on_open_wallet, wallet_rpc::COMMAND_RPC_OPEN_WALLET) @@ -212,8 +210,6 @@ namespace tools bool on_delete_address_book(const wallet_rpc::COMMAND_RPC_DELETE_ADDRESS_BOOK_ENTRY::request& req, wallet_rpc::COMMAND_RPC_DELETE_ADDRESS_BOOK_ENTRY::response& res, epee::json_rpc::error& er); bool on_refresh(const wallet_rpc::COMMAND_RPC_REFRESH::request& req, wallet_rpc::COMMAND_RPC_REFRESH::response& res, epee::json_rpc::error& er); bool on_rescan_spent(const wallet_rpc::COMMAND_RPC_RESCAN_SPENT::request& req, wallet_rpc::COMMAND_RPC_RESCAN_SPENT::response& res, epee::json_rpc::error& er); - bool on_start_mining(const wallet_rpc::COMMAND_RPC_START_MINING::request& req, wallet_rpc::COMMAND_RPC_START_MINING::response& res, epee::json_rpc::error& er); - bool on_stop_mining(const wallet_rpc::COMMAND_RPC_STOP_MINING::request& req, wallet_rpc::COMMAND_RPC_STOP_MINING::response& res, epee::json_rpc::error& er); bool on_get_languages(const wallet_rpc::COMMAND_RPC_GET_LANGUAGES::request& req, wallet_rpc::COMMAND_RPC_GET_LANGUAGES::response& res, epee::json_rpc::error& er); bool on_create_wallet(const wallet_rpc::COMMAND_RPC_CREATE_WALLET::request& req, wallet_rpc::COMMAND_RPC_CREATE_WALLET::response& res, epee::json_rpc::error& er); bool on_open_wallet(const wallet_rpc::COMMAND_RPC_OPEN_WALLET::request& req, wallet_rpc::COMMAND_RPC_OPEN_WALLET::response& res, epee::json_rpc::error& er); diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h index 50a6c8f730e..9741fa11aef 100755 --- a/src/wallet/wallet_rpc_server_commands_defs.h +++ b/src/wallet/wallet_rpc_server_commands_defs.h @@ -1735,43 +1735,6 @@ namespace wallet_rpc }; }; - struct COMMAND_RPC_START_MINING - { - struct request - { - uint64_t threads_count; - bool do_background_mining; - bool ignore_battery; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(threads_count) - KV_SERIALIZE(do_background_mining) - KV_SERIALIZE(ignore_battery) - END_KV_SERIALIZE_MAP() - }; - - struct response - { - BEGIN_KV_SERIALIZE_MAP() - END_KV_SERIALIZE_MAP() - }; - }; - - struct COMMAND_RPC_STOP_MINING - { - struct request - { - BEGIN_KV_SERIALIZE_MAP() - END_KV_SERIALIZE_MAP() - }; - - struct response - { - BEGIN_KV_SERIALIZE_MAP() - END_KV_SERIALIZE_MAP() - }; - }; - struct COMMAND_RPC_GET_LANGUAGES { struct request From 0ff86d3e308fc600bc84e088c52c54f5366af1be Mon Sep 17 00:00:00 2001 From: Zach Hildreth <41015215+zachhildreth@users.noreply.github.com> Date: Sun, 6 Mar 2022 17:38:11 -0800 Subject: [PATCH 09/10] test for syncing test for syncing --- src/cryptonote_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index da90ad922a5..2cde2195e01 100755 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -254,7 +254,7 @@ full_addrs.insert(SEED_NODE_5); // Updates data -#define BLOCK_HEIGHT_SF_V_2_1_0 8000000 // stealth address verification +#define BLOCK_HEIGHT_SF_V_2_1_0 895300 // stealth address verification // Network data nodes From 2834e2a68e0037b69f9c5f12d0e30fab8bfd7f69 Mon Sep 17 00:00:00 2001 From: zachhildreth Date: Thu, 10 Mar 2022 20:07:34 -0800 Subject: [PATCH 10/10] fix: Fixed debug non static build Fixed debug non static build. fixes #27 --- src/debug_utilities/object_sizes.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/debug_utilities/object_sizes.cpp b/src/debug_utilities/object_sizes.cpp index ad1fcac10f6..645f8dba747 100755 --- a/src/debug_utilities/object_sizes.cpp +++ b/src/debug_utilities/object_sizes.cpp @@ -109,12 +109,12 @@ int main(int argc, char* argv[]) SL(tools::wallet2::unsigned_tx_set); SL(tools::wallet2::signed_tx_set); - SL(X-CASH::WalletImpl); - SL(X-CASH::AddressBookRow); - SL(X-CASH::TransactionInfoImpl); - SL(X-CASH::TransactionHistoryImpl); - SL(X-CASH::PendingTransactionImpl); - SL(X-CASH::UnsignedTransactionImpl); + SL(XCash::WalletImpl); + SL(XCash::AddressBookRow); + SL(XCash::TransactionInfoImpl); + SL(XCash::TransactionHistoryImpl); + SL(XCash::PendingTransactionImpl); + SL(XCash::UnsignedTransactionImpl); return 0; }