add bws settings in import wallet

This commit is contained in:
Javier 2015-10-16 12:35:18 -03:00
parent 3d6b393e7c
commit de0a06235f
3 changed files with 69 additions and 29 deletions

View File

@ -84,6 +84,12 @@
<switch id="network-name" name="isTestnet" ng-model="isTestnet" class="green right m5t m10b"></switch> <switch id="network-name" name="isTestnet" ng-model="isTestnet" class="green right m5t m10b"></switch>
</label> </label>
<label for="bws" class="oh">
<span translate>Specify Bitcore Wallet Service URL
<input type="text" id="bwsurl" type="text" name="bwsurl" ng-model="bwsurl">
</span>
</label>
<label for="passphrase" class="oh line-b"><span translate>Passphrase</span> <small translate>Wallet Seed could require a passphrase to be imported</small> <label for="passphrase" class="oh line-b"><span translate>Passphrase</span> <small translate>Wallet Seed could require a passphrase to be imported</small>
<div class="input"> <div class="input">
<input type="password" class="form-control" placeholder="{{'Seed passphrase'|translate}}" <input type="password" class="form-control" placeholder="{{'Seed passphrase'|translate}}"
@ -133,6 +139,13 @@
<input type="password" class="form-control" placeholder="{{'Your backup password'|translate}}" <input type="password" class="form-control" placeholder="{{'Your backup password'|translate}}"
name="password" ng-model="import.password"> name="password" ng-model="import.password">
</div> </div>
<label for="bws" class="oh">
<span translate>Specify Bitcore Wallet Service URL
<input type="text" id="bwsurl" type="text" name="bwsurl" ng-model="bwsurl">
</span>
</label>
<button translate type="submit" class="button round expand black" <button translate type="submit" class="button round expand black"
ng-disabled="importForm.$invalid || !import.password || import.loading"> ng-disabled="importForm.$invalid || !import.password || import.loading">
Import backup Import backup
@ -159,6 +172,12 @@
<form name="importForm3" ng-submit="import.importLedger(importForm3)" ng-show="index.isChromeApp" novalidate> <form name="importForm3" ng-submit="import.importLedger(importForm3)" ng-show="index.isChromeApp" novalidate>
<div class="large-12 columns"> <div class="large-12 columns">
<label for="bws" class="oh">
<span translate>Specify Bitcore Wallet Service URL
<input type="text" id="bwsurl" type="text" name="bwsurl" ng-model="bwsurl">
</span>
</label>
<!-- TODO: account <!-- TODO: account
<label class=" oh"> <label class=" oh">
<span translate>Ledger Slot</span> <span translate>Ledger Slot</span>
@ -176,10 +195,14 @@
<form name="importForm4" ng-submit="import.importTrezor(importForm4)" novalidate> <form name="importForm4" ng-submit="import.importTrezor(importForm4)" novalidate>
<div class="large-12 columns"> <div class="large-12 columns">
<label for="bws" class="oh">
<span translate>Specify Bitcore Wallet Service URL
<input type="text" id="bwsurl" type="text" name="bwsurl" ng-model="bwsurl">
</span>
</label>
<!-- ng-disabled="import.loading || import.ledger" --> <!-- ng-disabled="import.loading || import.ledger" -->
<button translate type="submit" class="button round expand black" <button translate type="submit" class="button round expand black" ng-disabled="true">
ng-disabled="true"
>
Import from TREZOR Import from TREZOR
</button> </button>
</div> </div>

View File

@ -4,7 +4,6 @@ angular.module('copayApp.controllers').controller('createController',
function($scope, $rootScope, $location, $timeout, $log, lodash, go, profileService, configService, isCordova, gettext, ledger, trezor, isMobile) { function($scope, $rootScope, $location, $timeout, $log, lodash, go, profileService, configService, isCordova, gettext, ledger, trezor, isMobile) {
var self = this; var self = this;
var config = configService.getSync();
var defaults = configService.getDefaults(); var defaults = configService.getDefaults();
this.isWindowsPhoneApp = isMobile.Windows() && isCordova; this.isWindowsPhoneApp = isMobile.Windows() && isCordova;

View File

@ -1,11 +1,12 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('importController', angular.module('copayApp.controllers').controller('importController',
function($scope, $rootScope, $location, $timeout, $log, profileService, notification, go, sjcl, gettext, lodash, ledger, trezor) { function($scope, $rootScope, $location, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor) {
var self = this; var self = this;
var reader = new FileReader(); var reader = new FileReader();
var defaults = configService.getDefaults();
$scope.bwsurl = defaults.bws.url;
window.ignoreMobilePause = true; window.ignoreMobilePause = true;
$scope.$on('$destroy', function() { $scope.$on('$destroy', function() {
@ -22,6 +23,19 @@ angular.module('copayApp.controllers').controller('importController',
}); });
}; };
var setBwsurl = function(walletId, cb) {
var opts = {
bws: {}
};
opts.bws[walletId] = $scope.bwsurl;
configService.set(opts, function(err) {
if (err) return cb(err);
$scope.$emit('Local/BWSUpdated');
applicationService.restart();
return cb(null);
});
}
var _importBlob = function(str, opts) { var _importBlob = function(str, opts) {
var str2, err; var str2, err;
try { try {
@ -50,15 +64,16 @@ angular.module('copayApp.controllers').controller('importController',
if (err) { if (err) {
self.error = err; self.error = err;
} else { } else {
$rootScope.$emit('Local/WalletImported', walletId); setBwsurl(walletId, function() {
go.walletHome(); $rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); go.walletHome();
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
});
} }
}); });
}, 100); }, 100);
}; };
var _importExtendedPrivateKey = function(xPrivKey) { var _importExtendedPrivateKey = function(xPrivKey) {
self.loading = true; self.loading = true;
@ -71,15 +86,16 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply(); $scope.$apply();
}); });
} }
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); setBwsurl(walletId, function() {
go.walletHome(); $rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
}); });
}, 100); }, 100);
}; };
var _importMnemonic = function(words, opts) { var _importMnemonic = function(words, opts) {
self.loading = true; self.loading = true;
@ -92,9 +108,11 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply(); $scope.$apply();
}); });
} }
$rootScope.$emit('Local/WalletImported', walletId); setBwsurl(walletId, function() {
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); $rootScope.$emit('Local/WalletImported', walletId);
go.walletHome(); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
}); });
}, 100); }, 100);
}; };
@ -138,7 +156,6 @@ angular.module('copayApp.controllers').controller('importController',
} }
}; };
this.importMnemonic = function(form) { this.importMnemonic = function(form) {
if (form.$invalid) { if (form.$invalid) {
this.error = gettext('There is an error in the form'); this.error = gettext('There is an error in the form');
@ -157,7 +174,7 @@ angular.module('copayApp.controllers').controller('importController',
if (!words) { if (!words) {
this.error = gettext('Please enter the seed words'); this.error = gettext('Please enter the seed words');
} else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) { } else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) {
return _importExtendedPrivateKey(words) return _importExtendedPrivateKey(words)
} else { } else {
var wordList = words.split(/[\u3000\s]+/); var wordList = words.split(/[\u3000\s]+/);
@ -173,7 +190,6 @@ angular.module('copayApp.controllers').controller('importController',
return; return;
} }
opts.passphrase = form.passphrase.$modelValue || null; opts.passphrase = form.passphrase.$modelValue || null;
opts.networkName = form.isTestnet.$modelValue ? 'testnet' : 'livenet'; opts.networkName = form.isTestnet.$modelValue ? 'testnet' : 'livenet';
@ -209,15 +225,15 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply(); $scope.$apply();
}); });
} }
$rootScope.$emit('Local/WalletImported', walletId); setBwsurl(walletId, function() {
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); $rootScope.$emit('Local/WalletImported', walletId);
go.walletHome(); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
}); });
}, 100); }, 100);
}; };
this.importLedger = function(form) { this.importLedger = function(form) {
var self = this; var self = this;
if (form.$invalid) { if (form.$invalid) {
@ -247,9 +263,11 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply(); $scope.$apply();
}); });
} }
$rootScope.$emit('Local/WalletImported', walletId); setBwsurl(walletId, function() {
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); $rootScope.$emit('Local/WalletImported', walletId);
go.walletHome(); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
}); });
}, 100); }, 100);
}; };