Add cosigner index to AddressIndex

This commit is contained in:
Yemel Jardi 2014-06-27 15:06:39 -03:00
commit 2e56a782bd
3 changed files with 30 additions and 6 deletions

View file

@ -1,11 +1,12 @@
'use strict';
var imports = require('soop').imports();
var preconditions = require('preconditions').singleton();
function AddressIndex(opts) {
opts = opts || {};
this.walletId = opts.walletId;
this.cosigner = opts.cosigner || 0;
this.changeIndex = opts.changeIndex || 0;
this.receiveIndex = opts.receiveIndex || 0;
@ -22,8 +23,9 @@ AddressIndex.fromObj = function(data) {
AddressIndex.prototype.toObj = function() {
return {
walletId: this.walletId,
cosigner: this.cosigner,
changeIndex: this.changeIndex,
receiveIndex: this.receiveIndex,
receiveIndex: this.receiveIndex
};
};
@ -34,10 +36,10 @@ AddressIndex.prototype.checkRange = function(index, isChange) {
}
};
AddressIndex.prototype.getChangeIndex = function() {
return this.changeIndex;
};
AddressIndex.prototype.getReceiveIndex = function() {
return this.receiveIndex;
};
@ -51,6 +53,10 @@ 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;
// Indexes