aboutsummaryrefslogtreecommitdiff
path: root/js/Wizard.js
diff options
context:
space:
mode:
authormmbyday <mmbyday@protonmail.com>2019-05-14 20:21:09 -0700
committermmbyday <mmbyday@protonmail.com>2019-05-24 11:58:46 -0700
commitca9883b6c0c2dfe91f77462bc4909c5305e1126a (patch)
tree90fc97f77fed14bc1aba573628ea1ab42b4c285c /js/Wizard.js
parentc286c7e5a8e67d769bc9054f661ab742a8b1a5ba (diff)
downloadmonzero-gui-ca9883b6c0c2dfe91f77462bc4909c5305e1126a.tar.gz
monzero-gui-ca9883b6c0c2dfe91f77462bc4909c5305e1126a.tar.xz
monzero-gui-ca9883b6c0c2dfe91f77462bc4909c5305e1126a.zip
Fix restore height when using stagenet/testnet
Diffstat (limited to 'js/Wizard.js')
-rw-r--r--js/Wizard.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/js/Wizard.js b/js/Wizard.js
index 44954c8a..8bdc4616 100644
--- a/js/Wizard.js
+++ b/js/Wizard.js
@@ -134,15 +134,15 @@ function restoreWalletCheckViewSpendAddress(walletmanager, nettype, viewkey, spe
//usage: getApproximateBlockchainHeight("March 18 2016") or getApproximateBlockchainHeight("2016-11-11")
//returns estimated block height with 1 month buffer prior to requested date.
-function getApproximateBlockchainHeight(_date){
+function getApproximateBlockchainHeight(_date, _nettype){
// time of monero birth 2014-04-18 10:49:53 (1397818193)
- var moneroBirthTime = 1397818193;
+ var moneroBirthTime = _nettype == "Mainnet" ? 1397818193 : _nettype == "Testnet" ? 1410295020 : 1518932025;
// avg seconds per block in v1
var secondsPerBlockV1 = 60;
// time of v2 fork 2016-03-23 15:57:38 (1458748658)
- var forkTime = 1458748658;
+ var forkTime = _nettype == "Mainnet" ? 1458748658 : _nettype == "Testnet" ? 1448285909 : 1520937818;
// v2 fork block
- var forkBlock = 1009827;
+ var forkBlock = _nettype == "Mainnet" ? 1009827 : _nettype == "Testnet" ? 624634 : 32000;
// avg seconds per block in V2
var secondsPerBlockV2 = 120;
// time in UTC
@@ -166,6 +166,14 @@ function getApproximateBlockchainHeight(_date){
console.log("Calculated blockchain height: " + approxBlockchainHeight );
secondsPerBlock = secondsPerBlockV2;
}
+
+ if(_nettype == "Testnet"){
+ // testnet got some huge rollbacks, so the estimation is way off
+ var approximateTestnetRolledBackBlocks = 303967;
+ if(approxBlockchainHeight > approximateTestnetRolledBackBlocks)
+ approxBlockchainHeight -= approximateTestnetRolledBackBlocks
+ }
+
var blocksPerMonth = 60*60*24*30/secondsPerBlock;
if(approxBlockchainHeight - blocksPerMonth > 0){
return approxBlockchainHeight - blocksPerMonth;