Merge pull request #13 from JDonadio/feat/backup-needed
Warning backup needed
This commit is contained in:
commit
fa2aa37d91
9 changed files with 82 additions and 96 deletions
|
|
@ -1,7 +1,7 @@
|
|||
<div class="wallets" ng-show="wallets[0]">
|
||||
<ion-slides class="slides" slider="data.slider">
|
||||
<ion-slide-page ng-repeat="wallet in wallets track by $index">
|
||||
<div class="item item-icon-left">
|
||||
<div class="item item-icon-left item-icon-right">
|
||||
<i class="icon ion-briefcase size-21" ng-style="{'color':wallet.color}"></i>
|
||||
{{wallet.name || wallet.id}}
|
||||
<span class="item-note" ng-show="wallet.n > 1 && wallet.isComplete()">
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
<span class="badge badge-assertive" ng-show="!wallet.isComplete()" translate>
|
||||
Incomplete
|
||||
</span>
|
||||
<i ng-show="wallet.needsBackup" class="icon ion-android-warning assertive"></i>
|
||||
</div>
|
||||
</ion-slide-page>
|
||||
</ion-slides>
|
||||
|
|
|
|||
|
|
@ -4,39 +4,34 @@
|
|||
</ion-nav-bar>
|
||||
|
||||
<ion-content ng-controller="tabReceiveController" ng-init="init()">
|
||||
<div class="text-center m30v" copy-to-clipboard="addr" ng-show="addr">
|
||||
<qrcode size="220" data="bitcoin:{{addr}}" ng-show="addr"></qrcode>
|
||||
<div class="m30v text-center" copy-to-clipboard="addr">
|
||||
<qrcode size="220" data="bitcoin:{{addr}}"></qrcode>
|
||||
<div ng-if="wallet.needsBackup" class="assertive" translate>
|
||||
Before receiving funds, you must backup your wallet. If this device is lost, it is impossible to access your funds without a backup.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="padding assertive" ng-show="error">
|
||||
{{error|translate}}
|
||||
</div>
|
||||
|
||||
<div ng-show="generatingAddress" class="m30v">
|
||||
<div style="height:220px; width:220px; margin:auto; background: #eee; text-align:center">
|
||||
<div class="padding-top">
|
||||
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list card padding text-center" ng-if="!wallets[0]">
|
||||
<span translate>No Wallet</span>
|
||||
</div>
|
||||
|
||||
<div class="list" ng-if="wallets[0]">
|
||||
<div class="item item-icon-left" ng-click="shareAddress(addr)" ng-show="isCordova && addr" ng-disabled="generatingAddress">
|
||||
<div class="item item-icon-left" ng-click="shareAddress(addr)" ng-show="isCordova && addr">
|
||||
<i class="icon ion-ios-upload-outline"></i>
|
||||
<span translate>Share address</span>
|
||||
</div>
|
||||
<div class="item item-icon-left" ng-click="setAddress(null, true)" ng-disabled="">
|
||||
<div class="item item-icon-left" ng-click="setAddress(null, true)">
|
||||
<i class="icon ion-ios-loop"></i>
|
||||
<span translate>Next Address</span>
|
||||
</div>
|
||||
<div class="item item-icon-left">
|
||||
<i class="icon ion-social-bitcoin-outline"></i>
|
||||
<span ng-show="generatingAddress">...</span>
|
||||
<span ng-show="!generatingAddress" copy-to-clipboard="addr">{{addr}}</span>
|
||||
<span ng-if="generatingAddress">...</span>
|
||||
<span ng-if="!generatingAddress" copy-to-clipboard="addr">{{addr}}</span>
|
||||
</div>
|
||||
|
||||
<wallets ng-if="wallets[0]" wallets="wallets"></wallets>
|
||||
|
|
|
|||
|
|
@ -136,11 +136,8 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
}
|
||||
}
|
||||
|
||||
$log.debug('Backup done');
|
||||
storageService.setBackupFlag(wallet.credentials.walletId, function(err) {
|
||||
$log.debug('Backup stored');
|
||||
return cb();
|
||||
});
|
||||
profileService.setBackupFlag(walletClient.credentials.walletId);
|
||||
return cb();
|
||||
}, 1);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -183,12 +183,7 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
|
||||
|
||||
if (self.seedSourceId == 'set') {
|
||||
$timeout(function() {
|
||||
$log.debug('Backup done');
|
||||
storageService.setBackupFlag(wallet.credentials.walletId, function(err) {
|
||||
$log.debug('Backup stored');
|
||||
});
|
||||
}, 1);
|
||||
profileService.setBackupFlag(client.credentials.walletId);
|
||||
}
|
||||
$state.go('tabs.home')
|
||||
});
|
||||
|
|
|
|||
|
|
@ -109,12 +109,12 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
$rootScope.$emit('Local/WalletImported', client.credentials.walletId);
|
||||
if ($stateParams.fromOnboarding)
|
||||
profileService.setBackupFlag(client.credentials.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -141,12 +141,12 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
$rootScope.$emit('Local/WalletImported', client.credentials.walletId);
|
||||
if ($stateParams.fromOnboarding)
|
||||
profileService.setBackupFlag(client.credentials.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -166,12 +166,13 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
$scope.$apply();
|
||||
});
|
||||
}
|
||||
$rootScope.$emit('Local/WalletImported', walletId);
|
||||
if ($stateParams.fromOnboarding)
|
||||
|
||||
profileService.setBackupFlag(walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -200,12 +201,12 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
$rootScope.$emit('Local/WalletImported', client.credentials.walletId);
|
||||
if ($stateParams.fromOnboarding)
|
||||
profileService.setBackupFlag(client.credentials.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -339,12 +340,13 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.walletId)
|
||||
});
|
||||
$rootScope.$emit('Local/WalletImported', wallet.walletId);
|
||||
if ($stateParams.fromOnboarding)
|
||||
|
||||
profileService.setBackupFlag(wallet.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -421,13 +423,13 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.walletId)
|
||||
});
|
||||
$rootScope.$emit('Local/WalletImported', wallet.walletId);
|
||||
|
||||
if ($stateParams.fromOnboarding)
|
||||
profileService.setBackupFlag(wallet.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesDeleteWordsController', function($scope, $ionicHistory, $stateParams, $ionicNavBarDelegate, gettextCatalog, confirmDialog, lodash, profileService, walletService, gettext) {
|
||||
angular.module('copayApp.controllers').controller('preferencesDeleteWordsController', function($scope, $ionicHistory, $stateParams, $ionicNavBarDelegate, gettextCatalog, confirmDialog, lodash, profileService, gettext) {
|
||||
$ionicNavBarDelegate.title(gettextCatalog.getString('Delete recovery phrase'));
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
var msg = gettext('Are you sure you want to delete the recovery phrase?');
|
||||
var successMsg = gettext('Recovery phrase deleted');
|
||||
$scope.needsBackup = wallet.needsBackup;
|
||||
|
||||
walletService.needsBackup(wallet, function(needsBackup) {
|
||||
$scope.needsBackup = needsBackup;
|
||||
});
|
||||
if (lodash.isEmpty(wallet.credentials.mnemonic) && lodash.isEmpty(wallet.credentials.mnemonicEncrypted))
|
||||
$scope.deleted = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,35 +13,28 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
}
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, wallet) {
|
||||
if (lodash.isEmpty(wallet)) {
|
||||
if (!wallet) {
|
||||
$log.debug('No wallet provided');
|
||||
return;
|
||||
}
|
||||
$scope.defaultWallet = wallet;
|
||||
$scope.wallet = wallet;
|
||||
$log.debug('Wallet changed: ' + wallet.name);
|
||||
$scope.setAddress(wallet);
|
||||
});
|
||||
|
||||
$scope.shareAddress = function(addr) {
|
||||
if ($scope.generatingAddress) return;
|
||||
if ($scope.isCordova) {
|
||||
window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.setAddress = function(wallet, forceNew) {
|
||||
var wallet = wallet || $scope.defaultWallet;
|
||||
if ($scope.generatingAddress) return;
|
||||
|
||||
$scope.addr = null;
|
||||
var wallet = wallet || $scope.wallet;
|
||||
$scope.error = null;
|
||||
|
||||
if (wallet && !wallet.isComplete()) {
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.addr = null;
|
||||
$scope.generatingAddress = true;
|
||||
|
||||
$timeout(function() {
|
||||
|
|
@ -53,8 +46,9 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
if (addr)
|
||||
$scope.addr = addr;
|
||||
}
|
||||
$scope.$digest();
|
||||
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
}, 1);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,9 +36,35 @@ angular.module('copayApp.services')
|
|||
|
||||
wallet.name = config.aliasFor[wallet.id] || wallet.credentials.walletName;
|
||||
wallet.color = config.colorFor[wallet.id] || '#4A90E2';
|
||||
|
||||
}
|
||||
|
||||
root.setBackupFlag = function(walletId) {
|
||||
storageService.setBackupFlag(walletId, function(err) {
|
||||
if (err) $log.error(err);
|
||||
$log.debug('Backup flag stored');
|
||||
root.wallet[walletId].needsBackup = false;
|
||||
});
|
||||
};
|
||||
|
||||
function _requiresBackup(wallet) {
|
||||
if (wallet.isPrivKeyExternal()) return false;
|
||||
if (!wallet.credentials.mnemonic) return false;
|
||||
if (wallet.credentials.network == 'testnet') return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
function _needsBackup(wallet, cb) {
|
||||
if (!_requiresBackup(wallet))
|
||||
return cb(false);
|
||||
|
||||
storageService.getBackupFlag(wallet.credentials.walletId, function(err, val) {
|
||||
if (err) $log.error(err);
|
||||
if (val) return cb(false);
|
||||
return cb(true);
|
||||
});
|
||||
};
|
||||
|
||||
// Adds a wallet client to profileService
|
||||
root.bindWalletClient = function(wallet, opts) {
|
||||
var opts = opts || {};
|
||||
|
|
@ -52,18 +78,20 @@ angular.module('copayApp.services')
|
|||
wallet.id = walletId;
|
||||
wallet.started = true;
|
||||
wallet.doNotVerifyPayPro = isChromeApp;
|
||||
|
||||
|
||||
wallet.network = wallet.credentials.network;
|
||||
wallet.copayerId = wallet.credentials.copayerId;
|
||||
wallet.m = wallet.credentials.m;
|
||||
wallet.n = wallet.credentials.n;
|
||||
|
||||
root.updateWalletSettings(wallet);
|
||||
|
||||
root.wallet[walletId] = wallet;
|
||||
|
||||
_needsBackup(wallet, function(val) {
|
||||
wallet.needsBackup = val;
|
||||
});
|
||||
|
||||
wallet.removeAllListeners();
|
||||
|
||||
wallet.on('report', function(n) {
|
||||
$log.info('BWC Report:' + n);
|
||||
});
|
||||
|
|
@ -103,7 +131,6 @@ angular.module('copayApp.services')
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
$rootScope.$on('Local/SettingsUpdated', function(e, walletId) {
|
||||
if (!walletId || walletId == wallet.id) {
|
||||
$log.debug('Updating settings for wallet:' + wallet.id);
|
||||
|
|
|
|||
|
|
@ -65,27 +65,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
root.requiresBackup = function(wallet) {
|
||||
if (wallet.isPrivKeyExternal()) return false;
|
||||
if (!wallet.credentials.mnemonic) return false;
|
||||
if (wallet.credentials.network == 'testnet') return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
root.needsBackup = function(wallet, cb) {
|
||||
|
||||
if (!root.requiresBackup(wallet))
|
||||
return cb(false);
|
||||
|
||||
storageService.getBackupFlag(wallet.credentials.walletId, function(err, val) {
|
||||
if (err) $log.error(err);
|
||||
if (val) return cb(false);
|
||||
return cb(true);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// TODO
|
||||
// This handles errors from BWS/index which normally
|
||||
// trigger from async events (like updates).
|
||||
|
|
@ -815,11 +794,9 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
if (!wallet.isComplete())
|
||||
return cb('WALLET_NOT_COMPLETE');
|
||||
|
||||
root.needsBackup(wallet, function(needsBackup) {
|
||||
if (needsBackup)
|
||||
return cb('WALLET_NEEDS_BACKUP');
|
||||
return cb();
|
||||
});
|
||||
if (wallet.needsBackup)
|
||||
return cb('WALLET_NEEDS_BACKUP');
|
||||
return cb();
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -859,7 +836,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
askPassword(wallet.name, gettext('Enter new spending password'), function(password) {
|
||||
if (!password) return cb('no password');
|
||||
askPassword(wallet.name, gettext('Confirm you new spending password'), function(password2) {
|
||||
if (!password2 || password != password2)
|
||||
if (!password2 || password != password2)
|
||||
return cb('password mismatch');
|
||||
|
||||
wallet.encryptPrivateKey(password);
|
||||
|
|
@ -950,7 +927,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
}
|
||||
|
||||
root.prepare(wallet, function(err, password) {
|
||||
if (err) return cb('Prepare error: ' + err);
|
||||
if (err) return cb('Prepare error: ' + err);
|
||||
|
||||
ongoingProcess.set('sendingTx', true);
|
||||
publishFn(wallet, txp, function(err, publishedTxp) {
|
||||
|
|
@ -1040,7 +1017,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
if (wallet.credentials.derivationStrategy != 'BIP44' || !wallet.canSign())
|
||||
return null;
|
||||
|
||||
root.getKeys(wallet, function(err, keys){
|
||||
root.getKeys(wallet, function(err, keys) {
|
||||
if (err || !keys) return cb(err);
|
||||
|
||||
if (keys.mnemonic) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue