debugging

This commit is contained in:
Matias Alejo Garcia 2014-11-28 13:10:15 -03:00
commit 8032bae431
8 changed files with 72 additions and 14 deletions

View file

@ -288,6 +288,8 @@ Network.prototype._setupConnectionHandlers = function(opts, cb) {
self.socket.emit('subscribe', pubkey);
});
log.debug('Async subs done');
if (typeof cb === 'function') cb();
});

View file

@ -133,9 +133,12 @@ Identity.createFromPartialJson = function(jsonString, opts, callback) {
async.map(exported.walletIds, function(walletId, callback) {
identity.retrieveWalletFromStorage(walletId, {}, function(error, wallet) {
if (!error) {
console.log('[Identity.js.136] GOT:', wallet.getName()); //TODO
identity.wallets[wallet.getId()] = wallet;
identity.bindWallet(wallet);
wallet.netStart();
console.log('[Identity.js.136] STARTED:', wallet.getName()); //TODO
}
callback(error, wallet);
});

View file

@ -200,6 +200,8 @@ Insight.prototype.subscribe = function(addresses) {
addresses = Array.isArray(addresses) ? addresses : [addresses];
var self = this;
console.log('[Insight.js.202] subscribe STARTED'); //TODO
function handlerFor(self, address) {
return function(txid) {
// verify the address is still subscribed
@ -220,12 +222,15 @@ Insight.prototype.subscribe = function(addresses) {
if (!self.subscribed[address]) {
var handler = handlerFor(self, address);
self.subscribed[address] = handler;
log.debug('Subcribe to: ', address);
log.debug('Subscribe to: ', address);
s.emit('subscribe', address);
s.on(address, handler);
}
});
console.log('[Insight.js.202] subscribe ENDED'); //TODO
};
Insight.prototype.getSubscriptions = function(addresses) {

View file

@ -85,22 +85,30 @@ PublicKeyRing.trim = function(data) {
* @param {object} data - a serialized version of PublicKeyRing {@see PublicKeyRing#trim}
* @return {PublicKeyRing} - the deserialized object
*/
PublicKeyRing.fromObj = function(data) {
preconditions.checkArgument(!(data instanceof PublicKeyRing), 'bad data format: Did you use .toObj()?');
var opts = PublicKeyRing.trim(data);
PublicKeyRing.fromObj = function(opts) {
preconditions.checkArgument(!(opts instanceof PublicKeyRing), 'bad opts format: Did you use .toObj()?');
// Support old indexes schema
if (!Array.isArray(opts.indexes)) {
opts.indexes = HDParams.update(opts.indexes, opts.totalCopayers);
}
var ret = new PublicKeyRing(opts);
var pkr = new PublicKeyRing(opts);
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) {
return b.extendedPublicKeyString();
}),
nicknameFor: this.nicknameFor
nicknameFor: this.nicknameFor,
_cache: this._cacheAddressMap
};
};
PublicKeyRing.prototype.toTrimmedObj = function() {
return PublicKeyRing.trim(this.toObj());
}
/**
* @desc
* 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) {
var copayerIndex = this.getCosigner(id);
if (!this._cachedAddress(index, isChange, id)) {
console.log('[PublicKeyRing.js.338] CACHE MISS'); //TODO
var script = this.getRedeemScript(index, isChange, copayerIndex);
var address = Address.fromScript(script, this.network.name);
this.addressToPath[address.toString()] = HDPath.FullBranch(index, isChange, copayerIndex);
@ -472,12 +489,16 @@ PublicKeyRing.prototype.getCosigner = function(pubKey) {
*/
PublicKeyRing.prototype.getAddressesInfo = function(opts, pubkey) {
console.log('[PublicKeyRing.js.474] STARTED'); //TODO
var ret = [];
var self = this;
var copayerIndex = pubkey && this.getCosigner(pubkey);
console.log('[PublicKeyRing.js.478:copayerIndex:]',copayerIndex); //TODO
this.indexes.forEach(function(index) {
console.log('[PublicKeyRing.js.479:index:]',index); //TODO
ret = ret.concat(self.getAddressesInfoForIndex(index, opts, copayerIndex));
});
console.log('[PublicKeyRing.js.474] END'); //TODO
return ret;
};
@ -511,15 +532,23 @@ PublicKeyRing.prototype.getAddressesInfoForIndex = function(index, opts, copayer
isChange: isChange,
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++) {
appendAddressInfo(this.getAddress(i, true, index.copayerIndex), true);
}
console.log('[PublicKeyRing.js.526]'); //TODO
for (var i = 0; !opts.excludeMain && i < index.receiveIndex; i++) {
appendAddressInfo(this.getAddress(i, false, index.copayerIndex), false);
}
console.log('[PublicKeyRing.js.534] CACHE IS' , this._cacheAddressMap); //TODO
return ret;
};

View file

@ -314,7 +314,7 @@ Wallet.prototype.changeSettings = function(settings) {
Wallet.prototype._onPublicKeyRing = function(senderId, 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 hasChanged;
@ -886,6 +886,8 @@ Wallet.prototype._lockIncomming = function() {
};
Wallet.prototype._setBlockchainListeners = function() {
console.log('[Wallet.js.889] address'); //TODO
var self = this;
self.blockchain.removeAllListeners();
self.subscribeToAddresses();
@ -1053,7 +1055,6 @@ Wallet.prototype.toObj = function() {
settings: this.settings,
networkNonce: this.network.getHexNonce(), //yours
networkNonces: this.network.getHexNonces(), //copayers
publicKeyRing: this.publicKeyRing.toObj(),
txProposals: this.txProposals.toObj(),
privateKey: this.privateKey ? this.privateKey.toObj() : undefined,
addressBook: this.addressBook,
@ -1307,7 +1308,7 @@ Wallet.prototype.sendWalletId = function(recipients) {
* @param {string[]} [recipients] - the pubkeys of the recipients
*/
Wallet.prototype.sendPublicKeyRing = function(recipients) {
var publicKeyRingObj = this.publicKeyRing.toObj();
var publicKeyRingObj = this.publicKeyRing.toTrimmedObj();
this._sendToPeers(recipients, {
type: 'publicKeyRing',
@ -2001,6 +2002,7 @@ Wallet.prototype.getAddressesStr = function(opts) {
Wallet.prototype.subscribeToAddresses = function() {
if (!this.publicKeyRing.isComplete()) return;
console.log('[Wallet.js.2002:subscribeToAddresses:]'); //TODO
var addrInfo = this.publicKeyRing.getAddressesInfo();
this.blockchain.subscribe(_.pluck(addrInfo, 'addressStr'));

View file

@ -217,22 +217,32 @@ angular.module('copayApp.services')
$rootScope.wallet = w;
w.updateFocusedTimestamp(Date.now());
root.redirIfLogged();
root.updateTxs();
root.updateBalance(w, function() {
$timeout(function(){
$rootScope.$digest();
})
},1)
// root.updateTxs();
// root.updateBalance(w, function() {
// $rootScope.$digest();
// })
};
root.bindProfile = function($scope, iden, w) {
console.log('[controllerUtils.js.230] bindProfile Globals'); //TODO
root.setupGlobalVariables(iden);
console.log('[controllerUtils.js.230] bindProfile Wallets'); //TODO
root.rebindWallets($scope, iden);
if (w) {
console.log('[controllerUtils.js.230] bindProfile set Focus'); //TODO
root.setFocusedWallet(w);
} else {
$location.path('/create');
}
$timeout(function() {
console.log('[controllerUtils.js.242] DIGEST'); //TODO
$rootScope.$digest()
console.log('[controllerUtils.js.242] DIGEST DONE'); //TODO
}, 1);
};
@ -310,6 +320,10 @@ angular.module('copayApp.services')
root.updateBalance = function(w, cb, refreshAll) {
return
cb?cb(): null;
w = w || $rootScope.wallet;
if (!w) return root.onErrorDigest();
if (!w.isReady()) return;

View file

@ -92,6 +92,8 @@ angular.module('copayApp.services')
$rootScope.$digest()
}, 1);
} else {
console.log('[identityService.js.95] LISTO OPEN!!'); //TODO
var firstWallet = iden.getLastFocusedWallet();
controllerUtils.bindProfile(scope, iden, firstWallet);
}

View file

@ -9,6 +9,7 @@
<div class="contener_mixte"><div class="ballcolor ball_4">&nbsp;</div></div>
</div>
<span class="text-gray size-12" translate>Accessing your profile...</span>
13
</div>
</div>