From b1a5a937ff6177723c729f94624e282351de27bb Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Mon, 22 Aug 2016 15:53:07 +0300 Subject: libwallet_api: do not store wallet on close if status is not ok --- src/wallet/api/wallet.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 4b97e2f1d..ff74ec6c1 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -267,16 +267,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(); -- cgit v1.2.3 From 32bc7b41c0193297cc3b67a1b7a941813a407679 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Tue, 23 Aug 2016 12:35:01 +0300 Subject: libwallet_api: helper method to return maximumAllowedAmount --- src/wallet/api/wallet.cpp | 5 +++++ src/wallet/wallet2_api.h | 1 + 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index ff74ec6c1..a2066e62e 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -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::max(); +} + ///////////////////////// WalletImpl implementation //////////////////////// WalletImpl::WalletImpl(bool testnet) 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 -- cgit v1.2.3 From bcf7b67cd6f85cdf8bf7799aa3890a56ea58ddc8 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Tue, 23 Aug 2016 13:46:51 +0300 Subject: libwallet_api: Wallet::amountFromString fixed --- src/wallet/api/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index a2066e62e..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; } -- cgit v1.2.3