aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-08-26 10:32:00 +0200
committerRiccardo Spagni <ric@spagni.net>2016-08-26 10:32:00 +0200
commit9308b4e8b9fe30f05c771da4cb887cfbc6b09d26 (patch)
tree74854a58b121b7f2a3907d0764823bbe488909df /src/wallet
parentMerge pull request #976 (diff)
parentlibwallet_api: tests: checking for result while opening wallet (diff)
downloadmonero-9308b4e8b9fe30f05c771da4cb887cfbc6b09d26.tar.xz
Merge pull request #978
99dd572 libwallet_api: tests: checking for result while opening wallet (Ilya Kitaev) bcf7b67 libwallet_api: Wallet::amountFromString fixed (Ilya Kitaev) 32bc7b4 libwallet_api: helper method to return maximumAllowedAmount (Ilya Kitaev) cbe534d libwallet_api: tests: removed logged passwords (Ilya Kitaev) b1a5a93 libwallet_api: do not store wallet on close if status is not ok (Ilya Kitaev)
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/api/wallet.cpp15
-rw-r--r--src/wallet/wallet2_api.h1
2 files changed, 12 insertions, 4 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 4b97e2f1d..b3ee4112b 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -129,7 +129,7 @@ string Wallet::displayAmount(uint64_t amount)
uint64_t Wallet::amountFromString(const string &amount)
{
- uint64_t result;
+ uint64_t result = 0;
cryptonote::parse_amount(result, amount);
return result;
}
@@ -154,6 +154,11 @@ bool Wallet::paymentIdValid(const string &paiment_id)
return tools::wallet2::parse_short_payment_id(paiment_id, pid);
}
+uint64_t Wallet::maximumAllowedAmount()
+{
+ return std::numeric_limits<uint64_t>::max();
+}
+
///////////////////////// WalletImpl implementation ////////////////////////
WalletImpl::WalletImpl(bool testnet)
@@ -267,16 +272,18 @@ bool WalletImpl::recover(const std::string &path, const std::string &seed)
bool WalletImpl::close()
{
- clearStatus();
+
bool result = false;
try {
- // LOG_PRINT_L0("Calling wallet::store...");
- m_wallet->store();
+ // do not store wallet with invalid status
+ if (status() == Status_Ok)
+ m_wallet->store();
// LOG_PRINT_L0("wallet::store done");
// LOG_PRINT_L0("Calling wallet::stop...");
m_wallet->stop();
// LOG_PRINT_L0("wallet::stop done");
result = true;
+ clearStatus();
} catch (const std::exception &e) {
m_status = Status_Error;
m_errorString = e.what();
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index 2c5836573..e880b1c68 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -216,6 +216,7 @@ struct Wallet
static uint64_t amountFromDouble(double amount);
static std::string genPaymentId();
static bool paymentIdValid(const std::string &paiment_id);
+ static uint64_t maximumAllowedAmount();
/**
* @brief refresh - refreshes the wallet, updating transactions from daemon