diff options
Diffstat (limited to 'src/walletcmd.cpp')
| -rw-r--r-- | src/walletcmd.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/walletcmd.cpp b/src/walletcmd.cpp index 8eb3592..fae2095 100644 --- a/src/walletcmd.cpp +++ b/src/walletcmd.cpp | |||
| @@ -25,6 +25,10 @@ | |||
| 25 | // would restore a wallet that looks empty. | 25 | // would restore a wallet that looks empty. |
| 26 | static const int RESTORE_BATCH = 100; | 26 | static const int RESTORE_BATCH = 100; |
| 27 | static const int RESTORE_MAX = 10000; | 27 | static const int RESTORE_MAX = 10000; |
| 28 | // The wallet may have a full unused key pool in front of a change address | ||
| 29 | // created while spending pre-phrase coins. Looking only one empty batch ahead | ||
| 30 | // can stop just before that change output. | ||
| 31 | static const int RESTORE_MIN_SCAN = KEYPOOL_SIZE + RESTORE_BATCH; | ||
| 28 | 32 | ||
| 29 | int CmdNewPhrase() | 33 | int CmdNewPhrase() |
| 30 | { | 34 | { |
| @@ -105,6 +109,7 @@ bool RestoreFromPhrase(const std::string& strMnemonic, | |||
| 105 | // up nothing. Every derived key is written to the wallet before the scan, | 109 | // up nothing. Every derived key is written to the wallet before the scan, |
| 106 | // because the scan asks the wallet what belongs to it. | 110 | // because the scan asks the wallet what belongs to it. |
| 107 | int nTotalDerived = (int)nHDNext; | 111 | int nTotalDerived = (int)nHDNext; |
| 112 | int nStopDepth = max(nMinDepth, RESTORE_MIN_SCAN); | ||
| 108 | while (nTotalDerived < RESTORE_MAX) | 113 | while (nTotalDerived < RESTORE_MAX) |
| 109 | { | 114 | { |
| 110 | // Count wallet transactions, not scan hits. | 115 | // Count wallet transactions, not scan hits. |
| @@ -146,7 +151,7 @@ bool RestoreFromPhrase(const std::string& strMnemonic, | |||
| 146 | 151 | ||
| 147 | // A whole batch with nothing in it means far enough -- unless the | 152 | // A whole batch with nothing in it means far enough -- unless the |
| 148 | // caller asked to look deeper anyway. | 153 | // caller asked to look deeper anyway. |
| 149 | if (nWalletAfter == nWalletBefore && nTotalDerived >= nMinDepth) | 154 | if (nWalletAfter == nWalletBefore && nTotalDerived >= nStopDepth) |
| 150 | break; | 155 | break; |
| 151 | } | 156 | } |
| 152 | 157 | ||