* 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. */
| 1578 | * returned will be higher than startTime if relevant blocks could not be read. |
| 1579 | */ |
| 1580 | int64_t CWallet::RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update) |
| 1581 | { |
| 1582 | // Find starting block. May be null if nCreateTime is greater than the |
| 1583 | // highest blockchain timestamp, in which case there is nothing that needs |
| 1584 | // to be scanned. |
| 1585 | int start_height = 0; |
| 1586 | uint256 start_block; |
| 1587 | bool start = chain().findFirstBlockWithTimeAndHeight(startTime - TIMESTAMP_WINDOW, 0, FoundBlock().hash(start_block).height(start_height)); |
| 1588 | WalletLogPrintf("%s: Rescanning last %i blocks\n", __func__, start ? WITH_LOCK(cs_wallet, return GetLastBlockHeight()) - start_height + 1 : 0); |
| 1589 | |
| 1590 | if (start) { |
| 1591 | // TODO: this should take into account failure by ScanResult::USER_ABORT |
| 1592 | ScanResult result = ScanForWalletTransactions(start_block, start_height, {} /* max_height */, reserver, update); |
| 1593 | if (result.status == ScanResult::FAILURE) { |
| 1594 | int64_t time_max; |
| 1595 | CHECK_NONFATAL(chain().findBlock(result.last_failed_block, FoundBlock().maxTime(time_max))); |
| 1596 | return time_max + TIMESTAMP_WINDOW + 1; |
| 1597 | } |
| 1598 | } |
| 1599 | return startTime; |
| 1600 | } |
| 1601 | |
| 1602 | /** |
| 1603 | * Scan the block chain (starting in start_block) for transactions |
no test coverage detected