aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/api/wallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/api/wallet.cpp')
-rw-r--r--src/wallet/api/wallet.cpp48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 9054f552a..fb9e8b28b 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -40,10 +40,16 @@
#include "common/util.h"
#include "mnemonics/electrum-words.h"
+#include "mnemonics/english.h"
#include <boost/format.hpp>
#include <sstream>
#include <unordered_map>
+#ifdef WIN32
+#include <boost/locale.hpp>
+#include <boost/filesystem.hpp>
+#endif
+
using namespace std;
using namespace cryptonote;
@@ -233,16 +239,16 @@ bool Wallet::paymentIdValid(const string &paiment_id)
return false;
}
-bool Wallet::addressValid(const std::string &str, bool testnet)
+bool Wallet::addressValid(const std::string &str, NetworkType nettype)
{
cryptonote::address_parse_info info;
- return get_account_address_from_str(info, testnet, str);
+ return get_account_address_from_str(info, static_cast<cryptonote::network_type>(nettype), str);
}
-bool Wallet::keyValid(const std::string &secret_key_string, const std::string &address_string, bool isViewKey, bool testnet, std::string &error)
+bool Wallet::keyValid(const std::string &secret_key_string, const std::string &address_string, bool isViewKey, NetworkType nettype, std::string &error)
{
cryptonote::address_parse_info info;
- if(!get_account_address_from_str(info, testnet, address_string)) {
+ if(!get_account_address_from_str(info, static_cast<cryptonote::network_type>(nettype), address_string)) {
error = tr("Failed to parse address");
return false;
}
@@ -275,10 +281,10 @@ bool Wallet::keyValid(const std::string &secret_key_string, const std::string &a
return true;
}
-std::string Wallet::paymentIdFromAddress(const std::string &str, bool testnet)
+std::string Wallet::paymentIdFromAddress(const std::string &str, NetworkType nettype)
{
cryptonote::address_parse_info info;
- if (!get_account_address_from_str(info, testnet, str))
+ if (!get_account_address_from_str(info, static_cast<cryptonote::network_type>(nettype), str))
return "";
if (!info.has_payment_id)
return "";
@@ -291,6 +297,11 @@ uint64_t Wallet::maximumAllowedAmount()
}
void Wallet::init(const char *argv0, const char *default_log_base_name) {
+#ifdef WIN32
+ // Activate UTF-8 support for Boost filesystem classes on Windows
+ std::locale::global(boost::locale::generator().generate(""));
+ boost::filesystem::path::imbue(std::locale());
+#endif
epee::string_tools::set_module_name_and_folder(argv0);
mlog_configure(mlog_get_default_log_path(default_log_base_name), true);
}
@@ -312,7 +323,7 @@ void Wallet::error(const std::string &category, const std::string &str) {
}
///////////////////////// WalletImpl implementation ////////////////////////
-WalletImpl::WalletImpl(bool testnet)
+WalletImpl::WalletImpl(NetworkType nettype)
:m_wallet(nullptr)
, m_status(Wallet::Status_Ok)
, m_trustedDaemon(false)
@@ -322,7 +333,7 @@ WalletImpl::WalletImpl(bool testnet)
, m_rebuildWalletCache(false)
, m_is_connected(false)
{
- m_wallet = new tools::wallet2(testnet);
+ m_wallet = new tools::wallet2(static_cast<cryptonote::network_type>(nettype));
m_history = new TransactionHistoryImpl(this);
m_wallet2Callback = new Wallet2CallbackImpl(this);
m_wallet->callback(m_wallet2Callback);
@@ -400,7 +411,7 @@ bool WalletImpl::create(const std::string &path, const std::string &password, co
bool WalletImpl::createWatchOnly(const std::string &path, const std::string &password, const std::string &language) const
{
clearStatus();
- std::unique_ptr<tools::wallet2> view_wallet(new tools::wallet2(m_wallet->testnet()));
+ std::unique_ptr<tools::wallet2> view_wallet(new tools::wallet2(m_wallet->nettype()));
// Store same refresh height as original wallet
view_wallet->set_refresh_from_block_height(m_wallet->get_refresh_from_block_height());
@@ -481,7 +492,7 @@ bool WalletImpl::recoverFromKeysWithPassword(const std::string &path,
const std::string &spendkey_string)
{
cryptonote::address_parse_info info;
- if(!get_account_address_from_str(info, m_wallet->testnet(), address_string))
+ if(!get_account_address_from_str(info, m_wallet->nettype(), address_string))
{
m_errorString = tr("failed to parse address");
m_status = Status_Error;
@@ -615,6 +626,9 @@ bool WalletImpl::recover(const std::string &path, const std::string &password, c
return false;
}
+ if (old_language == crypto::ElectrumWords::old_language_name)
+ old_language = Language::English().get_language_name();
+
try {
m_wallet->set_seed_language(old_language);
m_wallet->generate(path, password, recovery_key, true, false);
@@ -1091,7 +1105,7 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
PendingTransactionImpl * transaction = new PendingTransactionImpl(*this);
do {
- if(!cryptonote::get_account_address_from_str(info, m_wallet->testnet(), dst_addr)) {
+ if(!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), dst_addr)) {
// TODO: copy-paste 'if treating as an address fails, try as url' from simplewallet.cpp:1982
m_status = Status_Error;
m_errorString = "Invalid destination address";
@@ -1476,7 +1490,7 @@ bool WalletImpl::checkTxKey(const std::string &txid_str, std::string tx_key_str,
}
cryptonote::address_parse_info info;
- if (!cryptonote::get_account_address_from_str(info, m_wallet->testnet(), address_str))
+ if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address_str))
{
m_status = Status_Error;
m_errorString = tr("Failed to parse address");
@@ -1508,7 +1522,7 @@ std::string WalletImpl::getTxProof(const std::string &txid_str, const std::strin
}
cryptonote::address_parse_info info;
- if (!cryptonote::get_account_address_from_str(info, m_wallet->testnet(), address_str))
+ if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address_str))
{
m_status = Status_Error;
m_errorString = tr("Failed to parse address");
@@ -1539,7 +1553,7 @@ bool WalletImpl::checkTxProof(const std::string &txid_str, const std::string &ad
}
cryptonote::address_parse_info info;
- if (!cryptonote::get_account_address_from_str(info, m_wallet->testnet(), address_str))
+ if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address_str))
{
m_status = Status_Error;
m_errorString = tr("Failed to parse address");
@@ -1627,7 +1641,7 @@ std::string WalletImpl::getReserveProof(bool all, uint32_t account_index, uint64
bool WalletImpl::checkReserveProof(const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &total, uint64_t &spent) const {
cryptonote::address_parse_info info;
- if (!cryptonote::get_account_address_from_str(info, m_wallet->testnet(), address))
+ if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address))
{
m_status = Status_Error;
m_errorString = tr("Failed to parse address");
@@ -1664,7 +1678,7 @@ bool WalletImpl::verifySignedMessage(const std::string &message, const std::stri
{
cryptonote::address_parse_info info;
- if (!cryptonote::get_account_address_from_str(info, m_wallet->testnet(), address))
+ if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address))
return false;
return m_wallet->verify(message, info.address, signature);
@@ -1758,7 +1772,7 @@ void WalletImpl::doRefresh()
m_synchronized = true;
}
// assuming if we have empty history, it wasn't initialized yet
- // for futher history changes client need to update history in
+ // for further history changes client need to update history in
// "on_money_received" and "on_money_sent" callbacks
if (m_history->count() == 0) {
m_history->refresh();