mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-17 15:21:30 +02:00
support wallet.setDaemonConnection(rpcConnection)
This commit is contained in:
+14
-12
@@ -737,6 +737,13 @@ namespace monero {
|
||||
return walletFileExists;
|
||||
}
|
||||
|
||||
MoneroWallet::MoneroWallet(const string& path, const string& password, const MoneroNetworkType networkType) {
|
||||
cout << "MoneroWallet(3b)" << endl;
|
||||
wallet2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<network_type>(networkType), 1, true));
|
||||
wallet2->load(path, password);
|
||||
wallet2Listener = unique_ptr<Wallet2Listener>(new Wallet2Listener(*this, *wallet2));
|
||||
}
|
||||
|
||||
MoneroWallet::MoneroWallet(const string& path, const string& password) {
|
||||
cout << "MoneroWallet()" << endl;
|
||||
throw runtime_error("Not implemented");
|
||||
@@ -745,7 +752,7 @@ namespace monero {
|
||||
MoneroWallet::MoneroWallet(const string& path, const string&password, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, const string& language) {
|
||||
cout << "MoneroWallet(3)" << endl;
|
||||
wallet2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<network_type>(networkType), 1, true));
|
||||
setDaemonConnection(daemonConnection.uri, daemonConnection.username, daemonConnection.password);
|
||||
setDaemonConnection(daemonConnection);
|
||||
wallet2->set_seed_language(language);
|
||||
crypto::secret_key secret_key;
|
||||
wallet2->generate(path, password, secret_key, false, false);
|
||||
@@ -763,7 +770,7 @@ namespace monero {
|
||||
|
||||
// initialize wallet
|
||||
wallet2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(networkType), 1, true));
|
||||
setDaemonConnection(daemonConnection.uri, daemonConnection.username, daemonConnection.password);
|
||||
setDaemonConnection(daemonConnection);
|
||||
wallet2->set_seed_language(language);
|
||||
wallet2->generate(path, password, recoveryKey, true, false);
|
||||
wallet2->set_refresh_from_block_height(restoreHeight);
|
||||
@@ -825,7 +832,7 @@ namespace monero {
|
||||
if (hasSpendKey && hasViewKey) wallet2->generate(path, password, info.address, spendKeySK, viewKeySK);
|
||||
if (!hasSpendKey && hasViewKey) wallet2->generate(path, password, info.address, viewKeySK);
|
||||
if (hasSpendKey && !hasViewKey) wallet2->generate(path, password, spendKeySK, true, false);
|
||||
setDaemonConnection(daemonConnection.uri, daemonConnection.username, daemonConnection.password);
|
||||
setDaemonConnection(daemonConnection);
|
||||
wallet2->set_refresh_from_block_height(restoreHeight);
|
||||
wallet2->set_seed_language(language);
|
||||
wallet2Listener = unique_ptr<Wallet2Listener>(new Wallet2Listener(*this, *wallet2));
|
||||
@@ -836,20 +843,11 @@ namespace monero {
|
||||
cout << "Mnemonic: " << string(fetchedMnemonic.data(), fetchedMnemonic.size()) << endl;
|
||||
}
|
||||
|
||||
MoneroWallet::MoneroWallet(const string& path, const string& password, const MoneroNetworkType networkType) {
|
||||
cout << "MoneroWallet(3b)" << endl;
|
||||
wallet2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<network_type>(networkType), 1, true));
|
||||
wallet2->load(path, password);
|
||||
wallet2Listener = unique_ptr<Wallet2Listener>(new Wallet2Listener(*this, *wallet2));
|
||||
}
|
||||
|
||||
MoneroWallet::~MoneroWallet() {
|
||||
cout << "~MoneroWallet()" << endl;
|
||||
close();
|
||||
}
|
||||
|
||||
// TODO: switch this to setDaemonConnection(MoneroDaemonRpc& daemonConnection)
|
||||
// TODO: actually setDaemonConnection(boost::optional<MoneroRpcConnection>& connection)
|
||||
void MoneroWallet::setDaemonConnection(const string& uri, const string& username, const string& password) {
|
||||
cout << "setDaemonConnection(" << uri << ", " << username << ", " << password << ")" << endl;
|
||||
|
||||
@@ -864,6 +862,10 @@ namespace monero {
|
||||
if (!wallet2->init(uri, login)) throw runtime_error("Failed to initialize wallet with daemon connection");
|
||||
}
|
||||
|
||||
void MoneroWallet::setDaemonConnection(const MoneroRpcConnection& connection) {
|
||||
setDaemonConnection(connection.uri, connection.username, connection.password);
|
||||
}
|
||||
|
||||
shared_ptr<MoneroRpcConnection> MoneroWallet::getDaemonConnection() const {
|
||||
if (wallet2->get_daemon_address().empty()) return nullptr;
|
||||
shared_ptr<MoneroRpcConnection> connection = shared_ptr<MoneroRpcConnection>(new MoneroRpcConnection());
|
||||
|
||||
+22
-17
@@ -147,7 +147,16 @@ namespace monero {
|
||||
static bool walletExists(const string& path);
|
||||
|
||||
/**
|
||||
* Construct an unconnected English wallet with a randomly generated seed on mainnet.
|
||||
* Open an existing wallet.
|
||||
*
|
||||
* @param path is the path to the wallet file to open
|
||||
* @param password is the password of the wallet file to open
|
||||
* @param networkType is the wallet's network type
|
||||
*/
|
||||
MoneroWallet(const string& path, const string& password, const MoneroNetworkType networkType);
|
||||
|
||||
/**
|
||||
* Create a new wallet with a randomly generated seed on mainnet in English.
|
||||
*
|
||||
* @param path is the path to create the wallet
|
||||
* @param password is the password encrypt the wallet
|
||||
@@ -155,7 +164,7 @@ namespace monero {
|
||||
MoneroWallet(const string& path, const string& password);
|
||||
|
||||
/**
|
||||
* Construct a wallet with a randomly generated seed.
|
||||
* 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
|
||||
@@ -166,7 +175,7 @@ namespace monero {
|
||||
MoneroWallet(const string& path, const string& password, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, const string& language);
|
||||
|
||||
/**
|
||||
* Construct a wallet from a mnemonic phrase.
|
||||
* 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
|
||||
@@ -178,7 +187,7 @@ namespace monero {
|
||||
MoneroWallet(const string& path, const string& password, const string& mnemonic, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight);
|
||||
|
||||
/**
|
||||
* Construct a wallet from an address, view key, and spend key.
|
||||
* 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
|
||||
@@ -193,29 +202,25 @@ namespace monero {
|
||||
MoneroWallet(const string& path, const string& password, const string& address, const string& viewKey, const string& spendKey, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight, const string& language);
|
||||
|
||||
/**
|
||||
* Construct a wallet by opening a wallet file on disk.
|
||||
*
|
||||
* @param path is the path to the wallet file to open
|
||||
* @param password is the password of the wallet file to open
|
||||
* @param networkType is the wallet's network type
|
||||
*/
|
||||
MoneroWallet(const string& path, const string& password, const MoneroNetworkType networkType);
|
||||
|
||||
/**
|
||||
* Deconstructs the wallet.
|
||||
* Deconstruct the wallet.
|
||||
*/
|
||||
~MoneroWallet();
|
||||
|
||||
/**
|
||||
* Set the wallet's daemon connection.
|
||||
*
|
||||
* TODO: support MoneroRpcConnection
|
||||
*
|
||||
* @param uri is the daemon's URI
|
||||
* @param username is the daemon's username
|
||||
* @param password is the daemon's password
|
||||
*/
|
||||
void setDaemonConnection(const string& uri, const string& username, const string& password);
|
||||
void setDaemonConnection(const string& uri, const string& username = "", const string& password = "");
|
||||
|
||||
/**
|
||||
* Set the wallet's daemon connection.
|
||||
*
|
||||
* @param connection is the connection to set
|
||||
*/
|
||||
void setDaemonConnection(const MoneroRpcConnection& connection);
|
||||
|
||||
/**
|
||||
* TODO
|
||||
|
||||
@@ -6,7 +6,6 @@ tx 121158a7e51044e27de6958a9501cc9eba811b2e37bc651ab9a04e749d11cc38 should have
|
||||
comb code todos
|
||||
|
||||
MEDIUM PRIORITY
|
||||
DaemonConnection is its own object
|
||||
onSyncProgress(startHeight, currentHeight, endHeight, percentDone, message)?
|
||||
remove warning jstring2string
|
||||
rename external-libs/monero to monero-core for clarity
|
||||
|
||||
Reference in New Issue
Block a user