aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-09-25 16:52:27 +0200
committerRiccardo Spagni <ric@spagni.net>2017-09-25 16:52:27 +0200
commitc2346c6c599211a7e9fa8d39f0750fb059cf71b2 (patch)
tree6dfa55c8096c6bda4783f481a03e71642eda7d3f /src/wallet
parentMerge pull request #2443 (diff)
parenttx_pool: pre-init tvc.m_verifivation_failed before processing (diff)
downloadmonero-c2346c6c599211a7e9fa8d39f0750fb059cf71b2.tar.xz
Merge pull request #2424
28b72b6e tx_pool: pre-init tvc.m_verifivation_failed before processing (moneromooo-monero) 50a629b2 core_tests: catch (impossible in practice) tx extra api failure (moneromooo-monero) fee15ef1 wallet2: catch failure to parse address (moneromooo-monero) 1399e26d net_peerlist: remove dead code (moneromooo-monero) 50e09698 tx_pool: guard against failure getting tx hash (moneromooo-monero) 54cc209a wallet_rpc_server: catch failure to create directory (moneromooo-monero) 3e55099c wallet_rpc_server: init m_vm to NULL in ctor (moneromooo-monero) 7d0dde5e wallet_args: remove redundant default value for --log-file (moneromooo-monero) ed4a3350 wallet2: catch failure to save keys file (moneromooo-monero) 44434c8a wallet2_api: check whether dynamic_cast returns NULL (moneromooo-monero) 92f2f687 core: check return value from parse_hexstr_to_binbuff (moneromooo-monero) 5475692e wallet2_api: remove an unused, uninitialized, field (moneromooo-monero) a7ba3de1 libwallet_api_tests: initialize newblock_triggered on reset (moneromooo-monero) b2763ace wallet2_api: init error code to "no error" in the ctor (moneromooo-monero) b5faac53 get_blockchain_top now returns void (moneromooo-monero) 2e44d8f2 wallet_rpc_server: guard against exceptions (moneromooo-monero) 4230876b simplewallet: guard against I/O exceptions (moneromooo-monero) 06c1e057 daemon: initialize decode_as_json in RPC request (moneromooo-monero) 11f71af5 http_base: init size_t in http_request_info ctor (moneromooo-monero)
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/api/address_book.cpp2
-rw-r--r--src/wallet/api/wallet.h1
-rw-r--r--src/wallet/api/wallet_manager.cpp2
-rw-r--r--src/wallet/wallet2.cpp11
-rw-r--r--src/wallet/wallet_args.cpp2
-rw-r--r--src/wallet/wallet_rpc_server.cpp23
6 files changed, 32 insertions, 9 deletions
diff --git a/src/wallet/api/address_book.cpp b/src/wallet/api/address_book.cpp
index 28f835ebd..a955cb166 100644
--- a/src/wallet/api/address_book.cpp
+++ b/src/wallet/api/address_book.cpp
@@ -42,7 +42,7 @@ namespace Monero {
AddressBook::~AddressBook() {}
AddressBookImpl::AddressBookImpl(WalletImpl *wallet)
- : m_wallet(wallet) {}
+ : m_wallet(wallet), m_errorCode(Status_Ok) {}
bool AddressBookImpl::addRow(const std::string &dst_addr , const std::string &payment_id_str, const std::string &description)
{
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 36ffd4fc0..1e3d1e600 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -153,7 +153,6 @@ private:
std::string m_password;
TransactionHistoryImpl * m_history;
bool m_trustedDaemon;
- WalletListener * m_walletListener;
Wallet2CallbackImpl * m_wallet2Callback;
AddressBookImpl * m_addressBook;
diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp
index 4b988a417..897137d35 100644
--- a/src/wallet/api/wallet_manager.cpp
+++ b/src/wallet/api/wallet_manager.cpp
@@ -105,6 +105,8 @@ Wallet *WalletManagerImpl::createWalletFromKeys(const std::string &path,
bool WalletManagerImpl::closeWallet(Wallet *wallet, bool store)
{
WalletImpl * wallet_ = dynamic_cast<WalletImpl*>(wallet);
+ if (!wallet_)
+ return false;
bool result = wallet_->close(store);
if (!result) {
m_errorString = wallet_->errorString();
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 805703027..986f33073 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -383,7 +383,11 @@ std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file,
cryptonote::account_public_address address2;
bool has_payment_id;
crypto::hash8 new_payment_id;
- get_account_integrated_address_from_str(address2, has_payment_id, new_payment_id, testnet, field_address);
+ if (!get_account_integrated_address_from_str(address2, has_payment_id, new_payment_id, testnet, field_address))
+ {
+ tools::fail_msg_writer() << tools::wallet2::tr("failed to parse address: ") << field_address;
+ return false;
+ }
address.m_spend_public_key = address2.m_spend_public_key;
}
wallet->generate(field_filename, field_password, address, viewkey);
@@ -2653,10 +2657,11 @@ void wallet2::store_to(const std::string &path, const std::string &password)
// if we here, main wallet file is saved and we only need to save keys and address files
if (!same_file) {
prepare_file_names(path);
- store_keys(m_keys_file, password, false);
+ bool r = store_keys(m_keys_file, password, false);
+ THROW_WALLET_EXCEPTION_IF(!r, error::file_save_error, m_keys_file);
// save address to the new file
const std::string address_file = m_wallet_file + ".address.txt";
- bool r = file_io_utils::save_string_to_file(address_file, m_account.get_public_address_str(m_testnet));
+ r = file_io_utils::save_string_to_file(address_file, m_account.get_public_address_str(m_testnet));
THROW_WALLET_EXCEPTION_IF(!r, error::file_save_error, m_wallet_file);
// remove old wallet file
r = boost::filesystem::remove(old_file);
diff --git a/src/wallet/wallet_args.cpp b/src/wallet/wallet_args.cpp
index 81dc7e549..42651c32d 100644
--- a/src/wallet/wallet_args.cpp
+++ b/src/wallet/wallet_args.cpp
@@ -99,7 +99,7 @@ namespace wallet_args
command_line::add_arg(desc_general, command_line::arg_help);
command_line::add_arg(desc_general, command_line::arg_version);
- command_line::add_arg(desc_params, arg_log_file, "");
+ command_line::add_arg(desc_params, arg_log_file);
command_line::add_arg(desc_params, arg_log_level);
command_line::add_arg(desc_params, arg_max_concurrency);
command_line::add_arg(desc_params, arg_config_file);
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 54f4c4f7e..cb35482bd 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -27,6 +27,7 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
+#include <boost/format.hpp>
#include <boost/asio/ip/address.hpp>
#include <boost/filesystem/operations.hpp>
#include <cstdint>
@@ -69,7 +70,7 @@ namespace tools
}
//------------------------------------------------------------------------------------------------------------------------------
- wallet_rpc_server::wallet_rpc_server():m_wallet(NULL), rpc_login_file(), m_stop(false), m_trusted_daemon(false)
+ wallet_rpc_server::wallet_rpc_server():m_wallet(NULL), rpc_login_file(), m_stop(false), m_trusted_daemon(false), m_vm(NULL)
{
}
//------------------------------------------------------------------------------------------------------------------------------
@@ -153,7 +154,15 @@ namespace tools
#else
#define MKDIR(path, mode) mkdir(path, mode)
#endif
- MKDIR(m_wallet_dir.c_str(), 0700);
+ if (MKDIR(m_wallet_dir.c_str(), 0700) < 0)
+ {
+#ifdef _WIN32
+ LOG_ERROR(tr("Failed to create directory ") + m_wallet_dir);
+#else
+ LOG_ERROR((boost::format(tr("Failed to create directory %s: %s")) % m_wallet_dir % strerror(errno)).str());
+#endif
+ return false;
+ }
}
if (disable_auth)
@@ -1887,7 +1896,15 @@ just_dir:
wrpc.send_stop_signal();
});
LOG_PRINT_L0(tools::wallet_rpc_server::tr("Starting wallet rpc server"));
- wrpc.run();
+ try
+ {
+ wrpc.run();
+ }
+ catch (const std::exception &e)
+ {
+ LOG_ERROR(tools::wallet_rpc_server::tr("Failed to run wallet: ") << e.what());
+ return 1;
+ }
LOG_PRINT_L0(tools::wallet_rpc_server::tr("Stopped wallet rpc server"));
try
{