|
|
@ -12,13 +12,7 @@ var WalletUtils = require('bitcore-wallet-utils'); |
|
|
|
var Bitcore = WalletUtils.Bitcore; |
|
|
|
var HDPublicKey = Bitcore.HDPublicKey; |
|
|
|
|
|
|
|
function Copayer() { |
|
|
|
this.version = '2'; |
|
|
|
}; |
|
|
|
|
|
|
|
Copayer.getVersion = function() { |
|
|
|
return parseInt(this.version); |
|
|
|
}; |
|
|
|
function Copayer() {}; |
|
|
|
|
|
|
|
Copayer.create = function(opts) { |
|
|
|
opts = opts || {}; |
|
|
@ -29,16 +23,14 @@ Copayer.create = function(opts) { |
|
|
|
opts.copayerIndex = opts.copayerIndex || 0; |
|
|
|
|
|
|
|
var x = new Copayer(); |
|
|
|
x.createdOn = Math.floor(Date.now() / 1000); |
|
|
|
|
|
|
|
x.version = 2; |
|
|
|
x.createdOn = Math.floor(Date.now() / 1000); |
|
|
|
x.xPubKey = opts.xPubKey; |
|
|
|
|
|
|
|
x.id = WalletUtils.xPubToCopayerId(x.xPubKey); |
|
|
|
x.name = opts.name; |
|
|
|
|
|
|
|
x.requestPubKey = opts.requestPubKey; |
|
|
|
x.signature = opts.signature; |
|
|
|
|
|
|
|
x.requestPubKeys = [{ |
|
|
|
key: opts.requestPubKey, |
|
|
|
signature: opts.signature, |
|
|
@ -56,15 +48,15 @@ Copayer.create = function(opts) { |
|
|
|
Copayer.fromObj = function(obj) { |
|
|
|
var x = new Copayer(); |
|
|
|
|
|
|
|
x.version = obj.version; |
|
|
|
x.createdOn = obj.createdOn; |
|
|
|
x.id = obj.id; |
|
|
|
x.name = obj.name; |
|
|
|
x.xPubKey = obj.xPubKey; |
|
|
|
|
|
|
|
x.requestPubKey = obj.requestPubKey; |
|
|
|
x.signature = obj.signature; |
|
|
|
|
|
|
|
if (this.getVersion() == 1) { |
|
|
|
if (parseInt(x.version) == 1) { |
|
|
|
x.requestPubKeys = [{ |
|
|
|
key: x.requestPubKey, |
|
|
|
signature: x.signature, |
|
|
|