mirror of https://github.com/BTCPrivate/copay.git
Add a pre-generated address to the shared branch
This commit is contained in:
parent
aa8211a40e
commit
fdabdc64fe
|
@ -18,7 +18,7 @@ function HDParams(opts) {
|
||||||
|
|
||||||
HDParams.init = function(totalCopayers) {
|
HDParams.init = function(totalCopayers) {
|
||||||
preconditions.shouldBeNumber(totalCopayers);
|
preconditions.shouldBeNumber(totalCopayers);
|
||||||
var ret = [new HDParams()];
|
var ret = [new HDParams({receiveIndex: 1})];
|
||||||
for (var i = 0 ; i < totalCopayers ; i++) {
|
for (var i = 0 ; i < totalCopayers ; i++) {
|
||||||
ret.push(new HDParams({copayerIndex: i}));
|
ret.push(new HDParams({copayerIndex: i}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,13 +185,14 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
root.updateAddressList = function() {
|
root.updateAddressList = function() {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
if (w)
|
if (w && w.isReady())
|
||||||
$rootScope.addrInfos = w.getAddressesInfo();
|
$rootScope.addrInfos = w.getAddressesInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
root.updateBalance = function(cb) {
|
root.updateBalance = function(cb) {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
if (!w) return root.onErrorDigest();
|
if (!w) return root.onErrorDigest();
|
||||||
|
if (!w.isReady()) return;
|
||||||
|
|
||||||
$rootScope.balanceByAddr = {};
|
$rootScope.balanceByAddr = {};
|
||||||
$rootScope.updatingBalance = true;
|
$rootScope.updatingBalance = true;
|
||||||
|
|
|
@ -46,6 +46,10 @@ FakeWallet.prototype.getAddressesInfo = function() {
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FakeWallet.prototype.isReady = function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FakeWallet.prototype.getBalance = function(cb) {
|
FakeWallet.prototype.getBalance = function(cb) {
|
||||||
return cb(null, this.balance, this.balanceByAddr, this.safeBalance);
|
return cb(null, this.balance, this.balanceByAddr, this.safeBalance);
|
||||||
|
|
|
@ -145,9 +145,8 @@ describe('PublicKeyRing model', function() {
|
||||||
var k = createW();
|
var k = createW();
|
||||||
var w = k.w;
|
var w = k.w;
|
||||||
|
|
||||||
|
|
||||||
var a = w.getAddresses();
|
var a = w.getAddresses();
|
||||||
a.length.should.equal(0);
|
a.length.should.equal(1);
|
||||||
|
|
||||||
[true, false].forEach(function(isChange){
|
[true, false].forEach(function(isChange){
|
||||||
for (var i = 0; i < 2; i++) {
|
for (var i = 0; i < 2; i++) {
|
||||||
|
@ -156,15 +155,22 @@ describe('PublicKeyRing model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var as = w.getAddressesInfo();
|
var as = w.getAddressesInfo();
|
||||||
as.length.should.equal(4);
|
as.length.should.equal(5); // include pre-generated shared one
|
||||||
for (var j in as) {
|
for (var j in as) {
|
||||||
var a = as[j];
|
var a = as[j];
|
||||||
a.address.isValid().should.equal(true);
|
a.address.isValid().should.equal(true);
|
||||||
a.addressStr.should.equal(a.address.toString());
|
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() {
|
it('should count generation indexes', function() {
|
||||||
var k = createW();
|
var k = createW();
|
||||||
var w = k.w;
|
var w = k.w;
|
||||||
|
|
|
@ -594,7 +594,7 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
|
|
||||||
it('should get balance', function(done) {
|
it('should get balance', function(done) {
|
||||||
var w = createW();
|
var w = createW2();
|
||||||
var spy = sinon.spy(w.blockchain, 'getUnspent');
|
var spy = sinon.spy(w.blockchain, 'getUnspent');
|
||||||
w.blockchain.fixUnspent([]);
|
w.blockchain.fixUnspent([]);
|
||||||
w.getBalance(function(err, balance, balanceByAddr, safeBalance) {
|
w.getBalance(function(err, balance, balanceByAddr, safeBalance) {
|
||||||
|
|
Loading…
Reference in New Issue