Ledger hardware wallet support

This commit is contained in:
Eric Larchevêque 2015-07-17 15:53:50 +02:00 committed by Matias Alejo Garcia
commit d3f77b37ad
9 changed files with 693 additions and 23 deletions

View file

@ -1,9 +1,15 @@
'use strict';
angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, go, isMobile, notification, profileService, isCordova, $modal, gettext) {
function($scope, $rootScope, $timeout, go, isMobile, notification, profileService, isCordova, isChromeApp, $modal, gettext, lodash, ledger) {
var self = this;
this.externatIndexValues = lodash.range(0,20);
$scope.externalIndex = 0;
this.isChromeApp = function() {
return isChromeApp;
};
//TODO : make one function - this was copied from topbar.js
var cordovaOpenScanner = function() {
@ -145,12 +151,37 @@ angular.module('copayApp.controllers').controller('joinController',
}
self.loading = true;
var opts = {
secret: form.secret.$modelValue,
extendedPrivateKey: form.privateKey.$modelValue,
myName: form.myName.$modelValue
}
if (form.hwLedger.$modelValue) {
self.ledger = true;
ledger.getXPubKey($scope.externalIndex, function(data) {
self.ledger = false;
$scope.$apply();
if (data.success) {
opts.extendedPublicKey = data.xpubkey;
opts.externalSource = 'ledger';
opts.externalIndex = $scope.externalIndex;
self._join(opts);
} else {
self.loading = false;
$log.debug(data.message);
self.error = data.message;
$scope.$apply();
}
});
} else {
self._join(opts);
}
};
this._join = function(opts) {
$timeout(function() {
profileService.joinWallet({
secret: form.secret.$modelValue,
extendedPrivateKey: form.privateKey.$modelValue,
myName: form.myName.$modelValue
}, function(err) {
profileService.joinWallet(opts, function(err) {
if (err) {
self.loading = false;
self.error = err;
@ -162,5 +193,5 @@ angular.module('copayApp.controllers').controller('joinController',
}, 2000);
});
}, 100);
}
};
});