Merge branch 'master' into feature/socket-io-support

Fix conflicts:
	js/app.js
	js/controllers/signin.js
This commit is contained in:
Gustavo Cortez 2014-04-17 11:58:11 -03:00
commit 2454d930fa
9 changed files with 63 additions and 68 deletions

View file

@ -22,7 +22,7 @@ function Wallet(opts) {
self[k] = opts[k];
});
console.log('creating '+opts.requiredCopayers+' of '+opts.totalCopayers+' wallet');
this.log('creating '+opts.requiredCopayers+' of '+opts.totalCopayers+' wallet');
this.id = opts.id || Wallet.getRandomId();
this.verbose = opts.verbose;
@ -33,7 +33,7 @@ function Wallet(opts) {
Wallet.parent=EventEmitter;
Wallet.prototype.log = function(){
// if (!this.verbose) return;
if (!this.verbose) return;
console.log(arguments);
};
@ -99,7 +99,7 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
if (this.id !== data.walletId)
throw new Error('wrong message received: Bad wallet ID');
console.log('[Wallet.js.98]' , data.type); //TODO
this.log('[Wallet.js.98]' , data.type); //TODO
switch(data.type) {
case 'publicKeyRing':
@ -120,6 +120,7 @@ Wallet.prototype._handleNetworkChange = function(newPeer) {
this.sendWalletId(newPeer);
this.sendPublicKeyRing(newPeer);
this.sendTxProposals(newPeer);
this.emit('refresh');
};
Wallet.prototype.netStart = function() {
@ -135,7 +136,7 @@ Wallet.prototype.netStart = function() {
};
Wallet.prototype.store = function() {
console.log('[Wallet.js.135:store:]'); //TODO
this.log('[Wallet.js.135:store:]'); //TODO
this.storage.set(this.id,'opts', {
id: this.id,
spendUnconfirmed: this.spendUnconfirmed,
@ -146,7 +147,7 @@ console.log('[Wallet.js.135:store:]'); //TODO
this.storage.set(this.id,'txProposals', this.txProposals.toObj());
this.storage.set(this.id,'privateKey', this.privateKey.toObj());
console.log('[Wallet.js.146] EMIT REFRESH'); //TODO
this.log('[Wallet.js.146] EMIT REFRESH'); //TODO
this.emit('refresh');
};
@ -229,13 +230,13 @@ Wallet.prototype.sign = function(ntxid) {
if (ret.signaturesAdded) {
txp.signedBy[this.privateKey.id] = Date.now();
console.log('[Wallet.js.230:ret:]',ret); //TODO
this.log('[Wallet.js.230:ret:]',ret); //TODO
if (ret.isFullySigned) {
console.log('[Wallet.js.231] BROADCASTING TX!!!'); //TODO
this.log('[Wallet.js.231] BROADCASTING TX!!!'); //TODO
var tx = txp.builder.build();
var txHex = tx.serialize().toString('hex');
this.blockchain.sendRawTransaction(txHex, function(txid) {
console.log('[Wallet.js.235:txid:]',txid); //TODO
this.log('[Wallet.js.235:txid:]',txid); //TODO
if (txid) {
this.store();
}

View file

@ -148,7 +148,10 @@ WalletFactory.prototype.openRemote = function(peedId) {
opts.storage = this.storage;
opts.network = this.network;
opts.blockchain = this.blockchain;
opts.spendUnconfirmed = opts.spendUnconfirmed || this.walletDefaults.spendUnconfirmed;
opts.spendUnconfirmed = typeof opts.spendUnconfirmed === undefined
?this.walletDefaults.spendUnconfirmed : opts.spendUnconfirmed;
opts.requiredCopayers = requiredCopayers;
opts.totalCopayers = totalCopayers;
var w = new Wallet(opts);

View file

@ -61,14 +61,9 @@ Network._arrayRemove = function(el, array) {
return array;
};
// DEBUG
Network.prototype._showConnectedPeers = function() {
// console.log("### CONNECTED PEERS", this.connectedPeers);
};
Network.prototype._onClose = function(peerId) {
this.connectedPeers = Network._arrayRemove(peerId, this.connectedPeers);
this._notify();
this._notifyNetworkChange();
};
Network.prototype._connectToPeers = function(peerIds) {
@ -97,7 +92,7 @@ Network.prototype._onData = function(data, isInbound) {
switch(obj.data.type) {
case 'peerList':
this._connectToPeers(obj.data.peers);
this._notify();
this._notifyNetworkChange();
break;
case 'disconnect':
this._onClose(obj.sender);
@ -144,7 +139,7 @@ Network.prototype._setupConnectionHandlers = function(dataConn, isInbound) {
dataConn.peer, isInbound);
self._addPeer(dataConn.peer, isInbound);
self._notify( isInbound ? dataConn.peer : null);
self._notifyNetworkChange( isInbound ? dataConn.peer : null);
this.emit('open');
}
});
@ -166,8 +161,8 @@ Network.prototype._setupConnectionHandlers = function(dataConn, isInbound) {
});
};
Network.prototype._notify = function(newPeer) {
this._showConnectedPeers();
Network.prototype._notifyNetworkChange = function(newPeer) {
console.log('[WebRTC.js.164:_notifyNetworkChange:]', newPeer); //TODO
this.emit('networkChange', newPeer);
};
@ -178,7 +173,7 @@ Network.prototype._setupPeerHandlers = function(openCallback) {
p.on('open', function(peerId) {
self.peerId = peerId;
self.connectedPeers = [peerId];
self._notify();
self._notifyNetworkChange();
return openCallback(peerId);
});
@ -263,7 +258,6 @@ Network.prototype.connectTo = function(peerId) {
console.log('### STARTING TO CONNECT TO:' + peerId );
var dataConn = this.peer.connect(peerId, {
// label: 'wallet',
serialization: 'none',
reliable: true,
metadata: { message: 'hi copayer!' }