mirror of https://github.com/BTCPrivate/copay.git
added import from text backup
This commit is contained in:
parent
b79caed7fc
commit
960b64affe
|
@ -188,7 +188,10 @@
|
||||||
<h3>{{title}}</h3>
|
<h3>{{title}}</h3>
|
||||||
<div class="large-6 columns">
|
<div class="large-6 columns">
|
||||||
<input type="password" class="form-control" placeholder="Your wallet password" ng-model="password" autofocus>
|
<input type="password" class="form-control" placeholder="Your wallet password" ng-model="password" autofocus>
|
||||||
|
<h6>Select a backup file</h6>
|
||||||
<input type="file" class="form-control" placeholder="Select a backup file" ng-model="backupFile" ng-file-select>
|
<input type="file" class="form-control" placeholder="Select a backup file" ng-model="backupFile" ng-file-select>
|
||||||
|
<h6>Or just pate the backup text here</h6>
|
||||||
|
<textarea class="form-control" ng-model="backupText"></textarea>
|
||||||
<button class="button primary expand radius" ng-click="import()">Import backup</button>
|
<button class="button primary expand radius" ng-click="import()">Import backup</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,6 +4,13 @@ angular.module('copay.import').controller('ImportController',
|
||||||
function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) {
|
function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) {
|
||||||
$scope.title = 'Import a backup';
|
$scope.title = 'Import a backup';
|
||||||
|
|
||||||
|
|
||||||
|
var _importBackup = function(encryptedObj) {
|
||||||
|
var passphrase = Passphrase.getBase64($scope.password);
|
||||||
|
$rootScope.wallet = walletFactory.fromEncryptedObj(encryptedObj, passphrase);
|
||||||
|
controllerUtils.startNetwork($rootScope.wallet);
|
||||||
|
};
|
||||||
|
|
||||||
$scope.getFile = function() {
|
$scope.getFile = function() {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
|
|
||||||
|
@ -11,17 +18,18 @@ angular.module('copay.import').controller('ImportController',
|
||||||
reader.onloadend = function(evt) {
|
reader.onloadend = function(evt) {
|
||||||
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
|
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
|
||||||
var encryptedObj = evt.target.result;
|
var encryptedObj = evt.target.result;
|
||||||
var passphrase = Passphrase.getBase64($scope.password);
|
_importBackup(encryptedObj);
|
||||||
$rootScope.wallet = walletFactory.fromEncryptedObj(encryptedObj, passphrase);
|
|
||||||
controllerUtils.startNetwork($rootScope.wallet);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
$scope.import = function() {
|
$scope.import = function() {
|
||||||
if ($scope.password != '') {
|
if ($scope.password != '') {
|
||||||
|
if ($scope.backupText != '') {
|
||||||
|
_importBackup($scope.backupText);
|
||||||
|
} else {
|
||||||
reader.readAsBinaryString($scope.file);
|
reader.readAsBinaryString($scope.file);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue