diff --git a/README.md b/README.md
index f48c6c5..80753e5 100755
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ to MyMonero. They include:
- the wallets generated use 25 word mnemonics, fully compatible with official monero wallets
(13 word mnemonics generated by MyMonero work as usual though).
- import wallet fee was reduced.
- - added support of testnet network and mainnet network without relying transactions
+ - added support of testnet and stagenet networks, and mainnet without relying transactions
- improved handling of mempool, coinbase, locked and unlocked transactions.
- added dynamic miner fees.
- minimum mixin set to 4 for the next hard fork.
@@ -231,6 +231,11 @@ To start for testnet:
```bash
./openmonero -t
```
+
+To start for stagenet:
+```bash
+./openmonero -s
+```
To start for testnet with non-default location of `config.json` file:
diff --git a/config/config.json b/config/config.json
index df130dd..c3afe2c 100755
--- a/config/config.json
+++ b/config/config.json
@@ -1,17 +1,21 @@
{
"daemon-url" :
{
- "mainnet" : "http://127.0.0.1:18081",
- "testnet" : "http://127.0.0.1:28081"
+ "_comment" : "RPC urls to monero deamon",
+ "mainnet" : "http://127.0.0.1:18081",
+ "testnet" : "http://127.0.0.1:28081",
+ "stagenet" : "http://127.0.0.1:38081"
},
"blockchain-path" :
{
- "_comment": "if paths are empty, default Monero paths will be used",
- "mainnet" : "",
- "testnet" : ""
+ "_comment" : "if paths are empty, default Monero paths will be used",
+ "mainnet" : "",
+ "testnet" : "",
+ "stagenet" : ""
},
"database" :
{
+ "_comment" : "how should the backend connect to the mysql database",
"url" : "127.0.0.1",
"port" : 3306,
"dbname" : "openmonero",
@@ -32,6 +36,11 @@
"_comment": "these are official monero project donation address and viewkey. change it to yours",
"address" : "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A",
"viewkey" : "f359631075708155cc3d92a32b75a7d02a5dcf27756707b47a2b31b21c389501"
+ },
+ "stagenet" :
+ {
+ "address" : "53mqDDKtVkib8inMa41HuNJG4tj9CcaNKGr6EVSbvhWGJdpDQCiNNYBUNF1oDb8BczU5aD68d3HNKXaEsPq8cvbQE2FBkTS",
+ "viewkey" : "53c5850e895122574c53a4f952c726be3fe22bcd2b08f4bfed8946d887cc950b"
}
},
"refresh_block_status_every_seconds" : 10,
diff --git a/html/index.html b/html/index.html
index 7dece73..a7ee641 100755
--- a/html/index.html
+++ b/html/index.html
@@ -105,8 +105,9 @@
OPEN MONERO
-
testnet monero network
-
mainnet monero network
+
mainnet monero network
+
testnet monero network
+
stagenet monero network
diff --git a/html/js/cn_util.js b/html/js/cn_util.js
index ed08a88..e0331d6 100755
--- a/html/js/cn_util.js
+++ b/html/js/cn_util.js
@@ -49,11 +49,14 @@ var cnUtil = (function(initConfig) {
var CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = config.integratedAddressPrefix;
var CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = config.subAddressPrefix;
- if (config.testnet === true)
- {
+ if (config.nettype === 1 /*testnet*/) {
CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = config.addressPrefixTestnet;
CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = config.integratedAddressPrefixTestnet;
CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = config.subAddressPrefixTestnet;
+ } else if (config.nettype === 2 /*stagenet*/) {
+ CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = config.addressPrefixStagenet;
+ CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = config.integratedAddressPrefixStagenet;
+ CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = config.subAddressPrefixStagnet;
}
var UINT64_MAX = new JSBigInt(2).pow(64);
diff --git a/html/js/config.js b/html/js/config.js
index 8955950..00238cc 100755
--- a/html/js/config.js
+++ b/html/js/config.js
@@ -2,7 +2,8 @@ var config = {
apiUrl: "http://127.0.0.1:1984/",
mainnetExplorerUrl: "https://xmrchain.com/",
testnetExplorerUrl: "https://testnet.xmrchain.com/",
- testnet: true,
+ stagenetExplorerUrl: "http://162.210.173.150:8083/",
+ nettype: 2, /* 0 - MAINNET, 1 - TESTNET, 2 - STAGENET */
coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero
@@ -16,7 +17,10 @@ var config = {
addressPrefixTestnet: 53,
integratedAddressPrefixTestnet: 54,
subAddressPrefixTestnet: 63,
- feePerKB: new JSBigInt('2000000000'),//20^10 - for testnet its not used, as fee is dynamic.
+ addressPrefixStagenet: 24,
+ integratedAddressPrefixStagenet: 25,
+ subAddressPrefixStagenet: 36,
+ feePerKB: new JSBigInt('2000000000'),//20^10 - not used anymore, as fee is dynamic.
dustThreshold: new JSBigInt('1000000000'),//10^10 used for choosing outputs/change - we decompose all the way down if the receiver wants now regardless of threshold
txChargeRatio: 0.5,
defaultMixin: 4, // minimum mixin for hardfork v5
@@ -27,3 +31,4 @@ var config = {
avgBlockTime: 120,
debugMode: false
};
+
diff --git a/html/js/controllers/account.js b/html/js/controllers/account.js
index 73d3144..3e8aad7 100755
--- a/html/js/controllers/account.js
+++ b/html/js/controllers/account.js
@@ -45,7 +45,7 @@ thinwalletCtrls.controller('AccountCtrl', function($scope, $rootScope, $http, $q
$scope.spend_key = AccountService.getSpendKey();
$scope.mnemonic = AccountService.getMnemonic();
- $scope.testnet = config.testnet;
+ $scope.nettype = config.nettype;
$scope.transactions = [];
$scope.blockchain_height = 0;
diff --git a/html/js/controllers/login.js b/html/js/controllers/login.js
index e4920a0..42ae9d4 100755
--- a/html/js/controllers/login.js
+++ b/html/js/controllers/login.js
@@ -39,9 +39,12 @@ thinwalletCtrls.controller("LoginCtrl", function($scope, $location, AccountServi
$scope.mnemonic_language = 'english';
- if (config.testnet == true) {
+ if (config.nettype == 1) {
// just some dummy account, as not to fill login form every time.
$scope.mnemonic = "agenda shrugged liquid extra mundane phone nomad oust duckling sifting pledge loyal royal urban skater bawled gusts bounced boil violin mumble gags axle sapling shrugged";
+ } else if (config.nettype == 2) {
+ // just some dummy account, as not to fill login form every time.
+ $scope.mnemonic = "eluded extra boyfriend gels hiding waxing feline unbending drying pancakes dwindling fuming friendly pamphlet myth tepid snug budget android vogue losing each affair afraid affair";
} else {
$scope.decode = false;
$scope.address = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A";
diff --git a/html/partials/home.html b/html/partials/home.html
index ac90bfc..fbd3072 100755
--- a/html/partials/home.html
+++ b/html/partials/home.html
@@ -37,7 +37,7 @@ html {
Inspect the code, change it, develop, host it for your own use or for others
Create an Account
-
+
This is development version on mainnet.
Don't use unless you know what you are doing.
diff --git a/main.cpp b/main.cpp
index 338add3..130a047 100755
--- a/main.cpp
+++ b/main.cpp
@@ -38,6 +38,11 @@ bool testnet = *testnet_opt;
bool stagenet = *stagenet_opt;
bool do_not_relay = *do_not_relay_opt;
+if (testnet && stagenet)
+{
+ cerr << "testnet and stagenet cannot be specified at the same time!" << endl;
+ return EXIT_FAILURE;
+}
// check if config-file provided exist
if (!boost::filesystem::exists(*config_file_opt))
@@ -63,52 +68,19 @@ catch (const std::exception& e)
return EXIT_FAILURE;
}
-
//cast port number in string to uint16
uint16_t app_port = boost::lexical_cast(*port_opt);
-// get blockchain path
-// if confing.json paths are emtpy, defeault monero
-// paths are going to be used
-path blockchain_path = testnet
- ? path(config_json["blockchain-path"]["testnet"].get())
- : path(config_json["blockchain-path"]["mainnet"].get());
-
-const cryptonote::network_type nettype = testnet ?
- cryptonote::network_type::TESTNET : stagenet ?
- cryptonote::network_type::STAGENET : cryptonote::network_type::MAINNET;
-
-if (!xmreg::get_blockchain_path(blockchain_path, testnet))
-{
- cerr << "Error getting blockchain path." << endl;
- return EXIT_FAILURE;
-}
-
-cout << "Blockchain path: " << blockchain_path.string() << endl;
-
-
-
-string deamon_url = testnet
- ? config_json["daemon-url"]["testnet"]
- : config_json["daemon-url"]["mainnet"];
-
-// set mysql/mariadb connection details
-xmreg::MySqlConnector::url = config_json["database"]["url"];
-xmreg::MySqlConnector::port = config_json["database"]["port"];
-xmreg::MySqlConnector::username = config_json["database"]["user"];
-xmreg::MySqlConnector::password = config_json["database"]["password"];
-xmreg::MySqlConnector::dbname = config_json["database"]["dbname"];
-
+// get the network type
+cryptonote::network_type nettype = testnet ?
+ cryptonote::network_type::TESTNET : stagenet ?
+ cryptonote::network_type::STAGENET : cryptonote::network_type::MAINNET;
// set blockchain status monitoring thread parameters
-xmreg::CurrentBlockchainStatus::blockchain_path
- = blockchain_path.string();
xmreg::CurrentBlockchainStatus::net_type
= nettype;
xmreg::CurrentBlockchainStatus::do_not_relay
= do_not_relay;
-xmreg::CurrentBlockchainStatus::deamon_url
- = deamon_url;
xmreg::CurrentBlockchainStatus::refresh_block_status_every_seconds
= config_json["refresh_block_status_every_seconds"];
xmreg::CurrentBlockchainStatus::max_number_of_blocks_to_import
@@ -118,21 +90,68 @@ xmreg::CurrentBlockchainStatus::search_thread_life_in_seconds
xmreg::CurrentBlockchainStatus::import_fee
= config_json["wallet_import"]["fee"];
-if (testnet)
+
+string deamon_url;
+
+// get blockchain path
+// if confing.json paths are emtpy, defeault monero
+// paths are going to be used
+path blockchain_path;
+
+switch (nettype)
{
- xmreg::CurrentBlockchainStatus::import_payment_address_str
- = config_json["wallet_import"]["testnet"]["address"];
- xmreg::CurrentBlockchainStatus::import_payment_viewkey_str
- = config_json["wallet_import"]["testnet"]["viewkey"];
+ case cryptonote::network_type::MAINNET:
+ blockchain_path = path(config_json["blockchain-path"]["mainnet"].get());
+ deamon_url = config_json["daemon-url"]["mainnet"];
+ xmreg::CurrentBlockchainStatus::import_payment_address_str
+ = config_json["wallet_import"]["mainnet"]["address"];
+ xmreg::CurrentBlockchainStatus::import_payment_viewkey_str
+ = config_json["wallet_import"]["mainnet"]["viewkey"];
+ break;
+ case cryptonote::network_type::TESTNET:
+ blockchain_path = path(config_json["blockchain-path"]["testnet"].get());
+ deamon_url = config_json["daemon-url"]["testnet"];
+ xmreg::CurrentBlockchainStatus::import_payment_address_str
+ = config_json["wallet_import"]["testnet"]["address"];
+ xmreg::CurrentBlockchainStatus::import_payment_viewkey_str
+ = config_json["wallet_import"]["testnet"]["viewkey"];
+ break;
+ case cryptonote::network_type::STAGENET:
+ blockchain_path = path(config_json["blockchain-path"]["stagenet"].get());
+ deamon_url = config_json["daemon-url"]["stagenet"];
+ xmreg::CurrentBlockchainStatus::import_payment_address_str
+ = config_json["wallet_import"]["stagenet"]["address"];
+ xmreg::CurrentBlockchainStatus::import_payment_viewkey_str
+ = config_json["wallet_import"]["stagenet"]["viewkey"];
+ break;
+ default:
+ cerr << "Invalid netowork type provided: " << static_cast(nettype) << "\n";
+ return EXIT_FAILURE;
}
-else
+
+
+if (!xmreg::get_blockchain_path(blockchain_path, nettype))
{
- xmreg::CurrentBlockchainStatus::import_payment_address_str
- = config_json["wallet_import"]["mainnet"]["address"];
- xmreg::CurrentBlockchainStatus::import_payment_viewkey_str
- = config_json["wallet_import"]["mainnet"]["viewkey"];
+ cerr << "Error getting blockchain path.\n";
+ return EXIT_FAILURE;
}
+// set remaining blockchain status variables that depend on the network type
+xmreg::CurrentBlockchainStatus::blockchain_path
+ = blockchain_path.string();
+xmreg::CurrentBlockchainStatus::deamon_url
+ = deamon_url;
+
+cout << "Blockchain path: " << blockchain_path.string() << endl;
+
+
+// set mysql/mariadb connection details
+xmreg::MySqlConnector::url = config_json["database"]["url"];
+xmreg::MySqlConnector::port = config_json["database"]["port"];
+xmreg::MySqlConnector::username = config_json["database"]["user"];
+xmreg::MySqlConnector::password = config_json["database"]["password"];
+xmreg::MySqlConnector::dbname = config_json["database"]["dbname"];
+
// try connecting to the mysql
shared_ptr mysql_accounts;
@@ -149,7 +168,6 @@ catch(std::exception const& e)
}
-
// since CurrentBlockchainStatus class monitors current status
// of the blockchain (e.g., current height), its seems logical to
// make static objects for accessing the blockchain in this class.
diff --git a/src/CurrentBlockchainStatus.cpp b/src/CurrentBlockchainStatus.cpp
index 8384110..9046b9f 100755
--- a/src/CurrentBlockchainStatus.cpp
+++ b/src/CurrentBlockchainStatus.cpp
@@ -131,10 +131,7 @@ CurrentBlockchainStatus::init_monero_blockchain()
// initialize the core using the blockchain path
if (!mcore->init(blockchain_path))
- {
- cerr << "Error accessing blockchain." << endl;
return false;
- }
// get the high level Blockchain object to interact
// with the blockchain lmdb database
diff --git a/src/tools.cpp b/src/tools.cpp
index a5449b7..a3fda82 100755
--- a/src/tools.cpp
+++ b/src/tools.cpp
@@ -248,14 +248,16 @@ generate_key_image(const crypto::key_derivation& derivation,
string
-get_default_lmdb_folder(bool testnet)
+get_default_lmdb_folder(network_type nettype)
{
// default path to monero folder
// on linux this is /home//.bitmonero
string default_monero_dir = tools::get_default_data_dir();
- if (testnet)
+ if (nettype == cryptonote::network_type::TESTNET)
default_monero_dir += "/testnet";
+ if (nettype == cryptonote::network_type::STAGENET)
+ default_monero_dir += "/stagenet";
// the default folder of the lmdb blockchain database
@@ -264,6 +266,7 @@ get_default_lmdb_folder(bool testnet)
}
+
/*
* Ge blockchain exception from command line option
*
@@ -271,11 +274,10 @@ get_default_lmdb_folder(bool testnet)
*/
bool
get_blockchain_path(bf::path& blockchain_path,
- bool testnet)
+ cryptonote::network_type nettype)
{
// the default folder of the lmdb blockchain database
- string default_lmdb_dir = xmreg::get_default_lmdb_folder(testnet);
-
+ string default_lmdb_dir = xmreg::get_default_lmdb_folder(nettype);
blockchain_path = !blockchain_path.empty()
? blockchain_path
@@ -284,8 +286,7 @@ get_blockchain_path(bf::path& blockchain_path,
if (!bf::is_directory(blockchain_path))
{
cerr << "Given path \"" << blockchain_path << "\" "
- << "is not a folder or does not exist" << " "
- << endl;
+ << "is not a folder or does not exist \n";
return false;
}
diff --git a/src/tools.h b/src/tools.h
index f14021e..72c984d 100755
--- a/src/tools.h
+++ b/src/tools.h
@@ -91,7 +91,7 @@ operator<< (ostream& os, const address_parse_info& addr);
string
-get_default_lmdb_folder(bool testnet = false);
+get_default_lmdb_folder(network_type nettype = network_type::MAINNET);
bool
generate_key_image(const crypto::key_derivation& derivation,
@@ -102,7 +102,7 @@ generate_key_image(const crypto::key_derivation& derivation,
bool
get_blockchain_path(bf::path& blockchain_path,
- bool testnet = false);
+ network_type nettype = network_type::MAINNET);
array
summary_of_in_out_rct(