wallet: Add AddWallet, RemoveWallet, GetWallet and GetWallets

With these new functions all vpwallets usage are removed
and vpwallets is now a static variable (no external linkage).
This commit is contained in:
João Barbosa
2018-04-17 18:22:23 +01:00
parent 6efd9644cf
commit 373aee26c3
9 changed files with 72 additions and 38 deletions

View File

@@ -74,7 +74,7 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
// after.
{
CWallet wallet("dummy", WalletDatabase::CreateDummy());
vpwallets.insert(vpwallets.begin(), &wallet);
AddWallet(&wallet);
UniValue keys;
keys.setArray();
UniValue key;
@@ -105,7 +105,7 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
"downloading and rescanning the relevant blocks (see -reindex and -rescan "
"options).\"}},{\"success\":true}]",
0, oldTip->GetBlockTimeMax(), TIMESTAMP_WINDOW));
vpwallets.erase(vpwallets.begin());
RemoveWallet(&wallet);
}
}
@@ -140,9 +140,9 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
JSONRPCRequest request;
request.params.setArray();
request.params.push_back((pathTemp / "wallet.backup").string());
vpwallets.insert(vpwallets.begin(), &wallet);
AddWallet(&wallet);
::dumpwallet(request);
vpwallets.erase(vpwallets.begin());
RemoveWallet(&wallet);
}
// Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME
@@ -153,9 +153,9 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
JSONRPCRequest request;
request.params.setArray();
request.params.push_back((pathTemp / "wallet.backup").string());
vpwallets.insert(vpwallets.begin(), &wallet);
AddWallet(&wallet);
::importwallet(request);
vpwallets.erase(vpwallets.begin());
RemoveWallet(&wallet);
LOCK(wallet.cs_wallet);
BOOST_CHECK_EQUAL(wallet.mapWallet.size(), 3U);