mirror of https://github.com/BTCPrivate/copay.git
support import
This commit is contained in:
parent
de8551812b
commit
1892d16b92
|
@ -160,7 +160,22 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="create.seedSourceId == 'set' || create.seedSourceId == 'new'">
|
<div ng-show="create.seedSourceId == 'set'">
|
||||||
|
<label class="oh"><span translate>Account</span>
|
||||||
|
<select class="m10t" ng-model="accountForSeed" ng-options="externalIndex as externalIndex for externalIndex in create.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 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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
|
@ -76,6 +76,14 @@
|
||||||
<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>
|
||||||
|
|
||||||
|
<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">
|
||||||
<input type="password" class="form-control" placeholder="{{'Seed passphrase'|translate}}"
|
<input type="password" class="form-control" placeholder="{{'Seed passphrase'|translate}}"
|
||||||
|
|
|
@ -25,6 +25,8 @@ 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.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) {
|
||||||
|
@ -48,8 +50,7 @@ angular.module('copayApp.controllers').controller('createController',
|
||||||
label: gettext('Specify Seed...'),
|
label: gettext('Specify Seed...'),
|
||||||
}];
|
}];
|
||||||
$scope.seedSource = self.seedOptions[0];
|
$scope.seedSource = self.seedOptions[0];
|
||||||
// TODO
|
if (!isChromeApp) return;
|
||||||
// if (!isChromeApp) return;
|
|
||||||
|
|
||||||
if (n > 1)
|
if (n > 1)
|
||||||
self.seedOptions.push({
|
self.seedOptions.push({
|
||||||
|
@ -76,11 +77,7 @@ 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);
|
||||||
if (self.seedSourceId == 'ledger')
|
|
||||||
self.accountValues = lodash.range(0, 99);
|
|
||||||
else
|
|
||||||
self.accountValues = lodash.range(1, 100);
|
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
|
@ -98,7 +95,9 @@ angular.module('copayApp.controllers').controller('createController',
|
||||||
name: form.walletName.$modelValue,
|
name: form.walletName.$modelValue,
|
||||||
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,
|
||||||
};
|
};
|
||||||
var setSeed = self.seedSourceId =='set';
|
var setSeed = self.seedSourceId =='set';
|
||||||
if (setSeed) {
|
if (setSeed) {
|
||||||
|
@ -118,7 +117,6 @@ angular.module('copayApp.controllers').controller('createController',
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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) {
|
||||||
|
|
|
@ -7,6 +7,8 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
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;
|
||||||
|
self.accountValuesForSeed = lodash.range(0, 100);
|
||||||
|
|
||||||
window.ignoreMobilePause = true;
|
window.ignoreMobilePause = true;
|
||||||
$scope.$on('$destroy', function() {
|
$scope.$on('$destroy', function() {
|
||||||
|
@ -17,8 +19,7 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
|
|
||||||
var updateSeedSourceSelect = function() {
|
var updateSeedSourceSelect = function() {
|
||||||
self.seedOptions = [];
|
self.seedOptions = [];
|
||||||
// TODO
|
if (!isChromeApp) return;
|
||||||
// if (!isChromeApp) return;
|
|
||||||
|
|
||||||
self.seedOptions.push({
|
self.seedOptions.push({
|
||||||
id: 'ledger',
|
id: 'ledger',
|
||||||
|
@ -193,6 +194,7 @@ 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.networkName = form.isTestnet.$modelValue ? 'testnet' : 'livenet';
|
||||||
|
opts.account = $scope.accountForSeed;
|
||||||
|
|
||||||
_importMnemonic(words, opts);
|
_importMnemonic(words, opts);
|
||||||
};
|
};
|
||||||
|
@ -256,11 +258,7 @@ 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);
|
||||||
if (self.seedSourceId == 'ledger')
|
|
||||||
self.accountValues = lodash.range(0, 99);
|
|
||||||
else
|
|
||||||
self.accountValues = lodash.range(1, 100);
|
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
|
|
|
@ -23,9 +23,7 @@ angular.module('copayApp.controllers').controller('joinController',
|
||||||
label: gettext('Specify Seed...'),
|
label: gettext('Specify Seed...'),
|
||||||
}];
|
}];
|
||||||
$scope.seedSource = self.seedOptions[0];
|
$scope.seedSource = self.seedOptions[0];
|
||||||
|
if (!isChromeApp) return;
|
||||||
// TODO
|
|
||||||
// if (!isChromeApp) return;
|
|
||||||
|
|
||||||
self.seedOptions.push({
|
self.seedOptions.push({
|
||||||
id: 'ledger',
|
id: 'ledger',
|
||||||
|
@ -40,11 +38,7 @@ angular.module('copayApp.controllers').controller('joinController',
|
||||||
|
|
||||||
this.setSeedSource = function(src) {
|
this.setSeedSource = function(src) {
|
||||||
self.seedSourceId = $scope.seedSource.id;
|
self.seedSourceId = $scope.seedSource.id;
|
||||||
|
self.accountValues = lodash.range(1, 100);
|
||||||
if (self.seedSourceId == 'ledger')
|
|
||||||
self.accountValues = lodash.range(0, 99);
|
|
||||||
else
|
|
||||||
self.accountValues = lodash.range(1, 100);
|
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
|
|
|
@ -17,13 +17,26 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getAddressPath = function(isMultisig, account) {
|
root.getAddressPath = function(isMultisig, account) {
|
||||||
var rootPath = isMultisig ? root.MULTISIG_ROOTPATH : root.UNISIG_ROOTPATH;
|
var rootPath;
|
||||||
|
|
||||||
|
if (account) {
|
||||||
|
rootPath = isMultisig ? root.MULTISIG_ROOTPATH : root.UNISIG_ROOTPATH;
|
||||||
|
} else {
|
||||||
|
// Old ledger wallet compat
|
||||||
|
rootPath = 44;
|
||||||
|
}
|
||||||
return rootPath + "'/" + root.LIVENET_PATH + "'/" + account + "'";
|
return rootPath + "'/" + root.LIVENET_PATH + "'/" + account + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
root.getEntropyPath = function(isMultisig, account) {
|
root.getEntropyPath = function(isMultisig, account) {
|
||||||
var rootPath = isMultisig ? root.MULTISIG_ROOTPATH : root.UNISIG_ROOTPATH;
|
var path;
|
||||||
var path = root.ENTROPY_INDEX_PATH + rootPath + "'/" + account + "'";
|
if (account) {
|
||||||
|
var rootPath = isMultisig ? root.MULTISIG_ROOTPATH : root.UNISIG_ROOTPATH;
|
||||||
|
path = root.ENTROPY_INDEX_PATH + rootPath + "'/" + account + "'";
|
||||||
|
} else {
|
||||||
|
// Old ledger wallet compat
|
||||||
|
path = root.ENTROPY_INDEX_PATH + "0'";
|
||||||
|
}
|
||||||
return path;
|
return path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,13 @@ angular.module('copayApp.services')
|
||||||
var root = {};
|
var root = {};
|
||||||
var LEDGER_CHROME_ID = "kkdpmhnladdopljabkgpacgpliggeeaf";
|
var LEDGER_CHROME_ID = "kkdpmhnladdopljabkgpacgpliggeeaf";
|
||||||
|
|
||||||
// Ledger magic number to get xPub without user confirmation
|
|
||||||
root.ENTROPY_INDEX_PATH = "0xb11e/";
|
|
||||||
root.UNISIG_ROOTPATH = 44;
|
|
||||||
root.MULTISIG_ROOTPATH = 48;
|
|
||||||
|
|
||||||
root.callbacks = {};
|
root.callbacks = {};
|
||||||
|
|
||||||
root.hasSession = function() {
|
root.hasSession = function() {
|
||||||
root._message({
|
root._message({
|
||||||
command: "has_session"
|
command: "has_session"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
root.getEntropySource = function(isMultisig, account, callback) {
|
root.getEntropySource = function(isMultisig, account, callback) {
|
||||||
root.getXPubKey(hwWallet.getEntropyPath(isMultisig, account), function(data) {
|
root.getXPubKey(hwWallet.getEntropyPath(isMultisig, account), function(data) {
|
||||||
if (!data.success)
|
if (!data.success)
|
||||||
|
|
|
@ -183,6 +183,14 @@ angular.module('copayApp.services')
|
||||||
passphrase: opts.passphrase,
|
passphrase: opts.passphrase,
|
||||||
account: opts.account || 0,
|
account: opts.account || 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// </ Nasty
|
||||||
|
if (opts.fromHardware && opts.n>1) {
|
||||||
|
walletClient.credentials.derivationStrategy ==
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nasty>
|
||||||
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
$log.info(ex);
|
$log.info(ex);
|
||||||
return cb(gettext('Could not create: Invalid wallet seed'));
|
return cb(gettext('Could not create: Invalid wallet seed'));
|
||||||
|
@ -420,7 +428,7 @@ angular.module('copayApp.services')
|
||||||
walletClient.importFromMnemonic(words, {
|
walletClient.importFromMnemonic(words, {
|
||||||
network: opts.networkName,
|
network: opts.networkName,
|
||||||
passphrase: opts.passphrase,
|
passphrase: opts.passphrase,
|
||||||
account: opts.account,
|
account: opts.account || 0,
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err)
|
if (err)
|
||||||
return bwsError.cb(err, gettext('Could not import'), cb);
|
return bwsError.cb(err, gettext('Could not import'), cb);
|
||||||
|
|
Loading…
Reference in New Issue