diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -124,10 +124,6 @@ //! Get block time. Height must be valid or this function will abort. virtual int64_t getBlockTime(int height) = 0; - //! Get block median time past. Height must be valid or this function - //! will abort. - virtual int64_t getBlockMedianTimePast(int height) = 0; - //! Check that the block is available on disk (i.e. has not been //! pruned), and contains transactions. virtual bool haveBlockOnDisk(int height) = 0; diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -94,12 +94,6 @@ assert(block != nullptr); return block->GetBlockTime(); } - int64_t getBlockMedianTimePast(int height) override { - LockAssertion lock(::cs_main); - CBlockIndex *block = ::ChainActive()[height]; - assert(block != nullptr); - return block->GetMedianTimePast(); - } bool haveBlockOnDisk(int height) override { LockAssertion lock(::cs_main); CBlockIndex *block = ::ChainActive()[height]; diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -1720,21 +1720,15 @@ EnsureWalletIsUnlocked(pwallet); // Verify all timestamps are present before importing any keys. - const Optional tip_height = locked_chain->getHeight(); - now = - tip_height ? locked_chain->getBlockMedianTimePast(*tip_height) : 0; + CHECK_NONFATAL(pwallet->chain().findBlock( + pwallet->GetLastBlockHash(), + FoundBlock().time(nLowestTimestamp).mtpTime(now))); for (const UniValue &data : requests.getValues()) { GetImportTimestamp(data, now); } const int64_t minimumTimestamp = 1; - if (fRescan && tip_height) { - nLowestTimestamp = locked_chain->getBlockTime(*tip_height); - } else { - fRescan = false; - } - for (const UniValue &data : requests.getValues()) { const int64_t timestamp = std::max(GetImportTimestamp(data, now), minimumTimestamp); 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 @@ -165,6 +165,9 @@ std::make_shared(Params(), chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); wallet->SetupLegacyScriptPubKeyMan(); + WITH_LOCK(wallet->cs_wallet, + wallet->SetLastBlockProcessed(newTip->nHeight, + newTip->GetBlockHash())); AddWallet(wallet); UniValue keys; keys.setArray();