mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-22 15:48:51 +00:00
Merge pull request #203
583cf0a
Document existing function (warptangent)95eb944
Repeat prompt for wallet path if invalid (warptangent)
This commit is contained in:
commit
f4675dc05d
@ -345,14 +345,28 @@ bool simple_wallet::ask_wallet_create_if_needed()
|
|||||||
{
|
{
|
||||||
std::string wallet_path;
|
std::string wallet_path;
|
||||||
|
|
||||||
|
bool valid_path = false;
|
||||||
|
do {
|
||||||
wallet_path = command_line::input_line(
|
wallet_path = command_line::input_line(
|
||||||
"Specify wallet file name (e.g., wallet.bin). If the wallet doesn't exist, it will be created.\n"
|
"Specify wallet file name (e.g., wallet.bin). If the wallet doesn't exist, it will be created.\n"
|
||||||
"Wallet file name: "
|
"Wallet file name: "
|
||||||
);
|
);
|
||||||
|
valid_path = tools::wallet2::wallet_valid_path_format(wallet_path);
|
||||||
|
if (!valid_path)
|
||||||
|
{
|
||||||
|
fail_msg_writer() << "wallet file path not valid: " << wallet_path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!valid_path);
|
||||||
|
|
||||||
bool keys_file_exists;
|
bool keys_file_exists;
|
||||||
bool wallet_file_exists;
|
bool wallet_file_exists;
|
||||||
tools::wallet2::wallet_exists(wallet_path, keys_file_exists, wallet_file_exists);
|
tools::wallet2::wallet_exists(wallet_path, keys_file_exists, wallet_file_exists);
|
||||||
|
LOG_PRINT_L3("wallet_path: " << wallet_path << "");
|
||||||
|
LOG_PRINT_L3("keys_file_exists: " << std::boolalpha << keys_file_exists << std::noboolalpha
|
||||||
|
<< " wallet_file_exists: " << std::boolalpha << wallet_file_exists << std::noboolalpha);
|
||||||
|
|
||||||
|
LOG_PRINT_L1("Loading wallet...");
|
||||||
|
|
||||||
// add logic to error out if new wallet requested but named wallet file exists
|
// add logic to error out if new wallet requested but named wallet file exists
|
||||||
if (keys_file_exists || wallet_file_exists)
|
if (keys_file_exists || wallet_file_exists)
|
||||||
@ -635,6 +649,12 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
bool simple_wallet::open_wallet(const string &wallet_file, const std::string& password, bool testnet)
|
bool simple_wallet::open_wallet(const string &wallet_file, const std::string& password, bool testnet)
|
||||||
{
|
{
|
||||||
|
if (!tools::wallet2::wallet_valid_path_format(wallet_file))
|
||||||
|
{
|
||||||
|
fail_msg_writer() << "wallet file path not valid: " << wallet_file;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
m_wallet_file = wallet_file;
|
m_wallet_file = wallet_file;
|
||||||
m_wallet.reset(new tools::wallet2(testnet));
|
m_wallet.reset(new tools::wallet2(testnet));
|
||||||
m_wallet->callback(this);
|
m_wallet->callback(this);
|
||||||
|
@ -679,6 +679,11 @@ void wallet2::wallet_exists(const std::string& file_path, bool& keys_file_exists
|
|||||||
wallet_file_exists = boost::filesystem::exists(wallet_file, ignore);
|
wallet_file_exists = boost::filesystem::exists(wallet_file, ignore);
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
bool wallet2::wallet_valid_path_format(const std::string& file_path)
|
||||||
|
{
|
||||||
|
return !file_path.empty();
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
bool wallet2::parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id)
|
bool wallet2::parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id)
|
||||||
{
|
{
|
||||||
cryptonote::blobdata payment_id_data;
|
cryptonote::blobdata payment_id_data;
|
||||||
|
@ -229,7 +229,19 @@ namespace tools
|
|||||||
a & m_payments;
|
a & m_payments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Check if wallet keys and bin files exist
|
||||||
|
* \param file_path Wallet file path
|
||||||
|
* \param keys_file_exists Whether keys file exists
|
||||||
|
* \param wallet_file_exists Whether bin file exists
|
||||||
|
*/
|
||||||
static void wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists);
|
static void wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists);
|
||||||
|
/*!
|
||||||
|
* \brief Check if wallet file path is valid format
|
||||||
|
* \param file_path Wallet file path
|
||||||
|
* \return Whether path is valid format
|
||||||
|
*/
|
||||||
|
static bool wallet_valid_path_format(const std::string& file_path);
|
||||||
|
|
||||||
static bool parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
|
static bool parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user