Browse Source

add isChange to address model

activeAddress
Ivan Socolsky 10 years ago
parent
commit
24e6ceeab5
  1. 2
      lib/model/address.js
  2. 4
      lib/model/wallet.js
  3. 8
      test/integration/server.js

2
lib/model/address.js

@ -13,6 +13,7 @@ Address.create = function(opts) {
x.createdOn = Math.floor(Date.now() / 1000);
x.address = opts.address;
x.isChange = opts.isChange;
x.path = opts.path;
x.publicKeys = opts.publicKeys;
return x;
@ -23,6 +24,7 @@ Address.fromObj = function(obj) {
x.createdOn = obj.createdOn;
x.address = obj.address;
x.isChange = obj.isChange;
x.path = obj.path;
x.publicKeys = obj.publicKeys;
return x;

4
lib/model/wallet.js

@ -122,7 +122,9 @@ Wallet.prototype.createAddress = function(isChange) {
$.checkState(this.isComplete());
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;
};

8
test/integration/server.js

@ -534,6 +534,7 @@ describe('Copay server', function() {
should.not.exist(err);
address.should.exist;
address.address.should.equal('38Jf1QE7ddXscW76ACgJrNkMWBwDAgMm6M');
address.isChange.should.be.false;
address.path.should.equal('m/2147483647/0/0');
done();
});
@ -669,6 +670,13 @@ describe('Copay server', function() {
should.not.exist(err);
balance.totalAmount.should.equal(helpers.toSatoshi(300));
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();
});
});

Loading…
Cancel
Save