mirror of https://github.com/BTCPrivate/copay.git
add test and adv opts to create
This commit is contained in:
parent
dd724a6135
commit
291ed73916
|
@ -116,7 +116,7 @@ angular.module('copayApp.controllers').controller('JoinController',
|
||||||
walletFactory.network.on('badSecret', function() {});
|
walletFactory.network.on('badSecret', function() {});
|
||||||
|
|
||||||
Passphrase.getBase64Async($scope.joinPassword, function(passphrase) {
|
Passphrase.getBase64Async($scope.joinPassword, function(passphrase) {
|
||||||
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, passphrase, $scope.enterPrivate ? $scope.private : null, function(err, w) {
|
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, passphrase, $scope.private, function(err, w) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
if (err || !w) {
|
if (err || !w) {
|
||||||
if (err === 'joinError')
|
if (err === 'joinError')
|
||||||
|
|
|
@ -41,6 +41,7 @@ angular.module('copayApp.controllers').controller('SetupController',
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.walletPassword = $rootScope.walletPassword;
|
$scope.walletPassword = $rootScope.walletPassword;
|
||||||
$scope.isMobile = !!window.cordova;
|
$scope.isMobile = !!window.cordova;
|
||||||
|
$scope.hideAdv = true;
|
||||||
|
|
||||||
// ng-repeat defined number of times instead of repeating over array?
|
// ng-repeat defined number of times instead of repeating over array?
|
||||||
$scope.getNumber = function(num) {
|
$scope.getNumber = function(num) {
|
||||||
|
@ -82,6 +83,7 @@ angular.module('copayApp.controllers').controller('SetupController',
|
||||||
name: $scope.walletName,
|
name: $scope.walletName,
|
||||||
nickname: $scope.myNickname,
|
nickname: $scope.myNickname,
|
||||||
passphrase: passphrase,
|
passphrase: passphrase,
|
||||||
|
privateKeyHex: $scope.private,
|
||||||
};
|
};
|
||||||
var w = walletFactory.create(opts);
|
var w = walletFactory.create(opts);
|
||||||
controllerUtils.startNetwork(w, $scope);
|
controllerUtils.startNetwork(w, $scope);
|
||||||
|
|
|
@ -113,9 +113,15 @@ WalletFactory.prototype.create = function(opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
this.log('### CREATING NEW WALLET.' + (opts.id ? ' USING ID: ' + opts.id : ' NEW ID') + (opts.privateKey ? ' USING PrivateKey: ' + opts.privateKey.getId() : ' NEW PrivateKey'));
|
this.log('### CREATING NEW WALLET.' + (opts.id ? ' USING ID: ' + opts.id : ' NEW ID') + (opts.privateKey ? ' USING PrivateKey: ' + opts.privateKey.getId() : ' NEW PrivateKey'));
|
||||||
|
|
||||||
opts.privateKey = opts.privateKey || new PrivateKey({
|
var privOpts = {
|
||||||
networkName: this.networkName
|
networkName: this.networkName,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (opts.privateKeyHex && opts.privateKeyHex.length>1) {
|
||||||
|
privOpts.extendedPrivateKeyString = opts.privateKeyHex;
|
||||||
|
}
|
||||||
|
|
||||||
|
opts.privateKey = opts.privateKey || new PrivateKey(privOpts);
|
||||||
|
|
||||||
var requiredCopayers = opts.requiredCopayers || this.walletDefaults.requiredCopayers;
|
var requiredCopayers = opts.requiredCopayers || this.walletDefaults.requiredCopayers;
|
||||||
var totalCopayers = opts.totalCopayers || this.walletDefaults.totalCopayers;
|
var totalCopayers = opts.totalCopayers || this.walletDefaults.totalCopayers;
|
||||||
|
@ -216,7 +222,6 @@ WalletFactory.prototype.decodeSecret = function(secret) {
|
||||||
|
|
||||||
|
|
||||||
WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphrase, privateHex, cb) {
|
WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphrase, privateHex, cb) {
|
||||||
console.log('[WalletFactory.js.218:privateHex:]',privateHex); //TODO
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var s = self.decodeSecret(secret);
|
var s = self.decodeSecret(secret);
|
||||||
if (!s) return cb('badSecret');
|
if (!s) return cb('badSecret');
|
||||||
|
@ -229,7 +234,6 @@ console.log('[WalletFactory.js.218:privateHex:]',privateHex); //TODO
|
||||||
privOpts.extendedPrivateKeyString = privateHex;
|
privOpts.extendedPrivateKeyString = privateHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[WalletFactory.js.229:privOpts:]',privOpts); //TODO
|
|
||||||
//Create our PrivateK
|
//Create our PrivateK
|
||||||
var privateKey = new PrivateKey(privOpts);
|
var privateKey = new PrivateKey(privOpts);
|
||||||
this.log('\t### PrivateKey Initialized');
|
this.log('\t### PrivateKey Initialized');
|
||||||
|
|
|
@ -138,6 +138,27 @@ describe('WalletFactory model', function() {
|
||||||
var w = wf.create();
|
var w = wf.create();
|
||||||
should.exist(w);
|
should.exist(w);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should be able to create wallets with given pk', function() {
|
||||||
|
var wf = new WalletFactory(config, '0.0.1');
|
||||||
|
var priv = 'tprv8ZgxMBicQKsPdEqHcA7RjJTayxA3gSSqeRTttS1JjVbgmNDZdSk9EHZK5pc52GY5xFmwcakmUeKWUDzGoMLGAhrfr5b3MovMUZUTPqisL2m';
|
||||||
|
var w = wf.create({
|
||||||
|
privateKeyHex:priv,
|
||||||
|
});
|
||||||
|
w.privateKey.toObj().extendedPrivateKeyString.should.equal(priv);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to create wallets with random pk', function() {
|
||||||
|
var wf = new WalletFactory(config, '0.0.1');
|
||||||
|
var priv = 'tprv8ZgxMBicQKsPdEqHcA7RjJTayxA3gSSqeRTttS1JjVbgmNDZdSk9EHZK5pc52GY5xFmwcakmUeKWUDzGoMLGAhrfr5b3MovMUZUTPqisL2m';
|
||||||
|
var w1 = wf.create();
|
||||||
|
var w2 = wf.create();
|
||||||
|
w1.privateKey.toObj().extendedPrivateKeyString.should.not.equal(
|
||||||
|
w2.privateKey.toObj().extendedPrivateKeyString
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should be able to get wallets', function() {
|
it('should be able to get wallets', function() {
|
||||||
var wf = new WalletFactory(config, '0.0.1');
|
var wf = new WalletFactory(config, '0.0.1');
|
||||||
var w = wf.create();
|
var w = wf.create();
|
||||||
|
|
|
@ -44,6 +44,21 @@
|
||||||
match="walletPassword"
|
match="walletPassword"
|
||||||
required>
|
required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<a class="expand small" ng-click="hideAdv=!hideAdv">
|
||||||
|
<span ng-hide="!hideAdv">Show</span>
|
||||||
|
<span ng-hide="hideAdv">Hide</span>
|
||||||
|
advanced options
|
||||||
|
</a>
|
||||||
|
<div ng-hide="hideAdv">
|
||||||
|
<p>
|
||||||
|
<input type="text"
|
||||||
|
placeholder="Private Key (Hex)"
|
||||||
|
name="private"
|
||||||
|
ng-model="private"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row" ng-show="!isSetupWalletPage">
|
<div class="row" ng-show="!isSetupWalletPage">
|
||||||
<div class="large-6 medium-6 columns">
|
<div class="large-6 medium-6 columns">
|
||||||
|
@ -68,7 +83,7 @@
|
||||||
width="50px">
|
width="50px">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="comment" ng-show="totalCopayers>1">(*) The limits are imposed by the bitcoin network.</p>
|
<p class="comment" ng-show="totalCopayers>1 && !isSetupWalletPage">(*) The limits are imposed by the bitcoin network.</p>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<a ng-show="!isSetupWalletPage" class="back-button m20r" href="#!/">« Back</a>
|
<a ng-show="!isSetupWalletPage" class="back-button m20r" href="#!/">« Back</a>
|
||||||
<a ng-show="isSetupWalletPage" class="back-button m20r"
|
<a ng-show="isSetupWalletPage" class="back-button m20r"
|
||||||
|
|
Loading…
Reference in New Issue