nettype param renamed back to network_type

This commit is contained in:
woodser
2019-08-03 13:46:04 -04:00
parent fb92fcdb65
commit 1ba67c5b03
3 changed files with 37 additions and 38 deletions
+19 -20
View File
@@ -66,7 +66,6 @@
#endif
using namespace std;
using namespace cryptonote;
using namespace epee;
using namespace tools;
@@ -791,10 +790,10 @@ namespace monero {
return wallet_file_exists;
}
monero_wallet* monero_wallet::open_wallet(const string& path, const string& password, const monero_network_type nettype) {
MTRACE("open_wallet(" << path << ", " << password << ", " << nettype << ")");
monero_wallet* monero_wallet::open_wallet(const string& path, const string& password, const monero_network_type network_type) {
MTRACE("open_wallet(" << path << ", " << password << ", " << network_type << ")");
monero_wallet* wallet = new monero_wallet();
wallet->w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<network_type>(nettype), 1, true));
wallet->w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true));
wallet->w2->load(path, password);
wallet->w2->init("");
wallet->init_common();
@@ -806,10 +805,10 @@ namespace monero {
throw runtime_error("Not implemented");
}
monero_wallet* monero_wallet::create_wallet_random(const string& path, const string& password, const monero_network_type nettype, const monero_rpc_connection& daemon_connection, const string& language) {
MTRACE("create_wallet_random(path, password, nettype, daemon_connection, language)");
monero_wallet* monero_wallet::create_wallet_random(const string& path, const string& password, const monero_network_type network_type, const monero_rpc_connection& daemon_connection, const string& language) {
MTRACE("create_wallet_random(path, password, network_type, daemon_connection, language)");
monero_wallet* wallet = new monero_wallet();
wallet->w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<network_type>(nettype), 1, true));
wallet->w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true));
wallet->set_daemon_connection(daemon_connection);
wallet->w2->set_seed_language(language);
crypto::secret_key secret_key;
@@ -818,13 +817,13 @@ namespace monero {
return wallet;
}
monero_wallet* monero_wallet::create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type nettype, const string& mnemonic) {
MTRACE("create_wallet_from_mnemonic(path, password, nettype, mnemonic)");
monero_wallet* monero_wallet::create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic) {
MTRACE("create_wallet_from_mnemonic(path, password, network_type, mnemonic)");
throw runtime_error("Not implemented");
}
monero_wallet* monero_wallet::create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type nettype, const string& mnemonic, const monero_rpc_connection& daemon_connection, uint64_t restore_height) {
MTRACE("create_wallet_from_mnemonic(path, password, mnemonic, nettype, daemon_connection, restore_height)");
monero_wallet* monero_wallet::create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic, const monero_rpc_connection& daemon_connection, uint64_t restore_height) {
MTRACE("create_wallet_from_mnemonic(path, password, mnemonic, network_type, daemon_connection, restore_height)");
monero_wallet* wallet = new monero_wallet();
// validate mnemonic and get recovery key and language
@@ -835,7 +834,7 @@ namespace monero {
if (language == crypto::ElectrumWords::old_language_name) language = Language::English().get_language_name();
// initialize wallet
wallet->w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(nettype), 1, true));
wallet->w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true));
wallet->set_daemon_connection(daemon_connection);
wallet->w2->set_seed_language(language);
wallet->w2->generate(path, password, recoveryKey, true, false);
@@ -844,23 +843,23 @@ namespace monero {
return wallet;
}
monero_wallet* monero_wallet::create_wallet_from_keys(const string& path, const string& password, const monero_network_type nettype, const string& address, const string& view_key, const string& spend_key) {
MTRACE("create_wallet_from_keys(path, password, address, view_key, spend_key, nettype)");
monero_wallet* monero_wallet::create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key) {
MTRACE("create_wallet_from_keys(path, password, address, view_key, spend_key, network_type)");
throw runtime_error("Not implemented");
}
monero_wallet* monero_wallet::create_wallet_from_keys(const string& path, const string& password, const monero_network_type nettype, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height) {
MTRACE("create_wallet_from_keys(path, password, address, view_key, spend_key, nettype, daemon_connection, restore_height)");
monero_wallet* monero_wallet::create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height) {
MTRACE("create_wallet_from_keys(path, password, address, view_key, spend_key, network_type, daemon_connection, restore_height)");
throw runtime_error("Not implemented");
}
monero_wallet* monero_wallet::create_wallet_from_keys(const string& path, const string& password, const monero_network_type nettype, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height, const string& language) {
MTRACE("create_wallet_from_keys(path, password, address, view_key, spend_key, nettype, daemon_connection, restore_height, language)");
monero_wallet* monero_wallet::create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height, const string& language) {
MTRACE("create_wallet_from_keys(path, password, address, view_key, spend_key, network_type, daemon_connection, restore_height, language)");
monero_wallet* wallet = new monero_wallet();
// validate and parse address
cryptonote::address_parse_info info;
if (!get_account_address_from_str(info, static_cast<cryptonote::network_type>(nettype), address)) throw runtime_error("failed to parse address");
if (!get_account_address_from_str(info, static_cast<cryptonote::network_type>(network_type), address)) throw runtime_error("failed to parse address");
// validate and parse optional private spend key
crypto::secret_key spend_key_sk;
@@ -901,7 +900,7 @@ namespace monero {
}
// initialize wallet
wallet->w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(nettype), 1, true));
wallet->w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true));
if (has_spend_key && has_view_key) wallet->w2->generate(path, password, info.address, spend_key_sk, view_key_sk);
if (!has_spend_key && has_view_key) wallet->w2->generate(path, password, info.address, view_key_sk);
if (has_spend_key && !has_view_key) wallet->w2->generate(path, password, spend_key_sk, true, false);
+11 -11
View File
@@ -141,41 +141,41 @@ namespace monero {
*
* @param path is the path to the wallet file to open
* @param password is the password of the wallet file to open
* @param nettype is the wallet's network type
* @param network_type is the wallet's network type
*/
static monero_wallet* open_wallet(const string& path, const string& password, const monero_network_type nettype);
static monero_wallet* open_wallet(const string& path, const string& password, const monero_network_type network_type);
/**
* Create a new wallet with a randomly generated seed.
*
* @param path is the path to create the wallet
* @param password is the password encrypt the wallet
* @param nettype is the wallet's network type (default = monero_network_type.MAINNET)
* @param network_type is the wallet's network type (default = monero_network_type.MAINNET)
* @param daemon_connection is connection information to a daemon (default = an unconnected wallet)
* @param language is the wallet and mnemonic's language (default = "English")
*/
static monero_wallet* create_wallet_random(const string& path, const string& password);
static monero_wallet* create_wallet_random(const string& path, const string& password, const monero_network_type nettype, const monero_rpc_connection& daemon_connection, const string& language);
static monero_wallet* create_wallet_random(const string& path, const string& password, const monero_network_type network_type, const monero_rpc_connection& daemon_connection, const string& language);
/**
* Create a wallet from an existing mnemonic phrase.
*
* @param path is the path to create the wallet
* @param password is the password encrypt the wallet
* @param nettype is the wallet's network type
* @param network_type is the wallet's network type
* @param mnemonic is the mnemonic of the wallet to construct
* @param daemon_connection is connection information to a daemon (default = an unconnected wallet)
* @param restore_height is the block height to restore (i.e. scan the chain) from (default = 0)
*/
static monero_wallet* create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type nettype, const string& mnemonic);
static monero_wallet* create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type nettype, const string& mnemonic, const monero_rpc_connection& daemon_connection, uint64_t restore_height);
static monero_wallet* create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic);
static monero_wallet* create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic, const monero_rpc_connection& daemon_connection, uint64_t restore_height);
/**
* Create a wallet from an address, view key, and spend key.
*
* @param path is the path to create the wallet
* @param password is the password encrypt the wallet
* @param nettype is the wallet's network type
* @param network_type is the wallet's network type
* @param address is the address of the wallet to construct
* @param view_key is the view key of the wallet to construct
* @param spend_key is the spend key of the wallet to construct
@@ -183,9 +183,9 @@ namespace monero {
* @param restore_height is the block height to restore (i.e. scan the chain) from (default = 0)
* @param language is the wallet and mnemonic's language (default = "English")
*/
static monero_wallet* create_wallet_from_keys(const string& path, const string& password, const monero_network_type nettype, const string& address, const string& view_key, const string& spend_key);
static monero_wallet* create_wallet_from_keys(const string& path, const string& password, const monero_network_type nettype, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height);
static monero_wallet* create_wallet_from_keys(const string& path, const string& password, const monero_network_type nettype, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height, const string& language);
static monero_wallet* create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key);
static monero_wallet* create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height);
static monero_wallet* create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height, const string& language);
/**
* Deconstruct the wallet.
+7 -7
View File
@@ -13,15 +13,15 @@ bool wallet_exists(string path) {
return wallet_file_exists;
}
void open_wallet(string path, string password, int nettype) {
cout << "open_wallet(" << path << ", " << password << ", " << nettype << ")" << endl;
void open_wallet(string path, string password, int network_type) {
cout << "open_wallet(" << path << ", " << password << ", " << network_type << ")" << endl;
std::unique_ptr<tools::wallet2> wallet;
wallet.reset(new tools::wallet2(cryptonote::network_type::STAGENET, 1, true));
throw runtime_error("Not implemented");
}
void create_wallet_random(string language, int nettype) {
tools::wallet2* wallet = new tools::wallet2(static_cast<cryptonote::network_type>(nettype), 1, true);
void create_wallet_random(string language, int network_type) {
tools::wallet2* wallet = new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true);
wallet->set_seed_language(language);
crypto::secret_key recovery_val, secret_key;
wallet->generate(string(""), string(""), secret_key, false, false);
@@ -53,12 +53,12 @@ int main(int argc, const char* argv[]) {
string path = "test_wallet_1";
string password = "supersecretpassword123";
string language = "English";
int nettype = 2;
int network_type = 2;
MINFO("Wallet exists: " << wallet_exists(path));
// open_wallet(path, password, nettype);
// create_wallet_random(language, nettype);
// open_wallet(path, password, network_type);
// create_wallet_random(language, network_type);
// // create wallet
// monero_wallet* wallet = new monero_wallet();