add backwards compat with bwc
This commit is contained in:
parent
0a1b9319e5
commit
0433dc05cb
|
@ -38,6 +38,13 @@ Copayer.create = function(opts) {
|
|||
signature: opts.signature,
|
||||
}];
|
||||
}
|
||||
|
||||
x.requestPubKey = opts.requestPubKey;
|
||||
x.signature = opts.signature;
|
||||
|
||||
x.requestPubKeys = opts.requestPubKeys;
|
||||
Copayer.expandForCompat(x);
|
||||
|
||||
x.addressManager = AddressManager.create({
|
||||
copayerIndex: opts.copayerIndex
|
||||
});
|
||||
|
@ -45,6 +52,21 @@ Copayer.create = function(opts) {
|
|||
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) {
|
||||
var x = new Copayer();
|
||||
|
||||
|
@ -52,14 +74,13 @@ Copayer.fromObj = function(obj) {
|
|||
x.id = obj.id;
|
||||
x.name = obj.name;
|
||||
x.xPubKey = obj.xPubKey;
|
||||
if (!obj.requestPubKeys) {
|
||||
x.requestPubKeys = [{
|
||||
key: obj.requestPubKey,
|
||||
signature: obj.signature,
|
||||
}];
|
||||
} else {
|
||||
x.requestPubKeys = obj.requestPubKeys;
|
||||
}
|
||||
|
||||
x.requestPubKey = obj.requestPubKey;
|
||||
x.signature = obj.signature;
|
||||
|
||||
x.requestPubKeys = obj.requestPubKeys;
|
||||
Copayer.expandForCompat(x);
|
||||
|
||||
x.addressManager = AddressManager.fromObj(obj.addressManager);
|
||||
return x;
|
||||
};
|
||||
|
|
|
@ -94,7 +94,8 @@ Wallet.prototype.isShared = function() {
|
|||
|
||||
Wallet.prototype._updatePublicKeyRing = function() {
|
||||
this.publicKeyRing = _.map(this.copayers, function(copayer) {
|
||||
return _.pick(copayer, ['xPubKey']);
|
||||
return _.pick(copayer, ['xPubKey', 'requestPubKey']);
|
||||
// return _.pick(copayer, ['xPubKey']);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -141,12 +141,7 @@ Storage.prototype.fetchCopayerLookup = function(copayerId, cb) {
|
|||
if (err) return cb(err);
|
||||
if (!result) return cb();
|
||||
|
||||
if (!result.requestPubKeys) {
|
||||
result.requestPubKeys = [{
|
||||
key: result.requestPubKey,
|
||||
signature: result.signature,
|
||||
}];
|
||||
}
|
||||
Model.Copayer.expandForCompat(result);
|
||||
|
||||
return cb(null, result);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue