|
|
@ -18,8 +18,8 @@ Wallet.create = function(opts) { |
|
|
|
|
|
|
|
var x = new Wallet(); |
|
|
|
|
|
|
|
$.checkArgument(_.isNumber(opts.m), '"m" is expected to be a number'); |
|
|
|
$.checkArgument(_.isNumber(opts.n), '"n" is expected to be a number'); |
|
|
|
$.shouldBeNumber(opts.m); |
|
|
|
$.shouldBeNumber(opts.n); |
|
|
|
|
|
|
|
x.version = '1.0.0'; |
|
|
|
x.createdOn = Math.floor(Date.now() / 1000); |
|
|
@ -47,8 +47,8 @@ Wallet.create = function(opts) { |
|
|
|
Wallet.fromObj = function(obj) { |
|
|
|
var x = new Wallet(); |
|
|
|
|
|
|
|
$.checkArgument(_.isNumber(obj.m), '"m" is expected to be a number'); |
|
|
|
$.checkArgument(_.isNumber(obj.n), '"n" is expected to be a number'); |
|
|
|
$.shouldBeNumber(obj.m); |
|
|
|
$.shouldBeNumber(obj.n); |
|
|
|
|
|
|
|
x.version = obj.version; |
|
|
|
x.createdOn = obj.createdOn; |
|
|
@ -77,22 +77,6 @@ Wallet.prototype.toObject = function() { |
|
|
|
return x; |
|
|
|
}; |
|
|
|
|
|
|
|
/* For compressed keys, m*73 + n*34 <= 496 */ |
|
|
|
Wallet.COPAYER_PAIR_LIMITS = { |
|
|
|
1: 1, |
|
|
|
2: 2, |
|
|
|
3: 3, |
|
|
|
4: 4, |
|
|
|
5: 4, |
|
|
|
6: 4, |
|
|
|
7: 3, |
|
|
|
8: 3, |
|
|
|
9: 2, |
|
|
|
10: 2, |
|
|
|
11: 1, |
|
|
|
12: 1, |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the maximum allowed number of required copayers. |
|
|
|
* This is a limit imposed by the maximum allowed size of the scriptSig. |
|
|
@ -104,7 +88,7 @@ Wallet.getMaxRequiredCopayers = function(totalCopayers) { |
|
|
|
}; |
|
|
|
|
|
|
|
Wallet.verifyCopayerLimits = function(m, n) { |
|
|
|
return (n >= 1 && n <= 12) && (m >= 1 && m <= Wallet.COPAYER_PAIR_LIMITS[n]); |
|
|
|
return (n >= 1 && n <= 15) && (m >= 1 && m <= n); |
|
|
|
}; |
|
|
|
|
|
|
|
Wallet.prototype.isShared = function() { |
|
|
|