initial support for stagenet added

https://github.com/moneroexamples/openmonero/issues/71
pull/74/head
moneroexamples 6 years ago
parent 22836e6c73
commit d373327150

@ -19,7 +19,7 @@ to MyMonero. They include:
- the wallets generated use 25 word mnemonics, fully compatible with official monero wallets - the wallets generated use 25 word mnemonics, fully compatible with official monero wallets
(13 word mnemonics generated by MyMonero work as usual though). (13 word mnemonics generated by MyMonero work as usual though).
- import wallet fee was reduced. - 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. - improved handling of mempool, coinbase, locked and unlocked transactions.
- added dynamic miner fees. - added dynamic miner fees.
- minimum mixin set to 4 for the next hard fork. - minimum mixin set to 4 for the next hard fork.
@ -231,6 +231,11 @@ To start for testnet:
```bash ```bash
./openmonero -t ./openmonero -t
``` ```
To start for stagenet:
```bash
./openmonero -s
```
To start for testnet with non-default location of `config.json` file: To start for testnet with non-default location of `config.json` file:

@ -1,17 +1,21 @@
{ {
"daemon-url" : "daemon-url" :
{ {
"mainnet" : "http://127.0.0.1:18081", "_comment" : "RPC urls to monero deamon",
"testnet" : "http://127.0.0.1:28081" "mainnet" : "http://127.0.0.1:18081",
"testnet" : "http://127.0.0.1:28081",
"stagenet" : "http://127.0.0.1:38081"
}, },
"blockchain-path" : "blockchain-path" :
{ {
"_comment": "if paths are empty, default Monero paths will be used", "_comment" : "if paths are empty, default Monero paths will be used",
"mainnet" : "", "mainnet" : "",
"testnet" : "" "testnet" : "",
"stagenet" : ""
}, },
"database" : "database" :
{ {
"_comment" : "how should the backend connect to the mysql database",
"url" : "127.0.0.1", "url" : "127.0.0.1",
"port" : 3306, "port" : 3306,
"dbname" : "openmonero", "dbname" : "openmonero",
@ -32,6 +36,11 @@
"_comment": "these are official monero project donation address and viewkey. change it to yours", "_comment": "these are official monero project donation address and viewkey. change it to yours",
"address" : "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A", "address" : "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A",
"viewkey" : "f359631075708155cc3d92a32b75a7d02a5dcf27756707b47a2b31b21c389501" "viewkey" : "f359631075708155cc3d92a32b75a7d02a5dcf27756707b47a2b31b21c389501"
},
"stagenet" :
{
"address" : "53mqDDKtVkib8inMa41HuNJG4tj9CcaNKGr6EVSbvhWGJdpDQCiNNYBUNF1oDb8BczU5aD68d3HNKXaEsPq8cvbQE2FBkTS",
"viewkey" : "53c5850e895122574c53a4f952c726be3fe22bcd2b08f4bfed8946d887cc950b"
} }
}, },
"refresh_block_status_every_seconds" : 10, "refresh_block_status_every_seconds" : 10,

@ -105,8 +105,9 @@
</div> </div>
<a class="w-nav-brand brand-box" ng-href="{{loggedIn() ? '#!/overview' : '#!/'}}"> <a class="w-nav-brand brand-box" ng-href="{{loggedIn() ? '#!/overview' : '#!/'}}">
<span style="font-size: 32px; font-weight: bold;">OPEN MONERO</span> <span style="font-size: 32px; font-weight: bold;">OPEN MONERO</span>
<span style="color:white" ng-hide="testnet == false"><br/>testnet monero network</span> <span style="color:white" ng-show="nettype == 0"><br/>mainnet monero network</span>
<span style="color:white" ng-hide="testnet == true"><br/>mainnet monero network</span> <span style="color:white" ng-show="nettype == 1"><br/>testnet monero network</span>
<span style="color:white" ng-show="nettype == 2"><br/>stagenet monero network</span>
</a> </a>
</div> </div>
</div> </div>

@ -49,11 +49,14 @@ var cnUtil = (function(initConfig) {
var CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = config.integratedAddressPrefix; var CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = config.integratedAddressPrefix;
var CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = config.subAddressPrefix; 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_ADDRESS_BASE58_PREFIX = config.addressPrefixTestnet;
CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = config.integratedAddressPrefixTestnet; CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = config.integratedAddressPrefixTestnet;
CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = config.subAddressPrefixTestnet; 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); var UINT64_MAX = new JSBigInt(2).pow(64);

@ -2,7 +2,8 @@ var config = {
apiUrl: "http://127.0.0.1:1984/", apiUrl: "http://127.0.0.1:1984/",
mainnetExplorerUrl: "https://xmrchain.com/", mainnetExplorerUrl: "https://xmrchain.com/",
testnetExplorerUrl: "https://testnet.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, coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero
@ -16,7 +17,10 @@ var config = {
addressPrefixTestnet: 53, addressPrefixTestnet: 53,
integratedAddressPrefixTestnet: 54, integratedAddressPrefixTestnet: 54,
subAddressPrefixTestnet: 63, 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 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, txChargeRatio: 0.5,
defaultMixin: 4, // minimum mixin for hardfork v5 defaultMixin: 4, // minimum mixin for hardfork v5
@ -27,3 +31,4 @@ var config = {
avgBlockTime: 120, avgBlockTime: 120,
debugMode: false debugMode: false
}; };

@ -45,7 +45,7 @@ thinwalletCtrls.controller('AccountCtrl', function($scope, $rootScope, $http, $q
$scope.spend_key = AccountService.getSpendKey(); $scope.spend_key = AccountService.getSpendKey();
$scope.mnemonic = AccountService.getMnemonic(); $scope.mnemonic = AccountService.getMnemonic();
$scope.testnet = config.testnet; $scope.nettype = config.nettype;
$scope.transactions = []; $scope.transactions = [];
$scope.blockchain_height = 0; $scope.blockchain_height = 0;

@ -39,9 +39,12 @@ thinwalletCtrls.controller("LoginCtrl", function($scope, $location, AccountServi
$scope.mnemonic_language = 'english'; $scope.mnemonic_language = 'english';
if (config.testnet == true) { if (config.nettype == 1) {
// just some dummy account, as not to fill login form every time. // 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"; $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 { } else {
$scope.decode = false; $scope.decode = false;
$scope.address = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; $scope.address = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A";

@ -37,7 +37,7 @@ html {
<div class="home-header">Fully Open Sourced Light Monero Wallet</div> <div class="home-header">Fully Open Sourced Light Monero Wallet</div>
<div class="home-subhead">Inspect the code, change it, develop, host it for your own use or for others</div> <div class="home-subhead">Inspect the code, change it, develop, host it for your own use or for others</div>
<a class="create-account-btn" href="#!/create-your-account">Create an Account</a> <a class="create-account-btn" href="#!/create-your-account">Create an Account</a>
<div class="home-subhead" style="font-size:12px" ng-hide="testnet == true"> <div class="home-subhead" style="font-size:12px" ng-show="nettype == 0">
<br/> <br/>
This is <span style="color: red; font-weight: bold">development</span> version on mainnet. This is <span style="color: red; font-weight: bold">development</span> version on mainnet.
Don't use unless you know what you are doing. Don't use unless you know what you are doing.

@ -38,6 +38,11 @@ bool testnet = *testnet_opt;
bool stagenet = *stagenet_opt; bool stagenet = *stagenet_opt;
bool do_not_relay = *do_not_relay_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 // check if config-file provided exist
if (!boost::filesystem::exists(*config_file_opt)) if (!boost::filesystem::exists(*config_file_opt))
@ -63,52 +68,19 @@ catch (const std::exception& e)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
//cast port number in string to uint16 //cast port number in string to uint16
uint16_t app_port = boost::lexical_cast<uint16_t>(*port_opt); uint16_t app_port = boost::lexical_cast<uint16_t>(*port_opt);
// get blockchain path // get the network type
// if confing.json paths are emtpy, defeault monero cryptonote::network_type nettype = testnet ?
// paths are going to be used cryptonote::network_type::TESTNET : stagenet ?
path blockchain_path = testnet cryptonote::network_type::STAGENET : cryptonote::network_type::MAINNET;
? path(config_json["blockchain-path"]["testnet"].get<string>())
: path(config_json["blockchain-path"]["mainnet"].get<string>());
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"];
// set blockchain status monitoring thread parameters // set blockchain status monitoring thread parameters
xmreg::CurrentBlockchainStatus::blockchain_path
= blockchain_path.string();
xmreg::CurrentBlockchainStatus::net_type xmreg::CurrentBlockchainStatus::net_type
= nettype; = nettype;
xmreg::CurrentBlockchainStatus::do_not_relay xmreg::CurrentBlockchainStatus::do_not_relay
= do_not_relay; = do_not_relay;
xmreg::CurrentBlockchainStatus::deamon_url
= deamon_url;
xmreg::CurrentBlockchainStatus::refresh_block_status_every_seconds xmreg::CurrentBlockchainStatus::refresh_block_status_every_seconds
= config_json["refresh_block_status_every_seconds"]; = config_json["refresh_block_status_every_seconds"];
xmreg::CurrentBlockchainStatus::max_number_of_blocks_to_import xmreg::CurrentBlockchainStatus::max_number_of_blocks_to_import
@ -118,21 +90,68 @@ xmreg::CurrentBlockchainStatus::search_thread_life_in_seconds
xmreg::CurrentBlockchainStatus::import_fee xmreg::CurrentBlockchainStatus::import_fee
= config_json["wallet_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 case cryptonote::network_type::MAINNET:
= config_json["wallet_import"]["testnet"]["address"]; blockchain_path = path(config_json["blockchain-path"]["mainnet"].get<string>());
xmreg::CurrentBlockchainStatus::import_payment_viewkey_str deamon_url = config_json["daemon-url"]["mainnet"];
= config_json["wallet_import"]["testnet"]["viewkey"]; 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<string>());
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<string>());
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<int>(nettype) << "\n";
return EXIT_FAILURE;
} }
else
if (!xmreg::get_blockchain_path(blockchain_path, nettype))
{ {
xmreg::CurrentBlockchainStatus::import_payment_address_str cerr << "Error getting blockchain path.\n";
= config_json["wallet_import"]["mainnet"]["address"]; return EXIT_FAILURE;
xmreg::CurrentBlockchainStatus::import_payment_viewkey_str
= config_json["wallet_import"]["mainnet"]["viewkey"];
} }
// 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 // try connecting to the mysql
shared_ptr<xmreg::MySqlAccounts> mysql_accounts; shared_ptr<xmreg::MySqlAccounts> mysql_accounts;
@ -149,7 +168,6 @@ catch(std::exception const& e)
} }
// since CurrentBlockchainStatus class monitors current status // since CurrentBlockchainStatus class monitors current status
// of the blockchain (e.g., current height), its seems logical to // of the blockchain (e.g., current height), its seems logical to
// make static objects for accessing the blockchain in this class. // make static objects for accessing the blockchain in this class.

@ -131,10 +131,7 @@ CurrentBlockchainStatus::init_monero_blockchain()
// initialize the core using the blockchain path // initialize the core using the blockchain path
if (!mcore->init(blockchain_path)) if (!mcore->init(blockchain_path))
{
cerr << "Error accessing blockchain." << endl;
return false; return false;
}
// get the high level Blockchain object to interact // get the high level Blockchain object to interact
// with the blockchain lmdb database // with the blockchain lmdb database

@ -248,14 +248,16 @@ generate_key_image(const crypto::key_derivation& derivation,
string string
get_default_lmdb_folder(bool testnet) get_default_lmdb_folder(network_type nettype)
{ {
// default path to monero folder // default path to monero folder
// on linux this is /home/<username>/.bitmonero // on linux this is /home/<username>/.bitmonero
string default_monero_dir = tools::get_default_data_dir(); string default_monero_dir = tools::get_default_data_dir();
if (testnet) if (nettype == cryptonote::network_type::TESTNET)
default_monero_dir += "/testnet"; default_monero_dir += "/testnet";
if (nettype == cryptonote::network_type::STAGENET)
default_monero_dir += "/stagenet";
// the default folder of the lmdb blockchain database // 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 * Ge blockchain exception from command line option
* *
@ -271,11 +274,10 @@ get_default_lmdb_folder(bool testnet)
*/ */
bool bool
get_blockchain_path(bf::path& blockchain_path, get_blockchain_path(bf::path& blockchain_path,
bool testnet) cryptonote::network_type nettype)
{ {
// the default folder of the lmdb blockchain database // 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 = !blockchain_path.empty()
? blockchain_path ? blockchain_path
@ -284,8 +286,7 @@ get_blockchain_path(bf::path& blockchain_path,
if (!bf::is_directory(blockchain_path)) if (!bf::is_directory(blockchain_path))
{ {
cerr << "Given path \"" << blockchain_path << "\" " cerr << "Given path \"" << blockchain_path << "\" "
<< "is not a folder or does not exist" << " " << "is not a folder or does not exist \n";
<< endl;
return false; return false;
} }

@ -91,7 +91,7 @@ operator<< (ostream& os, const address_parse_info& addr);
string string
get_default_lmdb_folder(bool testnet = false); get_default_lmdb_folder(network_type nettype = network_type::MAINNET);
bool bool
generate_key_image(const crypto::key_derivation& derivation, generate_key_image(const crypto::key_derivation& derivation,
@ -102,7 +102,7 @@ generate_key_image(const crypto::key_derivation& derivation,
bool bool
get_blockchain_path(bf::path& blockchain_path, get_blockchain_path(bf::path& blockchain_path,
bool testnet = false); network_type nettype = network_type::MAINNET);
array<uint64_t, 4> array<uint64_t, 4>
summary_of_in_out_rct( summary_of_in_out_rct(

Loading…
Cancel
Save