mirror of https://github.com/BTCPrivate/copay.git
import a wallet inside a profile
This commit is contained in:
parent
8b9ad143bb
commit
0e1cdda52d
|
@ -180,8 +180,6 @@ a:hover {
|
|||
.open input,
|
||||
.join input,
|
||||
.setup input,
|
||||
.import input,
|
||||
.import textarea,
|
||||
.settings input {
|
||||
border-radius: 2px;
|
||||
background: #EDEDED;
|
||||
|
@ -268,19 +266,6 @@ a:hover {
|
|||
color: #fff;
|
||||
}
|
||||
|
||||
.import fieldset, .settings fieldset {
|
||||
border: 1px solid #3C5269;
|
||||
}
|
||||
|
||||
.import fieldset legend, .settings fieldset legend {
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.import input[type="file"],
|
||||
.import label,
|
||||
.import label small,
|
||||
.settings label,
|
||||
.settings label small {
|
||||
color: #fff;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('ImportController',
|
||||
function($scope, $rootScope, $location, identity, controllerUtils, Passphrase, notification, isMobile) {
|
||||
controllerUtils.redirIfLogged();
|
||||
function($scope, $rootScope, $location, controllerUtils, Passphrase, notification, isMobile) {
|
||||
|
||||
$scope.title = 'Import a backup';
|
||||
$scope.importStatus = 'Importing wallet - Reading backup...';
|
||||
|
@ -17,10 +16,8 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
}
|
||||
|
||||
var _importBackup = function(encryptedObj) {
|
||||
Passphrase.getBase64Async($scope.password, function(passphrase) {
|
||||
var password = $scope.password;
|
||||
updateStatus('Importing wallet - Setting things up...');
|
||||
var w, errMsg;
|
||||
|
||||
var skipFields = [];
|
||||
if ($scope.skipPublicKeyRing)
|
||||
skipFields.push('publicKeyRing');
|
||||
|
@ -28,24 +25,18 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
if ($scope.skipTxProposals)
|
||||
skipFields.push('txProposals');
|
||||
|
||||
// try to import encrypted wallet with passphrase
|
||||
try {
|
||||
w = identity.fromEncryptedObj(encryptedObj, passphrase, skipFields);
|
||||
} catch (e) {
|
||||
errMsg = e.message;
|
||||
}
|
||||
|
||||
$rootScope.iden.importWallet(encryptedObj, password, skipFields, function(err, w) {
|
||||
if (!w) {
|
||||
$scope.loading = false;
|
||||
notification.error('Error', errMsg || 'Wrong password');
|
||||
notification.error('Error', err || 'Wrong password');
|
||||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
|
||||
// if wallet was never used, we're done
|
||||
if (!w.isReady()) {
|
||||
$rootScope.wallet = w;
|
||||
controllerUtils.startNetwork($rootScope.wallet, $scope);
|
||||
controllerUtils.installWalletHandlers($scope, w);
|
||||
controllerUtils.setFocusedWallet(w);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,10 +47,9 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
$scope.loading = false;
|
||||
notification.error('Error', 'Error updating indexes: ' + err);
|
||||
}
|
||||
$rootScope.wallet = w;
|
||||
controllerUtils.startNetwork($rootScope.wallet, $scope);
|
||||
controllerUtils.installWalletHandlers($scope, w);
|
||||
controllerUtils.setFocusedWallet(w);
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ Identity._newWallet = function(opts) {
|
|||
return new Wallet(opts);
|
||||
};
|
||||
|
||||
Identity._walletFromObj = function(o, s, n, b, skip) {
|
||||
return Wallet.fromObj(o, s, n, b, skip);
|
||||
Identity._walletFromObj = function(o, readOpts) {
|
||||
return Wallet.fromObj(o, readOpts);
|
||||
};
|
||||
|
||||
Identity._walletRead = function(id, r, cb) {
|
||||
|
@ -299,6 +299,7 @@ Identity.prototype.close = function(cb) {
|
|||
* @return {Wallet}
|
||||
*/
|
||||
Identity.prototype.importWallet = function(base64, password, skipFields, cb) {
|
||||
var self = this;
|
||||
preconditions.checkArgument(password);
|
||||
preconditions.checkArgument(cb);
|
||||
|
||||
|
@ -307,13 +308,22 @@ Identity.prototype.importWallet = function(base64, password, skipFields, cb) {
|
|||
var obj = this.storage.decrypt(base64);
|
||||
this.storage.restorePassphrase();
|
||||
|
||||
if (!obj) return false;
|
||||
var w = Identity._walletFromObj(obj, this.storage, this.networkOpts, this.blockchainOpts);
|
||||
console.log('[Identity.js.307:Identity:]', w); //TODO
|
||||
var readOpts = {
|
||||
storage: this.storage,
|
||||
networkOpts: this.networkOpts,
|
||||
blockchainOpts: this.blockchainOpts,
|
||||
skipFields: skipFields
|
||||
};
|
||||
|
||||
if (!obj) return cb(null);
|
||||
var w = Identity._walletFromObj(obj, readOpts);
|
||||
this._checkVersion(w.version);
|
||||
this.addWallet(w, function(err) {
|
||||
if (err) return cb(err);
|
||||
w.store(cb);
|
||||
if (err) return cb(err, null);
|
||||
self.openWallets.push(w);
|
||||
self.store(null, function(err) {
|
||||
return cb(err, w);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ Storage.prototype._decrypt = function(base64) {
|
|||
decryptedStr = decrypted.toString(CryptoJS.enc.Utf8);
|
||||
} catch (e) {
|
||||
// Error while decrypting
|
||||
log.debug(e.message);
|
||||
return null;
|
||||
}
|
||||
return decryptedStr;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services')
|
||||
.value('Passphrase', new copay.Passphrase(config.passphrase));
|
||||
.value('Passphrase', new copay.Passphrase(config.passphraseConfig));
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
{{ importStatus|translate }}
|
||||
</div>
|
||||
|
||||
<div class="row" ng-init="choosefile=0; pastetext=0" ng-show="!loading">
|
||||
<div class="large-4 columns logo-setup">
|
||||
<img src="img/logo-negative-beta.svg" alt="Copay" width="146" height="59">
|
||||
<div ng-include="'views/includes/version.html'"></div>
|
||||
</div>
|
||||
<div class="large-8 columns line-dashed-setup-v">
|
||||
<div class="row" ng-show="!loading">
|
||||
<div class="large-12 columns">
|
||||
|
||||
<div class="box-setup">
|
||||
<h1 class="text-white line-sidebar-b">{{title|translate}}</h1>
|
||||
<h1>{{title|translate}}</h1>
|
||||
<form name="importForm" ng-submit="import(importForm)" novalidate>
|
||||
<div ng-show="!is_iOS">
|
||||
<legend for="backupFile" class="m10b">
|
||||
|
@ -75,5 +70,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue