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>
</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>
<div class="input">
<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}}"
name="password" ng-model="import.password">
</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"
ng-disabled="importForm.$invalid || !import.password || import.loading">
Import backup
@ -159,6 +172,12 @@
<form name="importForm3" ng-submit="import.importLedger(importForm3)" ng-show="index.isChromeApp" novalidate>
<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
<label class=" oh">
<span translate>Ledger Slot</span>
@ -176,10 +195,14 @@
<form name="importForm4" ng-submit="import.importTrezor(importForm4)" novalidate>
<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" -->
<button translate type="submit" class="button round expand black"
ng-disabled="true"
>
<button translate type="submit" class="button round expand black" ng-disabled="true">
Import from TREZOR
</button>
</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) {
var self = this;
var config = configService.getSync();
var defaults = configService.getDefaults();
this.isWindowsPhoneApp = isMobile.Windows() && isCordova;

View File

@ -1,11 +1,12 @@
'use strict';
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 reader = new FileReader();
var defaults = configService.getDefaults();
$scope.bwsurl = defaults.bws.url;
window.ignoreMobilePause = true;
$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 str2, err;
try {
@ -50,15 +64,16 @@ angular.module('copayApp.controllers').controller('importController',
if (err) {
self.error = err;
} else {
$rootScope.$emit('Local/WalletImported', walletId);
go.walletHome();
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
setBwsurl(walletId, function() {
$rootScope.$emit('Local/WalletImported', walletId);
go.walletHome();
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
});
}
});
}, 100);
};
var _importExtendedPrivateKey = function(xPrivKey) {
self.loading = true;
@ -71,15 +86,16 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply();
});
}
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
setBwsurl(walletId, function() {
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
});
}, 100);
};
var _importMnemonic = function(words, opts) {
self.loading = true;
@ -92,9 +108,11 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply();
});
}
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
setBwsurl(walletId, function() {
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
});
}, 100);
};
@ -138,7 +156,6 @@ angular.module('copayApp.controllers').controller('importController',
}
};
this.importMnemonic = function(form) {
if (form.$invalid) {
this.error = gettext('There is an error in the form');
@ -157,7 +174,7 @@ angular.module('copayApp.controllers').controller('importController',
if (!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)
} else {
var wordList = words.split(/[\u3000\s]+/);
@ -173,7 +190,6 @@ angular.module('copayApp.controllers').controller('importController',
return;
}
opts.passphrase = form.passphrase.$modelValue || null;
opts.networkName = form.isTestnet.$modelValue ? 'testnet' : 'livenet';
@ -209,15 +225,15 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply();
});
}
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
setBwsurl(walletId, function() {
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
});
}, 100);
};
this.importLedger = function(form) {
var self = this;
if (form.$invalid) {
@ -247,9 +263,11 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply();
});
}
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
setBwsurl(walletId, function() {
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
});
}, 100);
};