mirror of https://github.com/BTCPrivate/copay.git
hashing working
This commit is contained in:
parent
c1881d5fbb
commit
08fa60d41c
23
index.html
23
index.html
|
@ -193,28 +193,17 @@
|
||||||
|
|
||||||
<script type="text/ng-template" id="peer.html">
|
<script type="text/ng-template" id="peer.html">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-6 columns p70r line-dashed-v">
|
<div class="large-12 columns p70l">
|
||||||
<h3>I am </h3>
|
<h3 class="panel-title">Online Copayers: {{$root.wallet.network.connectedCopayers().length}}</h3>
|
||||||
<div class="row">
|
|
||||||
<div class="large-10 columns p0r">
|
|
||||||
<p class="panel share-wallet">{{$root.wallet.network.peerId}}</p>
|
|
||||||
</div>
|
|
||||||
<div class="large-2 columns">
|
|
||||||
<p class="panel panel-sign"> <i class="fi-page-copy size-22"></i> </p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="large-6 columns p70l">
|
|
||||||
<h3 class="panel-title">Online Copayers: {{$root.wallet.network.connectedPeers.length}}</h3>
|
|
||||||
|
|
||||||
<p class="text-info" ng-show="$root.wallet.publicKeyRing.requiredCopayers > $root.wallet.network.connectedPeers.length"> <i class="fi-alert size-28"></i>
|
<p class="text-info" ng-show="$root.wallet.publicKeyRing.requiredCopayers >$root.wallet.network.connectedCopayers()"> <i class="fi-alert size-28"></i>
|
||||||
{{$root.wallet.publicKeyRing.requiredCopayers}} copayers needed for signing transactions
|
{{$root.wallet.publicKeyRing.requiredCopayers}} copayers needed for signing transactions
|
||||||
|
|
||||||
|
|
||||||
<ul class="no-bullet">
|
<ul class="no-bullet">
|
||||||
<li class="panel" ng-repeat="copayer in $root.wallet.network.connectedPeers">
|
<li class="panel" ng-repeat="copayer in $root.wallet.network.connectedCopayers()">
|
||||||
<span ng-if="copayer == $root.wallet.network.peerId"> You ({{copayer}})</span>
|
<span ng-if="copayer === $root.wallet.getMyCopayerId()"> You ({{copayer}})</span>
|
||||||
<span ng-if="copayer !== $root.wallet.network.peerId">{{copayer}}</span>
|
<span ng-if="copayer !== $root.wallet.getMyCopayerId()">{{copayer}}</span>
|
||||||
<span>
|
<span>
|
||||||
<i class="fi-check size-16 panel-sign right p5h br100"></i>
|
<i class="fi-check size-16 panel-sign right p5h br100"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -59,7 +59,7 @@ angular.module('copay.transactions').controller('TransactionsController',
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var p = w.getTxProposal(ntxid);
|
var p = w.txProposals.getTxProposal(ntxid);
|
||||||
if (p.txp.builder.isFullySigned()) {
|
if (p.txp.builder.isFullySigned()) {
|
||||||
$scope.send(ntxid);
|
$scope.send(ntxid);
|
||||||
_updateTxs();
|
_updateTxs();
|
||||||
|
|
|
@ -123,7 +123,7 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype._handleNetworkChange = function(newCopayerId) {
|
Wallet.prototype._handleNetworkChange = function(newCopayerId) {
|
||||||
if (newPeerId) {
|
if (newCopayerId) {
|
||||||
this.log('#### Setting new PEER:', newCopayerId);
|
this.log('#### Setting new PEER:', newCopayerId);
|
||||||
this.sendWalletId(newCopayerId);
|
this.sendWalletId(newCopayerId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,28 +91,15 @@ console.log('[WebRTC.js.72:_onClose:]');
|
||||||
|
|
||||||
Network.prototype._connectToCopayers = function(copayerIds) {
|
Network.prototype._connectToCopayers = function(copayerIds) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var ret = false;
|
|
||||||
|
|
||||||
var peerIds = [];
|
console.log('[WebRTC.js.96] _connectToCopayers', copayerIds, this.connectedCopayers() ); //TODO
|
||||||
for(var i in copayerIds) {
|
|
||||||
if (!copayerIds[i]) continue;
|
|
||||||
|
|
||||||
var peerId = this.peerFromCopayer(copayerIds[i]);
|
var arrayDiff= Network._arrayDiff(copayerIds, this.connectedCopayers());
|
||||||
peerIds.push(peerId);
|
console.log('[WebRTC.js.99:arrayDiff:]',arrayDiff); //TODO
|
||||||
|
arrayDiff.forEach(function(copayerId) {
|
||||||
this.copayerForPeer[peerId] = copayerIds[i];
|
console.log('### CONNECTING TO:', copayerId);
|
||||||
}
|
self.connectTo(copayerId);
|
||||||
|
|
||||||
console.log('[WebRTC.js.102] copayerForPeer:', this.copayerForPeer); //TODO
|
|
||||||
|
|
||||||
var arrayDiff1= Network._arrayDiff(peerIds, this.connectedPeers);
|
|
||||||
var arrayDiff = Network._arrayDiff(arrayDiff1, [this.peerId]);
|
|
||||||
arrayDiff.forEach(function(peerId) {
|
|
||||||
console.log('### CONNECTING TO:', peerId);
|
|
||||||
self.connectTo(peerId);
|
|
||||||
ret = true;
|
|
||||||
});
|
});
|
||||||
return ret;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype._sendCopayerId = function(copayerId) {
|
Network.prototype._sendCopayerId = function(copayerId) {
|
||||||
|
@ -132,7 +119,9 @@ Network.prototype._sendCopayers = function(copayerIds) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype._addCopayer = function(copayerId, isInbound) {
|
Network.prototype._addCopayer = function(copayerId, isInbound) {
|
||||||
var hasChanged = Network._arrayPushOnce(this.peerFromCopayer(copayerId), this.connectedPeers);
|
var peerId = this.peerFromCopayer(copayerId);
|
||||||
|
this._addCopayerMap(peerId,copayerId);
|
||||||
|
var hasChanged = Network._arrayPushOnce(peerId, this.connectedPeers);
|
||||||
if (isInbound && hasChanged) {
|
if (isInbound && hasChanged) {
|
||||||
this._sendCopayers(); //broadcast peer list
|
this._sendCopayers(); //broadcast peer list
|
||||||
}
|
}
|
||||||
|
@ -157,7 +146,6 @@ Network.prototype._onData = function(data, isInbound, peerId) {
|
||||||
if(obj.data.type === 'copayerId') {
|
if(obj.data.type === 'copayerId') {
|
||||||
if (this.peerFromCopayer(obj.data.copayerId) === peerId) {
|
if (this.peerFromCopayer(obj.data.copayerId) === peerId) {
|
||||||
console.log('#### Peer sent the right copayerId. Setting it up.'); //TODO
|
console.log('#### Peer sent the right copayerId. Setting it up.'); //TODO
|
||||||
this.copayerForPeer[peerId]=obj.data.copayerId;
|
|
||||||
this._addCopayer(obj.data.copayerId, isInbound);
|
this._addCopayer(obj.data.copayerId, isInbound);
|
||||||
this._notifyNetworkChange( isInbound ? obj.data.copayerId : null);
|
this._notifyNetworkChange( isInbound ? obj.data.copayerId : null);
|
||||||
this.emit('open');
|
this.emit('open');
|
||||||
|
@ -175,6 +163,7 @@ Network.prototype._onData = function(data, isInbound, peerId) {
|
||||||
|
|
||||||
switch(obj.data.type) {
|
switch(obj.data.type) {
|
||||||
case 'copayers':
|
case 'copayers':
|
||||||
|
this._addCopayer(this.copayerForPeer[peerId], false);
|
||||||
this._connectToCopayers(obj.data.copayers);
|
this._connectToCopayers(obj.data.copayers);
|
||||||
this._notifyNetworkChange();
|
this._notifyNetworkChange();
|
||||||
break;
|
break;
|
||||||
|
@ -199,7 +188,9 @@ Network.prototype._setupConnectionHandlers = function(dataConn, isInbound) {
|
||||||
var self=this;
|
var self=this;
|
||||||
|
|
||||||
dataConn.on('open', function() {
|
dataConn.on('open', function() {
|
||||||
if (!Network._inArray(dataConn.peer, self.connectedPeers)) {
|
if (!Network._inArray(dataConn.peer, self.connectedPeers)
|
||||||
|
&& ! self.connections[dataConn.peer]) {
|
||||||
|
|
||||||
self.connections[dataConn.peer] = dataConn;
|
self.connections[dataConn.peer] = dataConn;
|
||||||
|
|
||||||
console.log('### DATA CONNECTION READY: ADDING PEER: %s (inbound: %s)',
|
console.log('### DATA CONNECTION READY: ADDING PEER: %s (inbound: %s)',
|
||||||
|
@ -242,6 +233,8 @@ Network.prototype._setupPeerHandlers = function(openCallback) {
|
||||||
|
|
||||||
p.on('open', function() {
|
p.on('open', function() {
|
||||||
self.connectedPeers = [self.peerId];
|
self.connectedPeers = [self.peerId];
|
||||||
|
self.copayerForPeer[self.peerId]= self.copayerId;
|
||||||
|
|
||||||
return openCallback();
|
return openCallback();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -267,14 +260,21 @@ Network.prototype._setupPeerHandlers = function(openCallback) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Network.prototype._addCopayerMap = function(peerId, copayerId) {
|
||||||
|
if (!this.copayerForPeer[peerId]) {
|
||||||
|
console.log('ADDING COPAYER MAPPING: %s => %s', peerId, copayerId); //TODO
|
||||||
|
this.copayerForPeer[peerId]=copayerId;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Network.prototype.setCopayerId = function(copayerId) {
|
Network.prototype.setCopayerId = function(copayerId) {
|
||||||
if (this.started) {
|
if (this.started) {
|
||||||
throw new Error ('network already started: can not change peerId')
|
throw new Error ('network already started: can not change peerId')
|
||||||
}
|
}
|
||||||
this.copayerId = copayerId;
|
this.copayerId = copayerId;
|
||||||
this.peerId = this.peerFromCopayer(this.copayerId);
|
this.peerId = this.peerFromCopayer(this.copayerId);
|
||||||
|
this._addCopayerMap(this.peerId,copayerId);
|
||||||
console.log('[WebRTC.js.275] setCopayerId', copayerId, this.peerId ); //TODO
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.peerFromCopayer = function(hex) {
|
Network.prototype.peerFromCopayer = function(hex) {
|
||||||
|
@ -342,7 +342,8 @@ Network.prototype.send = function(copayerIds, data, cb) {
|
||||||
Network.prototype.connectTo = function(copayerId) {
|
Network.prototype.connectTo = function(copayerId) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var peerId = this.peerFromCopayer(copayerId);
|
var peerId = this.peerFromCopayer(copayerId);
|
||||||
this.copayerForPeer[peerId] = copayerId;
|
this._addCopayerMap(peerId,copayerId);
|
||||||
|
|
||||||
console.log('### STARTING CONNECTION TO:', peerId, copayerId);
|
console.log('### STARTING CONNECTION TO:', peerId, copayerId);
|
||||||
var dataConn = this.peer.connect(peerId, {
|
var dataConn = this.peer.connect(peerId, {
|
||||||
serialization: 'none',
|
serialization: 'none',
|
||||||
|
|
Loading…
Reference in New Issue