aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/api/wallet.cpp6
-rw-r--r--src/wallet/api/wallet.h3
-rw-r--r--src/wallet/wallet2_api.h2
-rw-r--r--src/wallet/wallet_args.cpp53
-rw-r--r--src/wallet/wallet_args.h2
-rw-r--r--src/wallet/wallet_rpc_server.cpp1
6 files changed, 35 insertions, 32 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index c798d4d31..99645189a 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -656,9 +656,11 @@ string WalletImpl::keysFilename() const
return m_wallet->get_keys_file();
}
-bool WalletImpl::init(const std::string &daemon_address, uint64_t upper_transaction_size_limit)
+bool WalletImpl::init(const std::string &daemon_address, uint64_t upper_transaction_size_limit, const std::string &daemon_username, const std::string &daemon_password)
{
clearStatus();
+ if(daemon_username != "")
+ m_daemon_login.emplace(daemon_username, daemon_password);
return doInit(daemon_address, upper_transaction_size_limit);
}
@@ -1365,7 +1367,7 @@ bool WalletImpl::isNewWallet() const
bool WalletImpl::doInit(const string &daemon_address, uint64_t upper_transaction_size_limit)
{
- if (!m_wallet->init(daemon_address, boost::none, upper_transaction_size_limit))
+ if (!m_wallet->init(daemon_address, m_daemon_login, upper_transaction_size_limit))
return false;
// in case new wallet, this will force fast-refresh (pulling hashes instead of blocks)
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 3501fa0ac..456110908 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -78,7 +78,7 @@ public:
bool store(const std::string &path);
std::string filename() const;
std::string keysFilename() const;
- bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit = 0);
+ bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit = 0, const std::string &daemon_username = "", const std::string &daemon_password = "");
bool connectToDaemon();
ConnectionStatus connected() const;
void setTrustedDaemon(bool arg);
@@ -170,6 +170,7 @@ private:
std::atomic<bool> m_rebuildWalletCache;
// cache connection status to avoid unnecessary RPC calls
mutable std::atomic<bool> m_is_connected;
+ boost::optional<epee::net_utils::http::login> m_daemon_login{};
};
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index eec4f8b8f..e32d23d9f 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -340,7 +340,7 @@ struct Wallet
* \param upper_transaction_size_limit
* \return - true on success
*/
- virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit) = 0;
+ virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit, const std::string &daemon_username = "", const std::string &daemon_password = "") = 0;
/*!
* \brief createWatchOnly - Creates a watch only wallet
diff --git a/src/wallet/wallet_args.cpp b/src/wallet/wallet_args.cpp
index d2cda8700..166ce57e7 100644
--- a/src/wallet/wallet_args.cpp
+++ b/src/wallet/wallet_args.cpp
@@ -73,6 +73,7 @@ namespace wallet_args
const char* const usage,
boost::program_options::options_description desc_params,
const boost::program_options::positional_options_description& positional_options,
+ const char *default_log_name,
bool log_to_console)
{
@@ -106,35 +107,9 @@ namespace wallet_args
po::options_description desc_all;
desc_all.add(desc_general).add(desc_params);
po::variables_map vm;
- std::string log_path;
bool r = command_line::handle_error_helper(desc_all, [&]()
{
- po::store(command_line::parse_command_line(argc, argv, desc_general, true), vm);
-
- if (command_line::has_arg(vm, arg_log_file))
- log_path = command_line::get_arg(vm, arg_log_file);
- else
- log_path = mlog_get_default_log_path("monero-wallet-cli.log");
- mlog_configure(log_path, log_to_console);
- if (command_line::has_arg(vm, arg_log_level))
- {
- mlog_set_log(command_line::get_arg(vm, arg_log_level).c_str());
- }
-
- if (command_line::get_arg(vm, command_line::arg_help))
- {
- tools::msg_writer() << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")";
- tools::msg_writer() << wallet_args::tr("Usage:") << ' ' << usage;
- tools::msg_writer() << desc_all;
- return false;
- }
- else if (command_line::get_arg(vm, command_line::arg_version))
- {
- tools::msg_writer() << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")";
- return false;
- }
-
- auto parser = po::command_line_parser(argc, argv).options(desc_params).positional(positional_options);
+ auto parser = po::command_line_parser(argc, argv).options(desc_all).positional(positional_options);
po::store(parser.run(), vm);
po::notify(vm);
return true;
@@ -142,6 +117,30 @@ namespace wallet_args
if (!r)
return boost::none;
+ std::string log_path;
+ if (!vm["log-file"].defaulted())
+ log_path = command_line::get_arg(vm, arg_log_file);
+ else
+ log_path = mlog_get_default_log_path(default_log_name);
+ mlog_configure(log_path, log_to_console);
+ if (!vm["log-level"].defaulted())
+ {
+ mlog_set_log(command_line::get_arg(vm, arg_log_level).c_str());
+ }
+
+ if (command_line::get_arg(vm, command_line::arg_help))
+ {
+ tools::msg_writer() << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")";
+ tools::msg_writer() << wallet_args::tr("Usage:") << ' ' << usage;
+ tools::msg_writer() << desc_all;
+ return boost::none;
+ }
+ else if (command_line::get_arg(vm, command_line::arg_version))
+ {
+ tools::msg_writer() << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")";
+ return boost::none;
+ }
+
if(command_line::has_arg(vm, arg_max_concurrency))
tools::set_max_concurrency(command_line::get_arg(vm, arg_max_concurrency));
diff --git a/src/wallet/wallet_args.h b/src/wallet/wallet_args.h
index e3466509e..cf23ffded 100644
--- a/src/wallet/wallet_args.h
+++ b/src/wallet/wallet_args.h
@@ -50,5 +50,5 @@ namespace wallet_args
const char* const usage,
boost::program_options::options_description desc_params,
const boost::program_options::positional_options_description& positional_options,
- bool log_to_console = false);
+ const char *default_log_name, bool log_to_console = false);
}
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 28606ed73..be8e0057d 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -1397,6 +1397,7 @@ int main(int argc, char** argv) {
"monero-wallet-rpc [--wallet-file=<file>|--generate-from-json=<file>] [--rpc-bind-port=<port>]",
desc_params,
po::positional_options_description(),
+ "monero-wallet-rpc.log",
true
);
if (!vm)