Merge pull request #463 from maraoz/feature/m-n-script-2

allow only valid cases for livenet
This commit is contained in:
Mario Colque 2014-05-29 10:37:28 -03:00
commit bcda28c529
4 changed files with 172 additions and 97 deletions

View file

@ -1,5 +1,37 @@
'use strict';
var valid_pairs = {
'1,1': 112,
'1,2': 147,
'2,2': 220,
'1,3': 182,
'2,3': 256,
'3,3': 329,
'1,4': 216,
'2,4': 290,
'3,4': 363,
'4,4': 436,
'1,5': 250,
'2,5': 324,
'3,5': 398,
'4,5': 470,
'1,6': 284,
'2,6': 358,
'3,6': 432,
'1,7': 318,
'2,7': 392,
'3,7': 465,
'1,8': 353,
'2,8': 427,
'1,9': 387,
'2,9': 461,
'1,10': 421,
'2,10': 495,
'1,11': 455,
'1,12': 489
};
angular.module('copay.setup').controller('SetupController',
function($scope, $rootScope, $location, $timeout, walletFactory, controllerUtils, Passphrase) {
@ -9,7 +41,7 @@ angular.module('copay.setup').controller('SetupController',
// ng-repeat defined number of times instead of repeating over array?
$scope.getNumber = function(num) {
return new Array(num);
return new Array(num);
}
$scope.totalCopayers = config.wallet.totalCopayers;
@ -18,10 +50,11 @@ angular.module('copay.setup').controller('SetupController',
$scope.TCValues.push(n);
var updateRCSelect = function(n) {
$scope.requiredCopayers = parseInt(Math.min(n / 2 + 1, config.limits.mPlusN-n));
$scope.requiredCopayers = (valid_pairs[[parseInt(n / 2 + 1), n]] > 0 || config.networkName === 'testnet') ?
parseInt(n / 2 + 1) : 1;
$scope.RCValues = [];
for (var m = 1; m <= n; m++) {
if (n + m <= config.limits.mPlusN) {
if (valid_pairs[[m, n]] > 0 || config.networkName === 'testnet') {
$scope.RCValues.push(m);
}
}
@ -35,15 +68,18 @@ angular.module('copay.setup').controller('SetupController',
$scope.create = function(form) {
if (form && form.$invalid) {
$rootScope.$flashMessage = { message: 'Please, enter required fields', type: 'error'};
$rootScope.$flashMessage = {
message: 'Please, enter required fields',
type: 'error'
};
return;
}
$scope.loading = true;
Passphrase.getBase64Async($scope.walletPassword, function(passphrase){
Passphrase.getBase64Async($scope.walletPassword, function(passphrase) {
var opts = {
requiredCopayers: $scope.requiredCopayers,
totalCopayers: $scope.totalCopayers,
name: $scope.walletName,
name: $scope.walletName,
nickname: $scope.myNickname,
passphrase: passphrase,
};

View file

@ -426,7 +426,10 @@ Wallet.prototype.sign = function(ntxid, cb) {
setTimeout(function() {
var myId = self.getMyCopayerId();
var txp = self.txProposals.txps[ntxid];
if (!txp || txp.rejectedBy[myId] || txp.signedBy[myId]) return;
if (!txp || txp.rejectedBy[myId] || txp.signedBy[myId]) {
if (cb) cb(false);
return;
}
var pkr = self.publicKeyRing;
var keys = self.privateKey.getAll(pkr.addressIndex, pkr.changeAddressIndex);
@ -455,6 +458,9 @@ Wallet.prototype.sendTx = function(ntxid, cb) {
if (!tx.isComplete()) return;
this.log('[Wallet.js.231] BROADCASTING TX!!!'); //TODO
var scriptSig = tx.ins[0].getScript();
var size = scriptSig.serialize().length;
var txHex = tx.serialize().toString('hex');
this.log('[Wallet.js.261:txHex:]', txHex); //TODO