add bws settings in join wallet

This commit is contained in:
Javier 2015-10-16 13:00:41 -03:00
parent de0a06235f
commit a75bbe6e45
2 changed files with 28 additions and 6 deletions

View File

@ -77,6 +77,13 @@
</a>
<div ng-show="join.hideAdv" class="row">
<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>
<label for="hw-ledger" class="oh" ng-show="index.isChromeApp">
<span translate>Use Ledger hardware wallet</span>
<switch id="hw-ledger" name="hwLedger" ng-model="hwLedger" class="green right m5t m10b"></switch>

View File

@ -1,9 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, go, notification, profileService, isCordova, $modal, gettext, lodash, ledger, trezor) {
function($scope, $rootScope, $timeout, go, notification, profileService, configService, isCordova, $modal, gettext, lodash, ledger, trezor) {
var self = this;
var defaults = configService.getDefaults();
var defaults = configService.getDefaults();
$scope.bwsurl = defaults.bws.url;
this.onQrCodeScanned = function(data) {
$scope.secret = data;
@ -24,7 +27,7 @@ angular.module('copayApp.controllers').controller('joinController',
}
var setSeed = form.setSeed.$modelValue;
if (setSeed) {
if (setSeed) {
var words = form.privateKey.$modelValue;
if (words.indexOf(' ') == -1 && words.indexOf('prv') == 1 && words.length > 108) {
opts.extendedPrivateKey = words;
@ -40,10 +43,10 @@ angular.module('copayApp.controllers').controller('joinController',
this.error = gettext('Please enter the wallet seed');
return;
}
if (form.hwLedger.$modelValue || form.hwTrezor.$modelValue) {
self.hwWallet = form.hwLedger.$modelValue ? 'Ledger' : 'TREZOR';
var src= form.hwLedger.$modelValue ? ledger : trezor;
self.hwWallet = form.hwLedger.$modelValue ? 'Ledger' : 'TREZOR';
var src = form.hwLedger.$modelValue ? ledger : trezor;
var account = 0;
src.getInfoForNewWallet(account, function(err, lopts) {
@ -72,7 +75,19 @@ angular.module('copayApp.controllers').controller('joinController',
}
$timeout(function() {
var fc = profileService.focusedClient;
if ( fc.isComplete() && (opts.mnemonic || opts.externalSource || opts.extendedPrivateKey)) {
var opts_ = {
bws: {}
};
opts_.bws[fc.credentials.walletId] = $scope.bwsurl;
configService.set(opts_, function(err) {
if (err) console.log(err);
$scope.$emit('Local/BWSUpdated');
applicationService.restart();
});
if (fc.isComplete() && (opts.mnemonic || opts.externalSource || opts.extendedPrivateKey)) {
$rootScope.$emit('Local/WalletImported', fc.credentials.walletId);
} else {
go.walletHome();