Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115403
D7868.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D7868.diff
View Options
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -673,8 +673,8 @@
throw JSONRPCError(RPC_INVALID_PARAMETER,
"Cannot open wallet dump file");
}
- Optional<int> tip_height = locked_chain->getHeight();
- nTimeBegin = tip_height ? locked_chain->getBlockTime(*tip_height) : 0;
+ CHECK_NONFATAL(pwallet->chain().findBlock(
+ pwallet->GetLastBlockHash(), FoundBlock().time(nTimeBegin)));
int64_t nFilesize = std::max<int64_t>(1, file.tellg());
file.seekg(0, file.beg);
@@ -944,16 +944,13 @@
// produce output
file << strprintf("# Wallet dump created by Bitcoin %s\n", CLIENT_BUILD);
file << strprintf("# * Created on %s\n", FormatISO8601DateTime(GetTime()));
- const Optional<int> tip_height = locked_chain->getHeight();
file << strprintf("# * Best block at time of backup was %i (%s),\n",
- tip_height.value_or(-1),
- tip_height
- ? locked_chain->getBlockHash(*tip_height).ToString()
- : "(missing block hash)");
- file << strprintf("# mined on %s\n",
- tip_height ? FormatISO8601DateTime(
- locked_chain->getBlockTime(*tip_height))
- : "(missing block time)");
+ pwallet->GetLastBlockHeight(),
+ pwallet->GetLastBlockHash().ToString());
+ int64_t block_time = 0;
+ CHECK_NONFATAL(pwallet->chain().findBlock(pwallet->GetLastBlockHash(),
+ FoundBlock().time(block_time)));
+ file << strprintf("# mined on %s\n", FormatISO8601DateTime(block_time));
file << "\n";
// add the base58check encoded extended master if the wallet uses HD
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -257,6 +257,8 @@
request.params.setArray();
request.params.push_back(backup_file);
AddWallet(wallet);
+ wallet->SetLastBlockProcessed(::ChainActive().Height(),
+ ::ChainActive().Tip()->GetBlockHash());
::dumpwallet(GetConfig(), request);
RemoveWallet(wallet);
}
@@ -267,16 +269,18 @@
std::shared_ptr<CWallet> wallet =
std::make_shared<CWallet>(Params(), chain.get(), WalletLocation(),
WalletDatabase::CreateDummy());
+ LOCK(wallet->cs_wallet);
wallet->SetupLegacyScriptPubKeyMan();
JSONRPCRequest request;
request.params.setArray();
request.params.push_back(backup_file);
AddWallet(wallet);
+ wallet->SetLastBlockProcessed(::ChainActive().Height(),
+ ::ChainActive().Tip()->GetBlockHash());
::importwallet(GetConfig(), request);
RemoveWallet(wallet);
- LOCK(wallet->cs_wallet);
BOOST_CHECK_EQUAL(wallet->mapWallet.size(), 3U);
BOOST_CHECK_EQUAL(m_coinbase_txns.size(), 103U);
for (size_t i = 0; i < m_coinbase_txns.size(); ++i) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:03 (15 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5182976
Default Alt Text
D7868.diff (3 KB)
Attached To
D7868: wallet: Avoid use of Chain::Lock in importwallet and dumpwallet
Event Timeline
Log In to Comment