[wallet] Move getBlockHeight from Chain::Lock interface to simple Chain

Add HaveChain to assert chain access for wallet-tool in LoadToWallet.
This commit is contained in:
Antoine Riard
2019-07-15 18:20:12 -04:00
parent b855592d83
commit de13363a47
4 changed files with 20 additions and 18 deletions

View File

@@ -885,10 +885,9 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
void CWallet::LoadToWallet(CWalletTx& wtxIn)
{
// If wallet doesn't have a chain (e.g bitcoin-wallet), lock can't be taken.
auto locked_chain = LockChain();
if (locked_chain) {
Optional<int> block_height = locked_chain->getBlockHeight(wtxIn.m_confirm.hashBlock);
// If wallet doesn't have a chain (e.g wallet-tool), don't bother to update txn.
if (HaveChain()) {
Optional<int> block_height = chain().getBlockHeight(wtxIn.m_confirm.hashBlock);
if (block_height) {
// Update cached block height variable since it not stored in the
// serialized transaction.