add isChange to address model
This commit is contained in:
parent
0672c9084f
commit
24e6ceeab5
|
@ -13,6 +13,7 @@ Address.create = function(opts) {
|
||||||
|
|
||||||
x.createdOn = Math.floor(Date.now() / 1000);
|
x.createdOn = Math.floor(Date.now() / 1000);
|
||||||
x.address = opts.address;
|
x.address = opts.address;
|
||||||
|
x.isChange = opts.isChange;
|
||||||
x.path = opts.path;
|
x.path = opts.path;
|
||||||
x.publicKeys = opts.publicKeys;
|
x.publicKeys = opts.publicKeys;
|
||||||
return x;
|
return x;
|
||||||
|
@ -23,6 +24,7 @@ Address.fromObj = function(obj) {
|
||||||
|
|
||||||
x.createdOn = obj.createdOn;
|
x.createdOn = obj.createdOn;
|
||||||
x.address = obj.address;
|
x.address = obj.address;
|
||||||
|
x.isChange = obj.isChange;
|
||||||
x.path = obj.path;
|
x.path = obj.path;
|
||||||
x.publicKeys = obj.publicKeys;
|
x.publicKeys = obj.publicKeys;
|
||||||
return x;
|
return x;
|
||||||
|
|
|
@ -122,7 +122,9 @@ Wallet.prototype.createAddress = function(isChange) {
|
||||||
$.checkState(this.isComplete());
|
$.checkState(this.isComplete());
|
||||||
|
|
||||||
var path = this.addressManager.getNewAddressPath(isChange);
|
var path = this.addressManager.getNewAddressPath(isChange);
|
||||||
return Address.create(WalletUtils.deriveAddress(this.publicKeyRing, path, this.m, this.network));
|
var address = Address.create(WalletUtils.deriveAddress(this.publicKeyRing, path, this.m, this.network));
|
||||||
|
address.isChange = isChange;
|
||||||
|
return address;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -534,6 +534,7 @@ describe('Copay server', function() {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
address.should.exist;
|
address.should.exist;
|
||||||
address.address.should.equal('38Jf1QE7ddXscW76ACgJrNkMWBwDAgMm6M');
|
address.address.should.equal('38Jf1QE7ddXscW76ACgJrNkMWBwDAgMm6M');
|
||||||
|
address.isChange.should.be.false;
|
||||||
address.path.should.equal('m/2147483647/0/0');
|
address.path.should.equal('m/2147483647/0/0');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -669,6 +670,13 @@ describe('Copay server', function() {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
balance.totalAmount.should.equal(helpers.toSatoshi(300));
|
balance.totalAmount.should.equal(helpers.toSatoshi(300));
|
||||||
balance.lockedAmount.should.equal(helpers.toSatoshi(100));
|
balance.lockedAmount.should.equal(helpers.toSatoshi(100));
|
||||||
|
server.getAddresses({}, function(err, addresses) {
|
||||||
|
should.not.exist(err);
|
||||||
|
var change = _.filter(addresses, {
|
||||||
|
isChange: true
|
||||||
|
});
|
||||||
|
change.length.should.equal(1);
|
||||||
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue