mirror of https://github.com/m2049r/xmrwallet.git
Better offline estimation of restore height (#398)
* 2018-09-01 blockheight * better offline restore height estimate for new wallets
This commit is contained in:
parent
8b016f93dc
commit
4215a8bf9e
|
@ -686,7 +686,13 @@ Java_com_m2049r_xmrwallet_model_Wallet_initJ(JNIEnv *env, jobject instance,
|
|||
}
|
||||
|
||||
// virtual bool createWatchOnly(const std::string &path, const std::string &password, const std::string &language) const = 0;
|
||||
// virtual void setRefreshFromBlockHeight(uint64_t refresh_from_block_height) = 0;
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_m2049r_xmrwallet_model_Wallet_setRestoreHeight(JNIEnv *env, jobject instance,
|
||||
jlong height) {
|
||||
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
|
||||
wallet->setRefreshFromBlockHeight((uint64_t) height);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_com_m2049r_xmrwallet_model_Wallet_getRestoreHeight(JNIEnv *env, jobject instance) {
|
||||
|
|
|
@ -151,6 +151,8 @@ public class Wallet {
|
|||
// virtual bool createWatchOnly(const std::string &path, const std::string &password, const std::string &language) const = 0;
|
||||
// virtual void setRefreshFromBlockHeight(uint64_t refresh_from_block_height) = 0;
|
||||
|
||||
public native void setRestoreHeight(long height);
|
||||
|
||||
public native long getRestoreHeight();
|
||||
|
||||
// virtual void setRecoveringFromSeed(bool recoveringFromSeed) = 0;
|
||||
|
|
|
@ -18,6 +18,7 @@ package com.m2049r.xmrwallet.model;
|
|||
|
||||
import com.m2049r.xmrwallet.data.WalletNode;
|
||||
import com.m2049r.xmrwallet.ledger.Ledger;
|
||||
import com.m2049r.xmrwallet.util.RestoreHeight;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -25,6 +26,7 @@ import java.io.FileReader;
|
|||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
@ -76,6 +78,13 @@ public class WalletManager {
|
|||
long walletHandle = createWalletJ(aFile.getAbsolutePath(), password, language, getNetworkType().getValue());
|
||||
Wallet wallet = new Wallet(walletHandle);
|
||||
manageWallet(wallet);
|
||||
if (wallet.getStatus() == Wallet.Status.Status_Ok) {
|
||||
// (Re-)Estimate restore height based on what we know
|
||||
long oldHeight = wallet.getRestoreHeight();
|
||||
wallet.setRestoreHeight(RestoreHeight.getInstance().getHeight(new Date()));
|
||||
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)
|
||||
}
|
||||
return wallet;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ public class RestoreHeight {
|
|||
blockheight.put("2018-06-01", 1585135L);
|
||||
blockheight.put("2018-07-01", 1606715L);
|
||||
blockheight.put("2018-08-01", 1629017L);
|
||||
blockheight.put("2018-09-01", 1651347L);
|
||||
}
|
||||
|
||||
public long getHeight(String date) {
|
||||
|
|
Loading…
Reference in New Issue