mirror of https://github.com/BTCPrivate/copay.git
fix account indexes, add base path in settings
This commit is contained in:
parent
5abf35c68c
commit
791efca714
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
Copay accepts three base derivation paths:
|
||||||
|
|
||||||
|
* m/44'
|
||||||
|
* m/48' (only used for MULTISIGNATURE, HARDWARE Wallets)
|
||||||
|
* m/45' (deprecated and it is only supported for old wallets)
|
||||||
|
|
||||||
|
Both m/44 and m/48 follow the BIP44 standard:
|
||||||
|
|
||||||
|
m/XX'/<coin_type>'/<account'>
|
||||||
|
|
||||||
|
Supported cointypes are: 0: Livenet, and 1: Testnet
|
||||||
|
|
||||||
|
If you need to import a wallet from a mnemonic using an account different
|
||||||
|
from the default (0), use, for example:
|
||||||
|
|
||||||
|
m/44'/0'/11'
|
||||||
|
|
||||||
|
to import account 11.
|
||||||
|
|
||||||
|
In case you have a multisignature wallet originally created from a hardware device, and you had loose access to the device, you will need to enter the 24 mnemonic backup (from the device) and a path like:
|
||||||
|
|
||||||
|
|
||||||
|
m/48'/0'/8'
|
||||||
|
|
||||||
|
for a multisignature wallet, account 8.
|
|
@ -116,12 +116,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="create.seedSourceId == 'trezor' || create.seedSourceId == 'ledger'">
|
<div ng-show="create.seedSourceId == 'trezor' || create.seedSourceId == 'ledger'">
|
||||||
|
<label class="oh"><span translate>Account Number</span>
|
||||||
<label class="oh"><span translate>Account</span>
|
<input type="number" id="account" ng-model="account">
|
||||||
<select class="m10t" ng-model="account" ng-options="externalIndex as externalIndex for externalIndex in create.accountValues">
|
|
||||||
</select>
|
|
||||||
</label>
|
</label>
|
||||||
<div class="oh text-gray line-b size-12 p10b m20b"><span translate>Multiple wallets accounts are supported on the device simultaneously. Select which account should be used for this wallet</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="box-notification" ng-show="create.seedSourceId=='new' && createPassphrase">
|
<div class="box-notification" ng-show="create.seedSourceId=='new' && createPassphrase">
|
||||||
|
@ -161,21 +158,11 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="create.seedSourceId == 'set'">
|
<div ng-show="create.seedSourceId == 'set'">
|
||||||
<label class="oh"><span translate>Account</span>
|
<label class="oh"><span translate>Derivation Path</span> <small translate>BIP32 path for address derivation</small>
|
||||||
<select class="m10t" ng-model="accountForSeed" ng-options="externalIndex as externalIndex for externalIndex in create.accountValuesForSeed">
|
<input type="text" class="form-control" name="derivationPath" ng-model="derivationPath">
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<div class="oh text-gray line-b size-12 p10b m20b"><span translate>Multiple accounts can be derived from the same seed. Specify which account to use</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="oh" ng-show="create.seedSourceId == 'set' && privateKey.split(' ').length>20 && totalCopayers != 1">
|
|
||||||
<label for="fromHardware">
|
|
||||||
<span translate>Hardware Wallet?</span>
|
|
||||||
<switch id="fromHardware" name="fromHardware" ng-model="fromHardware" class="green right m5t m10b"></switch>
|
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="oh" ng-show="create.seedSourceId == 'new'">
|
||||||
<div class="oh" ng-show="(create.seedSourceId == 'set' || create.seedSourceId == 'new') && ! fromHardware">
|
|
||||||
<label for="network-name" >
|
<label for="network-name" >
|
||||||
<span translate>Testnet</span>
|
<span translate>Testnet</span>
|
||||||
<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>
|
||||||
|
|
|
@ -71,18 +71,6 @@
|
||||||
</div>
|
</div>
|
||||||
<div ng-hide="hideAdv" class="row">
|
<div ng-hide="hideAdv" class="row">
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
<label for="network-name" class=" oh">
|
|
||||||
<span translate>Testnet</span>
|
|
||||||
<switch id="network-name" name="isTestnet" ng-model="isTestnet" class="green right m5t m10b"></switch>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="oh"><span translate>BIP44 Account</span>
|
|
||||||
<select class="m10t" ng-model="accountForSeed" ng-options="externalIndex as externalIndex for externalIndex in import.accountValuesForSeed">
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<div class="oh text-gray line-b size-12 p10b m20b"><span translate>Multiple accounts can be derived from the same seed. Specify which account to import</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label for="passphrase" class="oh"><span translate>Passphrase</span> <small translate>Wallet Seed could require a passphrase to be imported</small>
|
<label for="passphrase" class="oh"><span translate>Passphrase</span> <small translate>Wallet Seed could require a passphrase to be imported</small>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
|
@ -91,6 +79,12 @@
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="oh"><span translate>Derivation Path</span> <small translate>BIP32 path for address derivation</small>
|
||||||
|
<input type="text" class="form-control" name="derivationPath" ng-model="derivationPath">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label for="bws" class="oh">
|
<label for="bws" class="oh">
|
||||||
<span>Wallet Service URL</span>
|
<span>Wallet Service URL</span>
|
||||||
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
|
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
|
||||||
|
@ -195,6 +189,13 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div ng-show="import.seedSourceId == 'trezor' || import.seedSourceId == 'ledger'">
|
||||||
|
|
||||||
|
<label class="oh"><span translate>Account Number</span>
|
||||||
|
<input type="number" id="account" ng-model="account">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div ng-show="import.seedSourceId == 'trezor'">
|
<div ng-show="import.seedSourceId == 'trezor'">
|
||||||
<label for="isMultisig" class="oh">
|
<label for="isMultisig" class="oh">
|
||||||
<span translate>Shared Wallet</span>
|
<span translate>Shared Wallet</span>
|
||||||
|
@ -202,15 +203,6 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="import.seedSourceId == 'trezor' || import.seedSourceId == 'ledger'">
|
|
||||||
|
|
||||||
<label class="oh"><span translate>Account</span>
|
|
||||||
<select class="m10t" ng-model="account" ng-options="externalIndex as externalIndex for externalIndex in import.accountValues">
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<div class="oh text-gray line-b size-12 p10b m20b"><span translate>Multiple wallets accounts are supported on the device simultaneously. Select which account should be imported</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="m10t oh" ng-init="hideAdv=true">
|
<div class="m10t oh" ng-init="hideAdv=true">
|
||||||
<a class="button outline light-gray expand tiny" ng-click="hideAdv=!hideAdv">
|
<a class="button outline light-gray expand tiny" ng-click="hideAdv=!hideAdv">
|
||||||
<i class="fi-widget m3r"></i>
|
<i class="fi-widget m3r"></i>
|
||||||
|
|
|
@ -141,16 +141,11 @@
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="join.seedSourceId == 'set'">
|
<div ng-show="join.seedSourceId == 'set'">
|
||||||
<label class="oh"><span translate>Account</span>
|
<label class="oh"><span translate>Derivation Path</span> <small translate>BIP32 path for address derivation</small>
|
||||||
<select class="m10t" ng-model="accountForSeed" ng-options="externalIndex as externalIndex for externalIndex in join.accountValuesForSeed">
|
<input type="text" class="form-control" name="derivationPath" ng-model="derivationPath">
|
||||||
</select>
|
|
||||||
</label>
|
</label>
|
||||||
<div class="oh text-gray line-b size-12 p10b m20b"><span translate>Multiple accounts can be derived from the same seed. Specify which account to use</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- columns -->
|
</div> <!-- columns -->
|
||||||
</div> <!-- advanced -->
|
</div> <!-- advanced -->
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('createController',
|
angular.module('copayApp.controllers').controller('createController',
|
||||||
function($scope, $rootScope, $location, $timeout, $log, lodash, go, profileService, configService, isCordova, gettext, ledger, trezor, isMobile, isChromeApp, isDevel) {
|
function($scope, $rootScope, $location, $timeout, $log, lodash, go, profileService, configService, isCordova, gettext, ledger, trezor, isMobile, isChromeApp, isDevel, derivationPathHelper) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
this.isWindowsPhoneApp = isMobile.Windows() && isCordova;
|
this.isWindowsPhoneApp = isMobile.Windows() && isCordova;
|
||||||
|
$scope.account = 1;
|
||||||
|
|
||||||
/* For compressed keys, m*73 + n*34 <= 496 */
|
/* For compressed keys, m*73 + n*34 <= 496 */
|
||||||
var COPAYER_PAIR_LIMITS = {
|
var COPAYER_PAIR_LIMITS = {
|
||||||
|
@ -25,8 +26,7 @@ angular.module('copayApp.controllers').controller('createController',
|
||||||
|
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
$scope.bwsurl = defaults.bws.url;
|
$scope.bwsurl = defaults.bws.url;
|
||||||
self.accountValuesForSeed = lodash.range(0, 100);
|
$scope.derivationPath = derivationPathHelper.default;
|
||||||
$scope.accountForSeed = 0;
|
|
||||||
|
|
||||||
// ng-repeat defined number of times instead of repeating over array?
|
// ng-repeat defined number of times instead of repeating over array?
|
||||||
this.getNumber = function(num) {
|
this.getNumber = function(num) {
|
||||||
|
@ -77,7 +77,6 @@ angular.module('copayApp.controllers').controller('createController',
|
||||||
|
|
||||||
this.setSeedSource = function(src) {
|
this.setSeedSource = function(src) {
|
||||||
self.seedSourceId = $scope.seedSource.id;
|
self.seedSourceId = $scope.seedSource.id;
|
||||||
self.accountValues = lodash.range(1, 100);
|
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
|
@ -89,6 +88,7 @@ angular.module('copayApp.controllers').controller('createController',
|
||||||
this.error = gettext('Please enter the required fields');
|
this.error = gettext('Please enter the required fields');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var opts = {
|
var opts = {
|
||||||
m: $scope.requiredCopayers,
|
m: $scope.requiredCopayers,
|
||||||
n: $scope.totalCopayers,
|
n: $scope.totalCopayers,
|
||||||
|
@ -96,18 +96,29 @@ angular.module('copayApp.controllers').controller('createController',
|
||||||
myName: $scope.totalCopayers > 1 ? form.myName.$modelValue : null,
|
myName: $scope.totalCopayers > 1 ? form.myName.$modelValue : null,
|
||||||
networkName: form.isTestnet.$modelValue ? 'testnet' : 'livenet',
|
networkName: form.isTestnet.$modelValue ? 'testnet' : 'livenet',
|
||||||
bwsurl: $scope.bwsurl,
|
bwsurl: $scope.bwsurl,
|
||||||
account: $scope.accountForSeed || 0,
|
|
||||||
use48: $scope.fromHardware,
|
use48: $scope.fromHardware,
|
||||||
};
|
};
|
||||||
var setSeed = self.seedSourceId =='set';
|
var setSeed = self.seedSourceId == 'set';
|
||||||
if (setSeed) {
|
if (setSeed) {
|
||||||
var words = form.privateKey.$modelValue;
|
|
||||||
|
var words = form.privateKey.$modelValue || '';
|
||||||
if (words.indexOf(' ') == -1 && words.indexOf('prv') == 1 && words.length > 108) {
|
if (words.indexOf(' ') == -1 && words.indexOf('prv') == 1 && words.length > 108) {
|
||||||
opts.extendedPrivateKey = words;
|
opts.extendedPrivateKey = words;
|
||||||
} else {
|
} else {
|
||||||
opts.mnemonic = words;
|
opts.mnemonic = words;
|
||||||
}
|
}
|
||||||
opts.passphrase = form.passphrase.$modelValue;
|
opts.passphrase = form.passphrase.$modelValue;
|
||||||
|
|
||||||
|
var pathData = derivationPathHelper.parse($scope.derivationPath);
|
||||||
|
if (!pathData) {
|
||||||
|
this.error = gettext('Invalid derivation path');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
opts.account = pathData.account;
|
||||||
|
opts.networkName = pathData.networkName;
|
||||||
|
opts.derivationStrategy = pathData.derivationStrategy;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
opts.passphrase = form.createPassphrase.$modelValue;
|
opts.passphrase = form.createPassphrase.$modelValue;
|
||||||
}
|
}
|
||||||
|
@ -119,11 +130,15 @@ angular.module('copayApp.controllers').controller('createController',
|
||||||
|
|
||||||
if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') {
|
if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') {
|
||||||
var account = $scope.account;
|
var account = $scope.account;
|
||||||
if (!account) {
|
if (!account || account < 1) {
|
||||||
this.error = gettext('Please select account');
|
this.error = gettext('Invalid account number');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
opts.account = account;
|
|
||||||
|
if ( self.seedSourceId == 'trezor')
|
||||||
|
account = account - 1;
|
||||||
|
|
||||||
|
opts.account = account;
|
||||||
self.hwWallet = self.seedSourceId == 'ledger' ? 'Ledger' : 'Trezor';
|
self.hwWallet = self.seedSourceId == 'ledger' ? 'Ledger' : 'Trezor';
|
||||||
var src = self.seedSourceId == 'ledger' ? ledger : trezor;
|
var src = self.seedSourceId == 'ledger' ? ledger : trezor;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('importController',
|
angular.module('copayApp.controllers').controller('importController',
|
||||||
function($scope, $rootScope, $location, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, isChromeApp, isDevel) {
|
function($scope, $rootScope, $location, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, isChromeApp, isDevel, derivationPathHelper) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
$scope.bwsurl = defaults.bws.url;
|
$scope.bwsurl = defaults.bws.url;
|
||||||
$scope.accountForSeed = 0;
|
$scope.derivationPath = derivationPathHelper.default;
|
||||||
self.accountValuesForSeed = lodash.range(0, 100);
|
$scope.account = 1;
|
||||||
|
|
||||||
window.ignoreMobilePause = true;
|
window.ignoreMobilePause = true;
|
||||||
$scope.$on('$destroy', function() {
|
$scope.$on('$destroy', function() {
|
||||||
|
@ -196,8 +196,16 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.passphrase = form.passphrase.$modelValue || null;
|
opts.passphrase = form.passphrase.$modelValue || null;
|
||||||
opts.networkName = form.isTestnet.$modelValue ? 'testnet' : 'livenet';
|
|
||||||
opts.account = $scope.accountForSeed;
|
var pathData = derivationPathHelper.parse($scope.derivationPath);
|
||||||
|
if (!pathData) {
|
||||||
|
this.error = gettext('Invalid derivation path');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
opts.account = pathData.account;
|
||||||
|
opts.networkName = pathData.networkName;
|
||||||
|
opts.derivationStrategy = pathData.derivationStrategy;
|
||||||
|
|
||||||
|
|
||||||
_importMnemonic(words, opts);
|
_importMnemonic(words, opts);
|
||||||
};
|
};
|
||||||
|
@ -233,15 +241,24 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
};
|
};
|
||||||
|
|
||||||
this.importHW = function(form) {
|
this.importHW = function(form) {
|
||||||
if (form.$invalid) {
|
if (form.$invalid || $scope.account < 0 ) {
|
||||||
this.error = gettext('There is an error in the form');
|
this.error = gettext('There is an error in the form');
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.error = '';
|
||||||
|
|
||||||
var account = $scope.account;
|
var account = + $scope.account;
|
||||||
|
|
||||||
|
if (self.seedSourceId == 'trezor') {
|
||||||
|
if ( account < 1) {
|
||||||
|
this.error = gettext('Invalid account number');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
account = account - 1;
|
||||||
|
}
|
||||||
var isMultisig = form.isMultisig.$modelValue;
|
var isMultisig = form.isMultisig.$modelValue;
|
||||||
|
|
||||||
switch (self.seedSourceId) {
|
switch (self.seedSourceId) {
|
||||||
|
@ -261,7 +278,6 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
this.setSeedSource = function() {
|
this.setSeedSource = function() {
|
||||||
if (!$scope.seedSource) return;
|
if (!$scope.seedSource) return;
|
||||||
self.seedSourceId = $scope.seedSource.id;
|
self.seedSourceId = $scope.seedSource.id;
|
||||||
self.accountValues = lodash.range(1, 100);
|
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('joinController',
|
angular.module('copayApp.controllers').controller('joinController',
|
||||||
function($scope, $rootScope, $timeout, go, notification, profileService, configService, isCordova, storageService, applicationService, $modal, gettext, lodash, ledger, trezor, isChromeApp, isDevel) {
|
function($scope, $rootScope, $timeout, go, notification, profileService, configService, isCordova, storageService, applicationService, $modal, gettext, lodash, ledger, trezor, isChromeApp, isDevel,derivationPathHelper) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
$scope.bwsurl = defaults.bws.url;
|
$scope.bwsurl = defaults.bws.url;
|
||||||
self.accountValuesForSeed = lodash.range(0, 100);
|
$scope.derivationPath = derivationPathHelper.default;
|
||||||
$scope.accountForSeed = 0;
|
|
||||||
|
|
||||||
this.onQrCodeScanned = function(data) {
|
this.onQrCodeScanned = function(data) {
|
||||||
$scope.secret = data;
|
$scope.secret = data;
|
||||||
|
@ -62,7 +61,6 @@ angular.module('copayApp.controllers').controller('joinController',
|
||||||
secret: form.secret.$modelValue,
|
secret: form.secret.$modelValue,
|
||||||
myName: form.myName.$modelValue,
|
myName: form.myName.$modelValue,
|
||||||
bwsurl: $scope.bwsurl,
|
bwsurl: $scope.bwsurl,
|
||||||
account: $scope.accountForSeed || 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var setSeed = self.seedSourceId =='set';
|
var setSeed = self.seedSourceId =='set';
|
||||||
|
@ -74,6 +72,15 @@ angular.module('copayApp.controllers').controller('joinController',
|
||||||
opts.mnemonic = words;
|
opts.mnemonic = words;
|
||||||
}
|
}
|
||||||
opts.passphrase = form.passphrase.$modelValue;
|
opts.passphrase = form.passphrase.$modelValue;
|
||||||
|
|
||||||
|
var pathData = derivationPathHelper.parse($scope.derivationPath);
|
||||||
|
if (!pathData) {
|
||||||
|
this.error = gettext('Invalid derivation path');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
opts.account = pathData.account;
|
||||||
|
opts.networkName = pathData.networkName;
|
||||||
|
opts.derivationStrategy = pathData.derivationStrategy;
|
||||||
} else {
|
} else {
|
||||||
opts.passphrase = form.createPassphrase.$modelValue;
|
opts.passphrase = form.createPassphrase.$modelValue;
|
||||||
}
|
}
|
||||||
|
@ -85,10 +92,14 @@ angular.module('copayApp.controllers').controller('joinController',
|
||||||
|
|
||||||
if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') {
|
if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') {
|
||||||
var account = $scope.account;
|
var account = $scope.account;
|
||||||
if (!account) {
|
if (!account || account < 1) {
|
||||||
this.error = gettext('Please select account');
|
this.error = gettext('Invalid account number');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( self.seedSourceId == 'trezor')
|
||||||
|
account = account - 1;
|
||||||
|
|
||||||
opts.account = account;
|
opts.account = account;
|
||||||
self.hwWallet = self.seedSourceId == 'ledger' ? 'Ledger' : 'Trezor';
|
self.hwWallet = self.seedSourceId == 'ledger' ? 'Ledger' : 'Trezor';
|
||||||
var src = self.seedSourceId == 'ledger' ? ledger : trezor;
|
var src = self.seedSourceId == 'ledger' ? ledger : trezor;
|
||||||
|
|
|
@ -21,13 +21,14 @@ angular
|
||||||
|
|
||||||
$logProvider.debugEnabled(true);
|
$logProvider.debugEnabled(true);
|
||||||
$provide.decorator('$log', ['$delegate',
|
$provide.decorator('$log', ['$delegate',
|
||||||
function($delegate) {
|
function($delegate, isDevel) {
|
||||||
var historicLog = historicLogProvider.$get();
|
var historicLog = historicLogProvider.$get();
|
||||||
|
|
||||||
['debug', 'info', 'warn', 'error', 'log'].forEach(function(level) {
|
['debug', 'info', 'warn', 'error', 'log'].forEach(function(level) {
|
||||||
|
if (isDevel && level == 'error') return;
|
||||||
|
|
||||||
var orig = $delegate[level];
|
var orig = $delegate[level];
|
||||||
$delegate[level] = function() {
|
$delegate[level] = function() {
|
||||||
|
|
||||||
if (level == 'error')
|
if (level == 'error')
|
||||||
console.log(arguments);
|
console.log(arguments);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('copayApp.services').factory('derivationPathHelper', function(lodash) {
|
||||||
|
var root = {};
|
||||||
|
|
||||||
|
root.default = "m/44'/0'/0'"
|
||||||
|
root.parse = function(str) {
|
||||||
|
var arr = str.split('/');
|
||||||
|
|
||||||
|
var ret = {};
|
||||||
|
|
||||||
|
if (arr[0] != 'm')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (arr[1]) {
|
||||||
|
case "44'":
|
||||||
|
ret.derivationStrategy = 'BIP44';
|
||||||
|
break;
|
||||||
|
case "48'":
|
||||||
|
ret.derivationStrategy = 'BIP48';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (arr[2]) {
|
||||||
|
case "0'":
|
||||||
|
ret.networkName = 'livenet';
|
||||||
|
break;
|
||||||
|
case "1'":
|
||||||
|
ret.networkName = 'testnet';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
var match = arr[3].match(/(\d+)'/);
|
||||||
|
if (!match)
|
||||||
|
return false;
|
||||||
|
ret.account = + match[1]
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
return root;
|
||||||
|
});
|
|
@ -13,7 +13,7 @@ angular.module('copayApp.services')
|
||||||
root._err = function(data) {
|
root._err = function(data) {
|
||||||
var msg = 'Hardware Wallet Error: ' + (data.error || data.message || 'unknown');
|
var msg = 'Hardware Wallet Error: ' + (data.error || data.message || 'unknown');
|
||||||
$log.warn(msg);
|
$log.warn(msg);
|
||||||
return JSON.parse(JSON.stringify(msg));
|
return msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getAddressPath = function(isMultisig, account) {
|
root.getAddressPath = function(isMultisig, account) {
|
||||||
|
|
|
@ -24,7 +24,6 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
|
|
||||||
root.getInfoForNewWallet = function(isMultisig, account, callback) {
|
root.getInfoForNewWallet = function(isMultisig, account, callback) {
|
||||||
account = account - 1;
|
|
||||||
var opts = {};
|
var opts = {};
|
||||||
root.getEntropySource(isMultisig, account, function(err, data) {
|
root.getEntropySource(isMultisig, account, function(err, data) {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
Loading…
Reference in New Issue