* Scan active chain for relevant transactions after importing keys. This should * be called whenever new keys are added to the wallet, with the oldest key * creation time. * * @return Earliest timestamp that could be successfully scanned from. Timestamp * returned will be higher than startTime if relevant blocks could not be read. */
| 1832 | * returned will be higher than startTime if relevant blocks could not be read. |
| 1833 | */ |
| 1834 | int64_t CWallet::RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver) |
| 1835 | { |
| 1836 | // Find starting block. May be null if nCreateTime is greater than the |
| 1837 | // highest blockchain timestamp, in which case there is nothing that needs |
| 1838 | // to be scanned. |
| 1839 | int start_height = 0; |
| 1840 | uint256 start_block; |
| 1841 | bool start = chain().findFirstBlockWithTimeAndHeight(startTime - TIMESTAMP_WINDOW, 0, FoundBlock().hash(start_block).height(start_height)); |
| 1842 | WalletLogPrintf("%s: Rescanning last %i blocks\n", __func__, start ? WITH_LOCK(cs_wallet, return GetLastBlockHeight()) - start_height + 1 : 0); |
| 1843 | |
| 1844 | if (start) { |
| 1845 | // TODO: this should take into account failure by ScanResult::USER_ABORT |
| 1846 | ScanResult result = ScanForWalletTransactions(start_block, start_height, /*max_height=*/{}, reserver, /*save_progress=*/false); |
| 1847 | if (result.status == ScanResult::FAILURE) { |
| 1848 | int64_t time_max; |
| 1849 | CHECK_NONFATAL(chain().findBlock(result.last_failed_block, FoundBlock().maxTime(time_max))); |
| 1850 | return time_max + TIMESTAMP_WINDOW + 1; |
| 1851 | } |
| 1852 | } |
| 1853 | return startTime; |
| 1854 | } |
| 1855 | |
| 1856 | /** |
| 1857 | * Scan the block chain (starting in start_block) for transactions |
no test coverage detected