mirror of https://github.com/m2049r/xmrwallet.git
Fix new wallet restore height (#858)
* New wallets: set current block height as the restore height. Go back 4 days for estimated heights
This commit is contained in:
parent
807db19603
commit
0f0b9a38c7
|
@ -916,9 +916,9 @@ public class LoginActivity extends BaseActivity
|
||||||
@Override
|
@Override
|
||||||
public boolean createWallet(File aFile, String password) {
|
public boolean createWallet(File aFile, String password) {
|
||||||
NodeInfo currentNode = getNode();
|
NodeInfo currentNode = getNode();
|
||||||
// get it from the connected node if we have one, and go back ca. 4 days
|
// get it from the connected node if we have one
|
||||||
final long restoreHeight =
|
final long restoreHeight =
|
||||||
(currentNode != null) ? currentNode.getHeight() - 2000 : -1;
|
(currentNode != null) ? currentNode.getHeight() : -1;
|
||||||
Wallet newWallet = WalletManager.getInstance()
|
Wallet newWallet = WalletManager.getInstance()
|
||||||
.createWallet(aFile, password, MNEMONIC_LANGUAGE, restoreHeight);
|
.createWallet(aFile, password, MNEMONIC_LANGUAGE, restoreHeight);
|
||||||
return checkAndCloseWallet(newWallet);
|
return checkAndCloseWallet(newWallet);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.m2049r.xmrwallet.util.RestoreHeight;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -96,8 +97,11 @@ public class WalletManager {
|
||||||
if (wallet.getStatus().isOk()) {
|
if (wallet.getStatus().isOk()) {
|
||||||
// (Re-)Estimate restore height based on what we know
|
// (Re-)Estimate restore height based on what we know
|
||||||
final long oldHeight = wallet.getRestoreHeight();
|
final long oldHeight = wallet.getRestoreHeight();
|
||||||
|
// Go back 4 days if we don't have a precise restore height
|
||||||
|
Calendar restoreDate = Calendar.getInstance();
|
||||||
|
restoreDate.add(Calendar.DAY_OF_MONTH, -4);
|
||||||
final long restoreHeight =
|
final long restoreHeight =
|
||||||
(height > -1) ? height : RestoreHeight.getInstance().getHeight(new Date());
|
(height > -1) ? height : RestoreHeight.getInstance().getHeight(restoreDate.getTime());
|
||||||
wallet.setRestoreHeight(restoreHeight);
|
wallet.setRestoreHeight(restoreHeight);
|
||||||
Timber.d("Changed Restore Height from %d to %d", oldHeight, wallet.getRestoreHeight());
|
Timber.d("Changed Restore Height from %d to %d", oldHeight, wallet.getRestoreHeight());
|
||||||
wallet.setPassword(password); // this rewrites the keys file (which contains the restore height)
|
wallet.setPassword(password); // this rewrites the keys file (which contains the restore height)
|
||||||
|
|
Loading…
Reference in New Issue