fix join flow
This commit is contained in:
parent
a3d96535cd
commit
b391344daf
4 changed files with 26 additions and 18 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('CopayersController',
|
||||
function($scope, $rootScope, $location, backupService, identity, controllerUtils) {
|
||||
function($scope, $rootScope, $location, backupService, controllerUtils) {
|
||||
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
|
||||
$scope.hideAdv = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -294,11 +294,13 @@ Network.prototype.greet = function(copayerId, secretNumber) {
|
|||
};
|
||||
|
||||
Network.prototype._addCopayerMap = function(peerId, copayerId) {
|
||||
console.log('[Async.js.296:_addCopayerMap:]',peerId, copayerId); //TODO
|
||||
if (!this.copayerForPeer[peerId]) {
|
||||
if (Object.keys(this.copayerForPeer).length < this.maxPeers) {
|
||||
this.copayerForPeer[peerId] = copayerId;
|
||||
}
|
||||
}
|
||||
console.log('[Async.js.296:_addCopayerMap:]',this.copayerForPeer); //TODO
|
||||
};
|
||||
|
||||
Network.prototype._setInboundPeerAuth = function(peerId) {
|
||||
|
|
@ -374,6 +376,7 @@ Network.prototype.send = function(dest, payload, cb) {
|
|||
dest = this.getCopayerIds();
|
||||
payload.isBroadcast = 1;
|
||||
}
|
||||
console.log('[Async.js.374:dest:]',dest); //TODO
|
||||
|
||||
if (typeof dest === 'string')
|
||||
dest = [dest];
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ function Identity(email, password, opts) {
|
|||
|
||||
this.walletDefaults = opts.walletDefaults || {};
|
||||
this.version = opts.version || version;
|
||||
this.email = email;
|
||||
|
||||
// open wallets
|
||||
this.openWallets = [];
|
||||
|
|
@ -376,7 +377,7 @@ Identity.prototype.createWallet = function(opts, cb) {
|
|||
});
|
||||
opts.publicKeyRing.addCopayer(
|
||||
opts.privateKey.deriveBIP45Branch().extendedPublicKeyString(),
|
||||
opts.nickname
|
||||
opts.nickname || this.email
|
||||
);
|
||||
log.debug('\t### PublicKeyRing Initialized');
|
||||
|
||||
|
|
@ -605,9 +606,10 @@ Identity.prototype.joinWallet = function(opts, cb) {
|
|||
|
||||
var walletOpts = _.clone(data.opts);
|
||||
walletOpts.id = data.walletId;
|
||||
walletOpts.network = joinNetwork;
|
||||
|
||||
walletOpts.privateKey = privateKey;
|
||||
walletOpts.nickname = opts.nickname || self.profile.name;
|
||||
walletOpts.nickname = opts.nickname || this.email;
|
||||
|
||||
if (opts.password)
|
||||
walletOpts.password = opts.password;
|
||||
|
|
|
|||
|
|
@ -380,6 +380,7 @@ Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
|||
|
||||
var inPKR = PublicKeyRing.fromObj(data.publicKeyRing);
|
||||
var wasIncomplete = !this.publicKeyRing.isComplete();
|
||||
console.log('[Wallet.js.382:wasIncomplete:]',wasIncomplete); //TODO
|
||||
var hasChanged;
|
||||
|
||||
try {
|
||||
|
|
@ -389,7 +390,7 @@ Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
|||
this.emit('connectionError', e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[Wallet.js.393:hasChanged:]',hasChanged); //TODO
|
||||
if (hasChanged) {
|
||||
if (wasIncomplete) {
|
||||
this.sendPublicKeyRing();
|
||||
|
|
@ -699,10 +700,7 @@ Wallet.prototype._onData = function(senderId, data, ts) {
|
|||
break;
|
||||
case 'walletReady':
|
||||
|
||||
console.log('[Wallet.js.653]', this.lastMessageFrom[senderId]); //TODO
|
||||
if (this.lastMessageFrom[senderId] !== 'walletReady') {
|
||||
|
||||
console.log('[Wallet.js.656]'); //TODO
|
||||
log.debug('Wallet:' + this.id + ' peer Sync received. since: ' + (data.sinceTs || 0));
|
||||
this.sendPublicKeyRing(senderId);
|
||||
this.sendAddressBook(senderId);
|
||||
|
|
@ -927,16 +925,27 @@ Wallet.prototype.netStart = function() {
|
|||
var self = this;
|
||||
var net = this.network;
|
||||
|
||||
net.removeAllListeners();
|
||||
net.on('connect', self._onConnect.bind(self));
|
||||
net.on('data', self._onData.bind(self));
|
||||
net.on('no messages', self._onNoMessages.bind(self));
|
||||
net.on('connect_error', function() {
|
||||
self.emit('connectionError');
|
||||
});
|
||||
|
||||
if (this.publicKeyRing.isComplete()) {
|
||||
this._lockIncomming();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (net.started) {
|
||||
log.debug('Wallet:' + self.id + ' Wallet networking was ready')
|
||||
self.emit('ready', net.getPeer());
|
||||
return;
|
||||
}
|
||||
|
||||
net.removeAllListeners();
|
||||
net.on('connect', self._onConnect.bind(self));
|
||||
net.on('data', self._onData.bind(self));
|
||||
net.on('no messages', self._onNoMessages.bind(self));
|
||||
|
||||
|
||||
var myId = self.getMyCopayerId();
|
||||
var myIdPriv = self.getMyCopayerIdPriv();
|
||||
|
|
@ -949,13 +958,6 @@ Wallet.prototype.netStart = function() {
|
|||
secretNumber: self.secretNumber,
|
||||
};
|
||||
|
||||
if (this.publicKeyRing.isComplete()) {
|
||||
this._lockIncomming();
|
||||
}
|
||||
|
||||
net.on('connect_error', function() {
|
||||
self.emit('connectionError');
|
||||
});
|
||||
|
||||
log.debug('Wallet:' + self.id + ' Starting networking: ' + startOpts.copayerId);
|
||||
net.start(startOpts, function() {
|
||||
|
|
@ -1303,6 +1305,7 @@ Wallet.prototype.sendIndexes = function(recipients) {
|
|||
* @param {string[]} recipients - the pubkeys of the recipients
|
||||
*/
|
||||
Wallet.prototype.sendAddressBook = function(recipients) {
|
||||
if ( !Object.keys(this.addressBook).length ) return;
|
||||
log.debug('Wallet:' + this.id + ' ### SENDING addressBook TO:', recipients || 'All', this.addressBook);
|
||||
this.send(recipients, {
|
||||
type: 'addressbook',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue