|
14 | 14 | #include <sync.h>
|
15 | 15 | #include <ui_interface.h>
|
16 | 16 | #include <uint256.h>
|
| 17 | +#include <util/check.h> |
17 | 18 | #include <util/system.h>
|
18 | 19 | #include <wallet/feebumper.h>
|
19 | 20 | #include <wallet/fees.h>
|
@@ -62,7 +63,7 @@ WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx)
|
62 | 63 | WalletTxStatus MakeWalletTxStatus(interfaces::Chain::Lock& locked_chain, const CWalletTx& wtx)
|
63 | 64 | {
|
64 | 65 | WalletTxStatus result;
|
65 |
| - result.block_height = locked_chain.getBlockHeight(wtx.m_confirm.hashBlock).get_value_or(std::numeric_limits<int>::max()); |
| 66 | + result.block_height = wtx.m_confirm.block_height > 0 ? wtx.m_confirm.block_height : std::numeric_limits<int>::max(); |
66 | 67 | result.blocks_to_maturity = wtx.GetBlocksToMaturity();
|
67 | 68 | result.depth_in_main_chain = wtx.GetDepthInMainChain();
|
68 | 69 | result.time_received = wtx.nTimeReceived;
|
@@ -317,13 +318,9 @@ class WalletImpl : public Wallet
|
317 | 318 | if (mi == m_wallet->mapWallet.end()) {
|
318 | 319 | return false;
|
319 | 320 | }
|
320 |
| - if (Optional<int> height = locked_chain->getHeight()) { |
321 |
| - num_blocks = *height; |
322 |
| - block_time = locked_chain->getBlockTime(*height); |
323 |
| - } else { |
324 |
| - num_blocks = -1; |
325 |
| - block_time = -1; |
326 |
| - } |
| 321 | + num_blocks = m_wallet->GetLastBlockHeight(); |
| 322 | + block_time = -1; |
| 323 | + CHECK_NONFATAL(m_wallet->chain().findBlock(m_wallet->GetLastBlockHash(), FoundBlock().time(block_time))); |
327 | 324 | tx_status = MakeWalletTxStatus(*locked_chain, mi->second);
|
328 | 325 | return true;
|
329 | 326 | }
|
@@ -372,12 +369,12 @@ class WalletImpl : public Wallet
|
372 | 369 | {
|
373 | 370 | auto locked_chain = m_wallet->chain().lock(true /* try_lock */);
|
374 | 371 | if (!locked_chain) return false;
|
375 |
| - num_blocks = locked_chain->getHeight().get_value_or(-1); |
376 |
| - if (!force && num_blocks == cached_num_blocks) return false; |
377 | 372 | TRY_LOCK(m_wallet->cs_wallet, locked_wallet);
|
378 | 373 | if (!locked_wallet) {
|
379 | 374 | return false;
|
380 | 375 | }
|
| 376 | + num_blocks = m_wallet->GetLastBlockHeight(); |
| 377 | + if (!force && num_blocks == cached_num_blocks) return false; |
381 | 378 | balances = getBalances();
|
382 | 379 | return true;
|
383 | 380 | }
|
|
0 commit comments