Add a pre-generated address to the shared branch

This commit is contained in:
Yemel Jardi 2014-07-31 16:13:27 -03:00
parent aa8211a40e
commit fdabdc64fe
5 changed files with 18 additions and 7 deletions

View File

@ -18,7 +18,7 @@ function HDParams(opts) {
HDParams.init = function(totalCopayers) {
preconditions.shouldBeNumber(totalCopayers);
var ret = [new HDParams()];
var ret = [new HDParams({receiveIndex: 1})];
for (var i = 0 ; i < totalCopayers ; i++) {
ret.push(new HDParams({copayerIndex: i}));
}

View File

@ -185,13 +185,14 @@ angular.module('copayApp.services')
root.updateAddressList = function() {
var w = $rootScope.wallet;
if (w)
if (w && w.isReady())
$rootScope.addrInfos = w.getAddressesInfo();
};
root.updateBalance = function(cb) {
var w = $rootScope.wallet;
if (!w) return root.onErrorDigest();
if (!w.isReady()) return;
$rootScope.balanceByAddr = {};
$rootScope.updatingBalance = true;

View File

@ -46,6 +46,10 @@ FakeWallet.prototype.getAddressesInfo = function() {
return ret;
};
FakeWallet.prototype.isReady = function() {
return true;
}
FakeWallet.prototype.getBalance = function(cb) {
return cb(null, this.balance, this.balanceByAddr, this.safeBalance);

View File

@ -145,9 +145,8 @@ describe('PublicKeyRing model', function() {
var k = createW();
var w = k.w;
var a = w.getAddresses();
a.length.should.equal(0);
a.length.should.equal(1);
[true, false].forEach(function(isChange){
for (var i = 0; i < 2; i++) {
@ -156,15 +155,22 @@ describe('PublicKeyRing model', function() {
});
var as = w.getAddressesInfo();
as.length.should.equal(4);
as.length.should.equal(5); // include pre-generated shared one
for (var j in as) {
var a = as[j];
a.address.isValid().should.equal(true);
a.addressStr.should.equal(a.address.toString());
a.isChange.should.equal([false, false, true, true][j]);
a.isChange.should.equal([false, false, false, true, true][j]);
}
});
it('should start with one shared address', function() {
var k = createW();
var a = k.w.getAddresses();
a.length.should.equal(1);
});
it('should count generation indexes', function() {
var k = createW();
var w = k.w;

View File

@ -594,7 +594,7 @@ describe('Wallet model', function() {
it('should get balance', function(done) {
var w = createW();
var w = createW2();
var spy = sinon.spy(w.blockchain, 'getUnspent');
w.blockchain.fixUnspent([]);
w.getBalance(function(err, balance, balanceByAddr, safeBalance) {