debugging
This commit is contained in:
parent
fcb254b39c
commit
8032bae431
8 changed files with 72 additions and 14 deletions
|
|
@ -288,6 +288,8 @@ Network.prototype._setupConnectionHandlers = function(opts, cb) {
|
||||||
self.socket.emit('subscribe', pubkey);
|
self.socket.emit('subscribe', pubkey);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
log.debug('Async subs done');
|
||||||
|
|
||||||
if (typeof cb === 'function') cb();
|
if (typeof cb === 'function') cb();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,9 +133,12 @@ Identity.createFromPartialJson = function(jsonString, opts, callback) {
|
||||||
async.map(exported.walletIds, function(walletId, callback) {
|
async.map(exported.walletIds, function(walletId, callback) {
|
||||||
identity.retrieveWalletFromStorage(walletId, {}, function(error, wallet) {
|
identity.retrieveWalletFromStorage(walletId, {}, function(error, wallet) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
|
||||||
|
console.log('[Identity.js.136] GOT:', wallet.getName()); //TODO
|
||||||
identity.wallets[wallet.getId()] = wallet;
|
identity.wallets[wallet.getId()] = wallet;
|
||||||
identity.bindWallet(wallet);
|
identity.bindWallet(wallet);
|
||||||
wallet.netStart();
|
wallet.netStart();
|
||||||
|
console.log('[Identity.js.136] STARTED:', wallet.getName()); //TODO
|
||||||
}
|
}
|
||||||
callback(error, wallet);
|
callback(error, wallet);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,8 @@ Insight.prototype.subscribe = function(addresses) {
|
||||||
addresses = Array.isArray(addresses) ? addresses : [addresses];
|
addresses = Array.isArray(addresses) ? addresses : [addresses];
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
console.log('[Insight.js.202] subscribe STARTED'); //TODO
|
||||||
|
|
||||||
function handlerFor(self, address) {
|
function handlerFor(self, address) {
|
||||||
return function(txid) {
|
return function(txid) {
|
||||||
// verify the address is still subscribed
|
// verify the address is still subscribed
|
||||||
|
|
@ -220,12 +222,15 @@ Insight.prototype.subscribe = function(addresses) {
|
||||||
if (!self.subscribed[address]) {
|
if (!self.subscribed[address]) {
|
||||||
var handler = handlerFor(self, address);
|
var handler = handlerFor(self, address);
|
||||||
self.subscribed[address] = handler;
|
self.subscribed[address] = handler;
|
||||||
log.debug('Subcribe to: ', address);
|
log.debug('Subscribe to: ', address);
|
||||||
|
|
||||||
s.emit('subscribe', address);
|
s.emit('subscribe', address);
|
||||||
s.on(address, handler);
|
s.on(address, handler);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
console.log('[Insight.js.202] subscribe ENDED'); //TODO
|
||||||
};
|
};
|
||||||
|
|
||||||
Insight.prototype.getSubscriptions = function(addresses) {
|
Insight.prototype.getSubscriptions = function(addresses) {
|
||||||
|
|
|
||||||
|
|
@ -85,22 +85,30 @@ PublicKeyRing.trim = function(data) {
|
||||||
* @param {object} data - a serialized version of PublicKeyRing {@see PublicKeyRing#trim}
|
* @param {object} data - a serialized version of PublicKeyRing {@see PublicKeyRing#trim}
|
||||||
* @return {PublicKeyRing} - the deserialized object
|
* @return {PublicKeyRing} - the deserialized object
|
||||||
*/
|
*/
|
||||||
PublicKeyRing.fromObj = function(data) {
|
PublicKeyRing.fromObj = function(opts) {
|
||||||
preconditions.checkArgument(!(data instanceof PublicKeyRing), 'bad data format: Did you use .toObj()?');
|
preconditions.checkArgument(!(opts instanceof PublicKeyRing), 'bad opts format: Did you use .toObj()?');
|
||||||
var opts = PublicKeyRing.trim(data);
|
|
||||||
|
|
||||||
// Support old indexes schema
|
// Support old indexes schema
|
||||||
if (!Array.isArray(opts.indexes)) {
|
if (!Array.isArray(opts.indexes)) {
|
||||||
opts.indexes = HDParams.update(opts.indexes, opts.totalCopayers);
|
opts.indexes = HDParams.update(opts.indexes, opts.totalCopayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ret = new PublicKeyRing(opts);
|
var pkr = new PublicKeyRing(opts);
|
||||||
|
|
||||||
for (var k in opts.copayersExtPubKeys) {
|
for (var k in opts.copayersExtPubKeys) {
|
||||||
ret.addCopayer(opts.copayersExtPubKeys[k]);
|
pkr.addCopayer(opts.copayersExtPubKeys[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
if (opts._cache){
|
||||||
|
log.debug('PublicKeyRing: Using address cache');
|
||||||
|
pkr._cacheAddressMap = opts._cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pkr;
|
||||||
|
};
|
||||||
|
|
||||||
|
PublicKeyRing.fromUntrustedObj = function(opts) {
|
||||||
|
return PublicKeyRing.fromObj(PublicKeyRing.trim(opts));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -120,10 +128,17 @@ PublicKeyRing.prototype.toObj = function() {
|
||||||
copayersExtPubKeys: this.copayersHK.map(function(b) {
|
copayersExtPubKeys: this.copayersHK.map(function(b) {
|
||||||
return b.extendedPublicKeyString();
|
return b.extendedPublicKeyString();
|
||||||
}),
|
}),
|
||||||
nicknameFor: this.nicknameFor
|
nicknameFor: this.nicknameFor,
|
||||||
|
_cache: this._cacheAddressMap
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
PublicKeyRing.prototype.toTrimmedObj = function() {
|
||||||
|
return PublicKeyRing.trim(this.toObj());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc
|
* @desc
|
||||||
* Retrieve a copayer's public key as a hexadecimal encoded string
|
* Retrieve a copayer's public key as a hexadecimal encoded string
|
||||||
|
|
@ -335,6 +350,8 @@ PublicKeyRing.prototype.getRedeemScript = function(index, isChange, copayerIndex
|
||||||
PublicKeyRing.prototype.getAddress = function(index, isChange, id) {
|
PublicKeyRing.prototype.getAddress = function(index, isChange, id) {
|
||||||
var copayerIndex = this.getCosigner(id);
|
var copayerIndex = this.getCosigner(id);
|
||||||
if (!this._cachedAddress(index, isChange, id)) {
|
if (!this._cachedAddress(index, isChange, id)) {
|
||||||
|
|
||||||
|
console.log('[PublicKeyRing.js.338] CACHE MISS'); //TODO
|
||||||
var script = this.getRedeemScript(index, isChange, copayerIndex);
|
var script = this.getRedeemScript(index, isChange, copayerIndex);
|
||||||
var address = Address.fromScript(script, this.network.name);
|
var address = Address.fromScript(script, this.network.name);
|
||||||
this.addressToPath[address.toString()] = HDPath.FullBranch(index, isChange, copayerIndex);
|
this.addressToPath[address.toString()] = HDPath.FullBranch(index, isChange, copayerIndex);
|
||||||
|
|
@ -472,12 +489,16 @@ PublicKeyRing.prototype.getCosigner = function(pubKey) {
|
||||||
*/
|
*/
|
||||||
PublicKeyRing.prototype.getAddressesInfo = function(opts, pubkey) {
|
PublicKeyRing.prototype.getAddressesInfo = function(opts, pubkey) {
|
||||||
|
|
||||||
|
console.log('[PublicKeyRing.js.474] STARTED'); //TODO
|
||||||
var ret = [];
|
var ret = [];
|
||||||
var self = this;
|
var self = this;
|
||||||
var copayerIndex = pubkey && this.getCosigner(pubkey);
|
var copayerIndex = pubkey && this.getCosigner(pubkey);
|
||||||
|
console.log('[PublicKeyRing.js.478:copayerIndex:]',copayerIndex); //TODO
|
||||||
this.indexes.forEach(function(index) {
|
this.indexes.forEach(function(index) {
|
||||||
|
console.log('[PublicKeyRing.js.479:index:]',index); //TODO
|
||||||
ret = ret.concat(self.getAddressesInfoForIndex(index, opts, copayerIndex));
|
ret = ret.concat(self.getAddressesInfoForIndex(index, opts, copayerIndex));
|
||||||
});
|
});
|
||||||
|
console.log('[PublicKeyRing.js.474] END'); //TODO
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -511,15 +532,23 @@ PublicKeyRing.prototype.getAddressesInfoForIndex = function(index, opts, copayer
|
||||||
isChange: isChange,
|
isChange: isChange,
|
||||||
owned: isOwned
|
owned: isOwned
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('[PublicKeyRing.js.518] Appending address'); //TODO
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('[PublicKeyRing.js.519] getAddressesInfoForIndex'); //TODO
|
||||||
for (var i = 0; !opts.excludeChange && i < index.changeIndex; i++) {
|
for (var i = 0; !opts.excludeChange && i < index.changeIndex; i++) {
|
||||||
appendAddressInfo(this.getAddress(i, true, index.copayerIndex), true);
|
appendAddressInfo(this.getAddress(i, true, index.copayerIndex), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('[PublicKeyRing.js.526]'); //TODO
|
||||||
for (var i = 0; !opts.excludeMain && i < index.receiveIndex; i++) {
|
for (var i = 0; !opts.excludeMain && i < index.receiveIndex; i++) {
|
||||||
appendAddressInfo(this.getAddress(i, false, index.copayerIndex), false);
|
appendAddressInfo(this.getAddress(i, false, index.copayerIndex), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
console.log('[PublicKeyRing.js.534] CACHE IS' , this._cacheAddressMap); //TODO
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,7 @@ Wallet.prototype.changeSettings = function(settings) {
|
||||||
Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
||||||
log.debug('Wallet:' + this.id + ' RECV PUBLICKEYRING:', data);
|
log.debug('Wallet:' + this.id + ' RECV PUBLICKEYRING:', data);
|
||||||
|
|
||||||
var inPKR = PublicKeyRing.fromObj(data.publicKeyRing);
|
var inPKR = PublicKeyRing.fromUntrustedObj(data.publicKeyRing);
|
||||||
var wasIncomplete = !this.publicKeyRing.isComplete();
|
var wasIncomplete = !this.publicKeyRing.isComplete();
|
||||||
var hasChanged;
|
var hasChanged;
|
||||||
|
|
||||||
|
|
@ -886,6 +886,8 @@ Wallet.prototype._lockIncomming = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype._setBlockchainListeners = function() {
|
Wallet.prototype._setBlockchainListeners = function() {
|
||||||
|
|
||||||
|
console.log('[Wallet.js.889] address'); //TODO
|
||||||
var self = this;
|
var self = this;
|
||||||
self.blockchain.removeAllListeners();
|
self.blockchain.removeAllListeners();
|
||||||
self.subscribeToAddresses();
|
self.subscribeToAddresses();
|
||||||
|
|
@ -1053,7 +1055,6 @@ Wallet.prototype.toObj = function() {
|
||||||
settings: this.settings,
|
settings: this.settings,
|
||||||
networkNonce: this.network.getHexNonce(), //yours
|
networkNonce: this.network.getHexNonce(), //yours
|
||||||
networkNonces: this.network.getHexNonces(), //copayers
|
networkNonces: this.network.getHexNonces(), //copayers
|
||||||
publicKeyRing: this.publicKeyRing.toObj(),
|
|
||||||
txProposals: this.txProposals.toObj(),
|
txProposals: this.txProposals.toObj(),
|
||||||
privateKey: this.privateKey ? this.privateKey.toObj() : undefined,
|
privateKey: this.privateKey ? this.privateKey.toObj() : undefined,
|
||||||
addressBook: this.addressBook,
|
addressBook: this.addressBook,
|
||||||
|
|
@ -1307,7 +1308,7 @@ Wallet.prototype.sendWalletId = function(recipients) {
|
||||||
* @param {string[]} [recipients] - the pubkeys of the recipients
|
* @param {string[]} [recipients] - the pubkeys of the recipients
|
||||||
*/
|
*/
|
||||||
Wallet.prototype.sendPublicKeyRing = function(recipients) {
|
Wallet.prototype.sendPublicKeyRing = function(recipients) {
|
||||||
var publicKeyRingObj = this.publicKeyRing.toObj();
|
var publicKeyRingObj = this.publicKeyRing.toTrimmedObj();
|
||||||
|
|
||||||
this._sendToPeers(recipients, {
|
this._sendToPeers(recipients, {
|
||||||
type: 'publicKeyRing',
|
type: 'publicKeyRing',
|
||||||
|
|
@ -2001,6 +2002,7 @@ Wallet.prototype.getAddressesStr = function(opts) {
|
||||||
|
|
||||||
Wallet.prototype.subscribeToAddresses = function() {
|
Wallet.prototype.subscribeToAddresses = function() {
|
||||||
if (!this.publicKeyRing.isComplete()) return;
|
if (!this.publicKeyRing.isComplete()) return;
|
||||||
|
console.log('[Wallet.js.2002:subscribeToAddresses:]'); //TODO
|
||||||
|
|
||||||
var addrInfo = this.publicKeyRing.getAddressesInfo();
|
var addrInfo = this.publicKeyRing.getAddressesInfo();
|
||||||
this.blockchain.subscribe(_.pluck(addrInfo, 'addressStr'));
|
this.blockchain.subscribe(_.pluck(addrInfo, 'addressStr'));
|
||||||
|
|
|
||||||
|
|
@ -217,22 +217,32 @@ angular.module('copayApp.services')
|
||||||
$rootScope.wallet = w;
|
$rootScope.wallet = w;
|
||||||
w.updateFocusedTimestamp(Date.now());
|
w.updateFocusedTimestamp(Date.now());
|
||||||
root.redirIfLogged();
|
root.redirIfLogged();
|
||||||
root.updateTxs();
|
$timeout(function(){
|
||||||
root.updateBalance(w, function() {
|
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
})
|
},1)
|
||||||
|
// root.updateTxs();
|
||||||
|
// root.updateBalance(w, function() {
|
||||||
|
// $rootScope.$digest();
|
||||||
|
// })
|
||||||
};
|
};
|
||||||
|
|
||||||
root.bindProfile = function($scope, iden, w) {
|
root.bindProfile = function($scope, iden, w) {
|
||||||
|
|
||||||
|
console.log('[controllerUtils.js.230] bindProfile Globals'); //TODO
|
||||||
root.setupGlobalVariables(iden);
|
root.setupGlobalVariables(iden);
|
||||||
|
console.log('[controllerUtils.js.230] bindProfile Wallets'); //TODO
|
||||||
root.rebindWallets($scope, iden);
|
root.rebindWallets($scope, iden);
|
||||||
if (w) {
|
if (w) {
|
||||||
|
console.log('[controllerUtils.js.230] bindProfile set Focus'); //TODO
|
||||||
root.setFocusedWallet(w);
|
root.setFocusedWallet(w);
|
||||||
} else {
|
} else {
|
||||||
$location.path('/create');
|
$location.path('/create');
|
||||||
}
|
}
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
|
|
||||||
|
console.log('[controllerUtils.js.242] DIGEST'); //TODO
|
||||||
$rootScope.$digest()
|
$rootScope.$digest()
|
||||||
|
console.log('[controllerUtils.js.242] DIGEST DONE'); //TODO
|
||||||
}, 1);
|
}, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -310,6 +320,10 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
root.updateBalance = function(w, cb, refreshAll) {
|
root.updateBalance = function(w, cb, refreshAll) {
|
||||||
|
|
||||||
|
return
|
||||||
|
cb?cb(): null;
|
||||||
|
|
||||||
|
|
||||||
w = w || $rootScope.wallet;
|
w = w || $rootScope.wallet;
|
||||||
if (!w) return root.onErrorDigest();
|
if (!w) return root.onErrorDigest();
|
||||||
if (!w.isReady()) return;
|
if (!w.isReady()) return;
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,8 @@ angular.module('copayApp.services')
|
||||||
$rootScope.$digest()
|
$rootScope.$digest()
|
||||||
}, 1);
|
}, 1);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
console.log('[identityService.js.95] LISTO OPEN!!'); //TODO
|
||||||
var firstWallet = iden.getLastFocusedWallet();
|
var firstWallet = iden.getLastFocusedWallet();
|
||||||
controllerUtils.bindProfile(scope, iden, firstWallet);
|
controllerUtils.bindProfile(scope, iden, firstWallet);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
<div class="contener_mixte"><div class="ballcolor ball_4"> </div></div>
|
<div class="contener_mixte"><div class="ballcolor ball_4"> </div></div>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-gray size-12" translate>Accessing your profile...</span>
|
<span class="text-gray size-12" translate>Accessing your profile...</span>
|
||||||
|
13
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue