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,
|
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,
|
|
||||||
}];
|
|
||||||
} else {
|
|
||||||
x.requestPubKeys = obj.requestPubKeys;
|
x.requestPubKeys = obj.requestPubKeys;
|
||||||
}
|
Copayer.expandForCompat(x);
|
||||||
|
|
||||||
x.addressManager = AddressManager.fromObj(obj.addressManager);
|
x.addressManager = AddressManager.fromObj(obj.addressManager);
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
|
|
@ -94,7 +94,8 @@ Wallet.prototype.isShared = function() {
|
||||||
|
|
||||||
Wallet.prototype._updatePublicKeyRing = function() {
|
Wallet.prototype._updatePublicKeyRing = function() {
|
||||||
this.publicKeyRing = _.map(this.copayers, function(copayer) {
|
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 (err) return cb(err);
|
||||||
if (!result) return cb();
|
if (!result) return cb();
|
||||||
|
|
||||||
if (!result.requestPubKeys) {
|
Model.Copayer.expandForCompat(result);
|
||||||
result.requestPubKeys = [{
|
|
||||||
key: result.requestPubKey,
|
|
||||||
signature: result.signature,
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
|
|
||||||
return cb(null, result);
|
return cb(null, result);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue