|
@ -38,6 +38,13 @@ Copayer.create = function(opts) { |
|
|
signature: opts.signature, |
|
|
signature: opts.signature, |
|
|
}]; |
|
|
}]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
x.requestPubKey = opts.requestPubKey; |
|
|
|
|
|
x.signature = opts.signature; |
|
|
|
|
|
|
|
|
|
|
|
x.requestPubKeys = opts.requestPubKeys; |
|
|
|
|
|
Copayer.expandForCompat(x); |
|
|
|
|
|
|
|
|
x.addressManager = AddressManager.create({ |
|
|
x.addressManager = AddressManager.create({ |
|
|
copayerIndex: opts.copayerIndex |
|
|
copayerIndex: opts.copayerIndex |
|
|
}); |
|
|
}); |
|
@ -45,6 +52,21 @@ Copayer.create = function(opts) { |
|
|
return x; |
|
|
return x; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Copayer.expandForCompat = function(x) { |
|
|
|
|
|
if (!x.requestPubKeys) { |
|
|
|
|
|
x.requestPubKeys = [{ |
|
|
|
|
|
key: x.requestPubKey, |
|
|
|
|
|
signature: x.signature, |
|
|
|
|
|
}]; |
|
|
|
|
|
} |
|
|
|
|
|
// For backcompat
|
|
|
|
|
|
if (!x.requestPubKey) { |
|
|
|
|
|
var l = _.last(x.requestPubKeys); |
|
|
|
|
|
x.requestPubKey = l.key; |
|
|
|
|
|
x.signature = l.signature; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
Copayer.fromObj = function(obj) { |
|
|
Copayer.fromObj = function(obj) { |
|
|
var x = new Copayer(); |
|
|
var x = new Copayer(); |
|
|
|
|
|
|
|
@ -52,14 +74,13 @@ Copayer.fromObj = function(obj) { |
|
|
x.id = obj.id; |
|
|
x.id = obj.id; |
|
|
x.name = obj.name; |
|
|
x.name = obj.name; |
|
|
x.xPubKey = obj.xPubKey; |
|
|
x.xPubKey = obj.xPubKey; |
|
|
if (!obj.requestPubKeys) { |
|
|
|
|
|
x.requestPubKeys = [{ |
|
|
x.requestPubKey = obj.requestPubKey; |
|
|
key: obj.requestPubKey, |
|
|
x.signature = obj.signature; |
|
|
signature: obj.signature, |
|
|
|
|
|
}]; |
|
|
x.requestPubKeys = obj.requestPubKeys; |
|
|
} else { |
|
|
Copayer.expandForCompat(x); |
|
|
x.requestPubKeys = obj.requestPubKeys; |
|
|
|
|
|
} |
|
|
|
|
|
x.addressManager = AddressManager.fromObj(obj.addressManager); |
|
|
x.addressManager = AddressManager.fromObj(obj.addressManager); |
|
|
return x; |
|
|
return x; |
|
|
}; |
|
|
}; |
|
|