Change PublicKeyRing index to array of AddressIndex
This commit is contained in:
parent
2e56a782bd
commit
e9f20b5de6
8 changed files with 104 additions and 61 deletions
|
|
@ -2,27 +2,28 @@
|
|||
|
||||
var imports = require('soop').imports();
|
||||
var preconditions = require('preconditions').singleton();
|
||||
var Structure = require('./Structure');
|
||||
|
||||
function AddressIndex(opts) {
|
||||
opts = opts || {};
|
||||
this.walletId = opts.walletId;
|
||||
this.cosigner = opts.cosigner || 0;
|
||||
|
||||
this.cosigner = opts.cosigner || Structure.SHARED_INDEX;
|
||||
this.changeIndex = opts.changeIndex || 0;
|
||||
this.receiveIndex = opts.receiveIndex || 0;
|
||||
}
|
||||
|
||||
AddressIndex.fromList = function(indexes) {
|
||||
return indexes.map(function(i) { return AddressIndex.fromObj(i); });
|
||||
}
|
||||
|
||||
AddressIndex.fromObj = function(data) {
|
||||
if (data instanceof AddressIndex) {
|
||||
throw new Error('bad data format: Did you use .toObj()?');
|
||||
}
|
||||
var ret = new AddressIndex(data);
|
||||
return ret;
|
||||
return new AddressIndex(data);
|
||||
};
|
||||
|
||||
AddressIndex.prototype.toObj = function() {
|
||||
return {
|
||||
walletId: this.walletId,
|
||||
cosigner: this.cosigner,
|
||||
changeIndex: this.changeIndex,
|
||||
receiveIndex: this.receiveIndex
|
||||
|
|
@ -54,7 +55,6 @@ AddressIndex.prototype.increment = function(isChange) {
|
|||
|
||||
AddressIndex.prototype.merge = function(inAddressIndex) {
|
||||
preconditions.shouldBeObject(inAddressIndex)
|
||||
.checkArgument(this.walletId == inAddressIndex.walletId)
|
||||
.checkArgument(this.cosigner == inAddressIndex.cosigner);
|
||||
|
||||
var hasChanged = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue