WalletAppKit: allow restore from wallet seed even when there are no checkpoints i.e. regtest mode

This commit is contained in:
Mike Hearn
2014-12-04 15:57:34 +01:00
parent 625d19230d
commit fccb6f03bd

View File

@@ -255,7 +255,8 @@ public class WalletAppKit extends AbstractIdleService {
// Initiate Bitcoin network objects (block store, blockchain and peer group) // Initiate Bitcoin network objects (block store, blockchain and peer group)
vStore = new SPVBlockStore(params, chainFile); vStore = new SPVBlockStore(params, chainFile);
if ((!chainFileExists || restoreFromSeed != null) && checkpoints != null) { if (!chainFileExists || restoreFromSeed != null) {
if (checkpoints != null) {
// Initialize the chain file with a checkpoint to speed up first-run sync. // Initialize the chain file with a checkpoint to speed up first-run sync.
long time; long time;
if (restoreFromSeed != null) { if (restoreFromSeed != null) {
@@ -271,6 +272,13 @@ public class WalletAppKit extends AbstractIdleService {
time = vWallet.getEarliestKeyCreationTime(); time = vWallet.getEarliestKeyCreationTime();
} }
CheckpointManager.checkpoint(params, checkpoints, vStore, time); CheckpointManager.checkpoint(params, checkpoints, vStore, time);
} else if (chainFileExists) {
log.info("Deleting the chain file in preparation from restore.");
vStore.close();
if (!chainFile.delete())
throw new Exception("Failed to delete chain file in preparation for restore.");
vStore = new SPVBlockStore(params, chainFile);
}
} }
vChain = new BlockChain(params, vStore); vChain = new BlockChain(params, vStore);
vPeerGroup = createPeerGroup(); vPeerGroup = createPeerGroup();