aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wallet/wallet2.cpp30
-rwxr-xr-xtests/functional_tests/transfer.py7
2 files changed, 28 insertions, 9 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index f9e207d69..c0b9bfbc9 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -5334,13 +5334,14 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass
wallet_keys_unlocker unlocker(*this, m_ask_password == AskPasswordToDecrypt && !m_unattended && !m_watch_only, password);
//keys loaded ok!
- //try to load wallet file. but even if we failed, it is not big problem
- if (use_fs && (!boost::filesystem::exists(m_wallet_file, e) || e))
+ //try to load wallet cache. but even if we failed, it is not big problem
+ bool cache_missing = use_fs ? (!boost::filesystem::exists(m_wallet_file, e) || e) : cache_buf.empty();
+ if (cache_missing)
{
- LOG_PRINT_L0("file not found: " << m_wallet_file << ", starting with empty blockchain");
+ LOG_PRINT_L0("wallet cache missing: " << m_wallet_file << ", starting with empty blockchain");
m_account_public_address = m_account.get_keys().m_account_address;
}
- else if (use_fs || !cache_buf.empty())
+ else
{
wallet2::cache_file_data cache_file_data;
std::string cache_file_buf;
@@ -5754,6 +5755,27 @@ std::map<uint32_t, uint64_t> wallet2::balance_per_subaddress(uint32_t index_majo
amount_per_subaddr[0] = utx.second.m_change;
else
found->second += utx.second.m_change;
+
+ // add transfers to same wallet
+ for (const auto &dest: utx.second.m_dests) {
+ auto index = get_subaddress_index(dest.addr);
+ if (index && (*index).major == index_major)
+ {
+ auto found = amount_per_subaddr.find((*index).minor);
+ if (found == amount_per_subaddr.end())
+ amount_per_subaddr[(*index).minor] = dest.amount;
+ else
+ found->second += dest.amount;
+ }
+ }
+ }
+ }
+
+ for (const auto& utx: m_unconfirmed_payments)
+ {
+ if (utx.second.m_pd.m_subaddr_index.major == index_major)
+ {
+ amount_per_subaddr[utx.second.m_pd.m_subaddr_index.minor] += utx.second.m_pd.m_amount;
}
}
}
diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py
index fca9ce91c..07a24546e 100755
--- a/tests/functional_tests/transfer.py
+++ b/tests/functional_tests/transfer.py
@@ -171,7 +171,7 @@ class TransferTest():
assert e.double_spend_seen == False
assert not 'confirmations' in e or e.confirmations == 0
- running_balances[0] -= 1000000000000 + fee
+ running_balances[0] -= fee
res = self.wallet[0].get_balance()
assert res.balance == running_balances[0]
@@ -183,8 +183,6 @@ class TransferTest():
running_balances[0] += res.block_header.reward
self.wallet[0].refresh()
- running_balances[0] += 1000000000000
-
res = self.wallet[0].get_transfers()
assert len(res['in']) == height # coinbases
assert len(res.out) == 1 # not mined yet
@@ -337,7 +335,7 @@ class TransferTest():
assert len(res.unsigned_txset) == 0
unsigned_txset = res.unsigned_txset
- running_balances[0] -= 1000000000000 + 1100000000000 + 1200000000000 + fee
+ running_balances[0] -= 1100000000000 + 1200000000000 + fee
res = self.wallet[0].get_balance()
assert res.balance == running_balances[0]
@@ -347,7 +345,6 @@ class TransferTest():
daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1)
res = daemon.getlastblockheader()
running_balances[0] += res.block_header.reward
- running_balances[0] += 1000000000000
running_balances[1] += 1100000000000
running_balances[2] += 1200000000000
self.wallet[0].refresh()