mirror of https://github.com/BTCPrivate/copay.git
fix style issues
This commit is contained in:
parent
d98bc6f2e9
commit
aa021125a0
15
css/main.css
15
css/main.css
|
@ -278,8 +278,17 @@ button.secondary:hover { background-color: #FFDF00 !important;}
|
|||
}
|
||||
|
||||
.video-small {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border: 1px solid black;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
margin: 20px;
|
||||
display: inline;
|
||||
float:left;
|
||||
}
|
||||
.online {
|
||||
border: 10px solid green;
|
||||
}
|
||||
.offline {
|
||||
border: 10px solid gray;
|
||||
}
|
||||
|
||||
|
||||
|
|
29
index.html
29
index.html
|
@ -205,20 +205,29 @@
|
|||
<script type="text/ng-template" id="peer.html">
|
||||
<div class="row">
|
||||
<div class="large-12 columns p70l">
|
||||
<h3 class="panel-title">Online Copayers: {{$root.wallet.network.connectedCopayers().length}}</h3>
|
||||
|
||||
<p class="text-info" ng-show="$root.wallet.publicKeyRing.requiredCopayers >$root.wallet.network.connectedCopayers()"> <i class="fi-alert size-28"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns p70l">
|
||||
{{$root.wallet.publicKeyRing.requiredCopayers}} copayers needed for signing transactions
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li class="panel" ng-repeat="copayer in $root.wallet.network.connectedPeers">
|
||||
<video class="video-small" autoplay ng-show="$root.videoSrc[copayer]"
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-4 columns"
|
||||
ng-repeat="copayer in $root.wallet.getRegisteredPeerIds()">
|
||||
<video
|
||||
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(copayer) != -1) ? 'online' : 'offline'"
|
||||
class="video-small"
|
||||
autoplay ng-show="$root.videoSrc[copayer]"
|
||||
ng-src="{{$root.getVideoURL(copayer)}}"
|
||||
id="{{copayer + '-video'}}" muted="true"></video>
|
||||
id="{{copayer + '-video'}}" muted="true"
|
||||
title="{{copayer + (copayer == $root.wallet.network.peerId?' (You)':'')}}" ></video>
|
||||
<img ng-show="!$root.videoSrc[copayer]"
|
||||
src="/img/satoshi.gif" title="{{copayer + (copayer == $root.wallet.network.peerId?' (You)':'')}}" />
|
||||
</li>
|
||||
</ul>
|
||||
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(copayer) != -1) ? 'online' : 'offline'"
|
||||
class="video-small"
|
||||
src="/img/satoshi.gif"
|
||||
title="{{copayer + (copayer == $root.wallet.network.peerId?' (You)':'')}}" />
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
|
|
@ -7,7 +7,7 @@ var coinUtil = bitcore.util;
|
|||
var buffertools = bitcore.buffertools;
|
||||
var Builder = bitcore.TransactionBuilder;
|
||||
var http = require('http');
|
||||
var EventEmitter= imports.EventEmitter || require('events').EventEmitter;
|
||||
var EventEmitter = imports.EventEmitter || require('events').EventEmitter;
|
||||
var copay = copay || require('../../../copay');
|
||||
|
||||
function Wallet(opts) {
|
||||
|
@ -17,12 +17,12 @@ function Wallet(opts) {
|
|||
['storage', 'network', 'blockchain',
|
||||
'requiredCopayers', 'totalCopayers', 'spendUnconfirmed',
|
||||
'publicKeyRing', 'txProposals', 'privateKey'
|
||||
].forEach( function(k){
|
||||
].forEach(function(k) {
|
||||
if (typeof opts[k] === 'undefined') throw new Error('missing key:' + k);
|
||||
self[k] = opts[k];
|
||||
});
|
||||
|
||||
this.log('creating '+opts.requiredCopayers+' of '+opts.totalCopayers+' wallet');
|
||||
this.log('creating ' + opts.requiredCopayers + ' of ' + opts.totalCopayers + ' wallet');
|
||||
|
||||
this.id = opts.id || Wallet.getRandomId();
|
||||
this.name = opts.name;
|
||||
|
@ -32,8 +32,8 @@ function Wallet(opts) {
|
|||
|
||||
}
|
||||
|
||||
Wallet.parent=EventEmitter;
|
||||
Wallet.prototype.log = function(){
|
||||
Wallet.parent = EventEmitter;
|
||||
Wallet.prototype.log = function() {
|
||||
if (!this.verbose) return;
|
||||
if (console)
|
||||
console.log.apply(console, arguments);
|
||||
|
@ -45,7 +45,7 @@ Wallet.getRandomId = function() {
|
|||
};
|
||||
|
||||
Wallet.prototype._handlePublicKeyRing = function(senderId, data, isInbound) {
|
||||
this.log('RECV PUBLICKEYRING:',data);
|
||||
this.log('RECV PUBLICKEYRING:', data);
|
||||
|
||||
var shouldSend = false;
|
||||
var recipients, pkr = this.publicKeyRing;
|
||||
|
@ -72,7 +72,7 @@ Wallet.prototype._handlePublicKeyRing = function(senderId, data, isInbound) {
|
|||
|
||||
|
||||
Wallet.prototype._handleTxProposals = function(senderId, data, isInbound) {
|
||||
this.log('RECV TXPROPOSAL:',data); //TODO
|
||||
this.log('RECV TXPROPOSAL:', data); //TODO
|
||||
|
||||
var shouldSend = false;
|
||||
var recipients;
|
||||
|
@ -80,7 +80,7 @@ Wallet.prototype._handleTxProposals = function(senderId, data, isInbound) {
|
|||
var mergeInfo = this.txProposals.merge(inTxp, true);
|
||||
var addSeen = this.addSeenToTxProposals();
|
||||
if (mergeInfo.hasChanged || addSeen) {
|
||||
this.log('### BROADCASTING txProposals. ' );
|
||||
this.log('### BROADCASTING txProposals. ');
|
||||
recipients = null;
|
||||
shouldSend = true;
|
||||
}
|
||||
|
@ -100,12 +100,12 @@ Wallet.prototype._handleTxProposals = function(senderId, data, isInbound) {
|
|||
Wallet.prototype._handleData = function(senderId, data, isInbound) {
|
||||
// TODO check message signature
|
||||
if (this.id !== data.walletId) {
|
||||
this.emit('badMessage',senderId);
|
||||
this.emit('badMessage', senderId);
|
||||
this.log('badMessage FROM:', senderId); //TODO
|
||||
return;
|
||||
}
|
||||
this.log('[Wallet.js.98]' , data.type); //TODO
|
||||
switch(data.type) {
|
||||
this.log('[Wallet.js.98]', data.type); //TODO
|
||||
switch (data.type) {
|
||||
// This handler is repeaded on WalletFactory (#join). TODO
|
||||
case 'walletId':
|
||||
this.sendWalletReady(senderId);
|
||||
|
@ -127,13 +127,13 @@ Wallet.prototype._handleNetworkChange = function(newCopayerId) {
|
|||
if (newCopayerId) {
|
||||
this.log('#### Setting new PEER:', newCopayerId);
|
||||
this.sendWalletId(newCopayerId);
|
||||
this.emit('peer', newCopayerId);
|
||||
this.emit('peer', this.network.peerFromCopayer(newCopayerId));
|
||||
}
|
||||
this.emit('refresh');
|
||||
};
|
||||
|
||||
|
||||
Wallet.prototype._optsToObj = function () {
|
||||
Wallet.prototype._optsToObj = function() {
|
||||
var obj = {
|
||||
id: this.id,
|
||||
spendUnconfirmed: this.spendUnconfirmed,
|
||||
|
@ -159,8 +159,8 @@ Wallet.prototype.netStart = function() {
|
|||
var self = this;
|
||||
var net = this.network;
|
||||
net.removeAllListeners();
|
||||
net.on('networkChange', self._handleNetworkChange.bind(self) );
|
||||
net.on('data', self._handleData.bind(self) );
|
||||
net.on('networkChange', self._handleNetworkChange.bind(self));
|
||||
net.on('data', self._handleData.bind(self));
|
||||
net.on('open', function() {}); // TODO
|
||||
net.on('openError', function() {
|
||||
self.log('[Wallet.js.132:openError:] GOT openError'); //TODO
|
||||
|
@ -176,15 +176,15 @@ Wallet.prototype.netStart = function() {
|
|||
signingKeyHex: self.privateKey.getSigningKey(),
|
||||
};
|
||||
|
||||
net.start(function() {
|
||||
net.start(startOpts, function() {
|
||||
self.emit('created', net.getPeer());
|
||||
var registered = self.getRegisteredPeerIds();
|
||||
for (var i=0; i<registered.length; i++) {
|
||||
var otherPeerId = registered[i];
|
||||
if (otherPeerId !== myPeerId) {
|
||||
net.connectTo(otherPeerId);
|
||||
for (var i = 0; i < self.publicKeyRing.registeredCopayers(); i++) {
|
||||
var otherId = self.getCopayerId(i);
|
||||
if (otherId !== myId) {
|
||||
net.connectTo(otherId);
|
||||
}
|
||||
if (self.firstCopayerId){
|
||||
if (self.firstCopayerId) {
|
||||
self.sendWalletReady(self.firstCopayerId);
|
||||
self.firstCopayerId = null;
|
||||
}
|
||||
|
@ -199,8 +199,10 @@ Wallet.prototype.getOnlinePeerIDs = function() {
|
|||
|
||||
Wallet.prototype.getRegisteredPeerIds = function() {
|
||||
var ret = [];
|
||||
for (var i=0; i<this.publicKeyRing.registeredCopayers(); i++) {
|
||||
ret.push(this.getPeerId(i));
|
||||
for (var i = 0; i < this.publicKeyRing.registeredCopayers(); i++) {
|
||||
var cid = this.getCopayerId(i)
|
||||
var pid = this.network.peerFromCopayer(cid);
|
||||
ret.push(pid);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
@ -212,8 +214,7 @@ Wallet.prototype.store = function(isSync) {
|
|||
|
||||
if (isSync) {
|
||||
this.log('Wallet stored.'); //TODO
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.log('Wallet stored. REFRESH Emitted'); //TODO
|
||||
this.emit('refresh');
|
||||
}
|
||||
|
@ -244,9 +245,9 @@ Wallet.fromObj = function(wallet) {
|
|||
};
|
||||
|
||||
Wallet.prototype.sendTxProposals = function(recipients) {
|
||||
this.log('### SENDING txProposals TO:', recipients||'All', this.txProposals);
|
||||
this.log('### SENDING txProposals TO:', recipients || 'All', this.txProposals);
|
||||
|
||||
this.network.send( recipients, {
|
||||
this.network.send(recipients, {
|
||||
type: 'txProposals',
|
||||
txProposals: this.txProposals.toObj(),
|
||||
walletId: this.id,
|
||||
|
@ -265,7 +266,7 @@ Wallet.prototype.sendWalletReady = function(recipients) {
|
|||
};
|
||||
|
||||
Wallet.prototype.sendWalletId = function(recipients) {
|
||||
this.log('### SENDING walletId TO:', recipients||'All', this.walletId);
|
||||
this.log('### SENDING walletId TO:', recipients || 'All', this.walletId);
|
||||
|
||||
this.network.send(recipients, {
|
||||
type: 'walletId',
|
||||
|
@ -276,7 +277,7 @@ Wallet.prototype.sendWalletId = function(recipients) {
|
|||
|
||||
|
||||
Wallet.prototype.sendPublicKeyRing = function(recipients) {
|
||||
this.log('### SENDING publicKeyRing TO:', recipients||'All', this.publicKeyRing.toObj());
|
||||
this.log('### SENDING publicKeyRing TO:', recipients || 'All', this.publicKeyRing.toObj());
|
||||
|
||||
this.network.send(recipients, {
|
||||
type: 'publicKeyRing',
|
||||
|
@ -297,12 +298,12 @@ Wallet.prototype.generateAddress = function(isChange) {
|
|||
|
||||
Wallet.prototype.getTxProposals = function() {
|
||||
var ret = [];
|
||||
for(var k in this.txProposals.txps) {
|
||||
for (var k in this.txProposals.txps) {
|
||||
var i = this.txProposals.getTxProposal(k);
|
||||
i.signedByUs = i.signedBy[this.getMyCopayerId()]?true:false;
|
||||
i.rejectedByUs = i.rejectedBy[this.getMyCopayerId()]?true:false;
|
||||
if (this.totalCopayers-i.rejectCount < this.requiredCopayers)
|
||||
i.finallyRejected=true;
|
||||
i.signedByUs = i.signedBy[this.getMyCopayerId()] ? true : false;
|
||||
i.rejectedByUs = i.rejectedBy[this.getMyCopayerId()] ? true : false;
|
||||
if (this.totalCopayers - i.rejectCount < this.requiredCopayers)
|
||||
i.finallyRejected = true;
|
||||
|
||||
ret.push(i);
|
||||
}
|
||||
|
@ -311,7 +312,7 @@ Wallet.prototype.getTxProposals = function() {
|
|||
|
||||
|
||||
Wallet.prototype.reject = function(ntxid) {
|
||||
var myId=this.getMyCopayerId();
|
||||
var myId = this.getMyCopayerId();
|
||||
var txp = this.txProposals.txps[ntxid];
|
||||
if (!txp || txp.rejectedBy[myId] || txp.signedBy[myId]) return;
|
||||
|
||||
|
@ -323,7 +324,7 @@ Wallet.prototype.reject = function(ntxid) {
|
|||
|
||||
Wallet.prototype.sign = function(ntxid) {
|
||||
var self = this;
|
||||
var myId=this.getMyCopayerId();
|
||||
var myId = this.getMyCopayerId();
|
||||
var txp = self.txProposals.txps[ntxid];
|
||||
if (!txp || txp.rejectedBy[myId] || txp.signedBy[myId]) return;
|
||||
|
||||
|
@ -353,12 +354,12 @@ Wallet.prototype.sendTx = function(ntxid, cb) {
|
|||
this.log('[Wallet.js.231] BROADCASTING TX!!!'); //TODO
|
||||
|
||||
var txHex = tx.serialize().toString('hex');
|
||||
this.log('[Wallet.js.261:txHex:]',txHex); //TODO
|
||||
this.log('[Wallet.js.261:txHex:]', txHex); //TODO
|
||||
|
||||
var self = this;
|
||||
|
||||
this.blockchain.sendRawTransaction(txHex, function(txid) {
|
||||
self.log('BITCOND txid:',txid); //TODO
|
||||
self.log('BITCOND txid:', txid); //TODO
|
||||
if (txid) {
|
||||
self.txProposals.setSent(ntxid, txid);
|
||||
}
|
||||
|
@ -369,10 +370,10 @@ Wallet.prototype.sendTx = function(ntxid, cb) {
|
|||
};
|
||||
|
||||
Wallet.prototype.addSeenToTxProposals = function() {
|
||||
var ret=false;
|
||||
var myId=this.getMyCopayerId();
|
||||
var ret = false;
|
||||
var myId = this.getMyCopayerId();
|
||||
|
||||
for(var k in this.txProposals.txps) {
|
||||
for (var k in this.txProposals.txps) {
|
||||
var txp = this.txProposals.txps[k];
|
||||
if (!txp.seenBy[myId]) {
|
||||
|
||||
|
@ -400,7 +401,7 @@ Wallet.prototype.addressIsOwn = function(addrStr) {
|
|||
var l = addrList.length;
|
||||
var ret = false;
|
||||
|
||||
for(var i=0; i<l; i++) {
|
||||
for (var i = 0; i < l; i++) {
|
||||
if (addrList[i] === addrStr) {
|
||||
ret = true;
|
||||
break;
|
||||
|
@ -416,23 +417,23 @@ Wallet.prototype.getBalance = function(safe, cb) {
|
|||
var COIN = bitcore.util.COIN;
|
||||
var addresses = this.getAddressesStr(true);
|
||||
|
||||
if (!addresses.length) return cb(0,[]);
|
||||
if (!addresses.length) return cb(0, []);
|
||||
|
||||
// Prefill balanceByAddr with main address
|
||||
addresses.forEach(function(a){
|
||||
balanceByAddr[a]=0;
|
||||
isMain[a]=1;
|
||||
addresses.forEach(function(a) {
|
||||
balanceByAddr[a] = 0;
|
||||
isMain[a] = 1;
|
||||
});
|
||||
var f = safe ? this.getSafeUnspent.bind(this):this.getUnspent.bind(this);
|
||||
var f = safe ? this.getSafeUnspent.bind(this) : this.getUnspent.bind(this);
|
||||
f(function(utxos) {
|
||||
for(var i=0;i<utxos.length; i++) {
|
||||
var u= utxos[i];
|
||||
for (var i = 0; i < utxos.length; i++) {
|
||||
var u = utxos[i];
|
||||
var amt = u.amount * COIN;
|
||||
balance = balance + amt;
|
||||
balanceByAddr[u.address] = (balanceByAddr[u.address]||0) + amt;
|
||||
balanceByAddr[u.address] = (balanceByAddr[u.address] || 0) + amt;
|
||||
}
|
||||
for(var a in balanceByAddr){
|
||||
balanceByAddr[a] = balanceByAddr[a]/COIN;
|
||||
for (var a in balanceByAddr) {
|
||||
balanceByAddr[a] = balanceByAddr[a] / COIN;
|
||||
}
|
||||
return cb(balance / COIN, balanceByAddr, isMain);
|
||||
});
|
||||
|
@ -448,11 +449,11 @@ Wallet.prototype.getSafeUnspent = function(cb) {
|
|||
var self = this;
|
||||
this.blockchain.getUnspent(this.getAddressesStr(), function(unspentList) {
|
||||
|
||||
var ret=[];
|
||||
var ret = [];
|
||||
var maxRejectCount = self.totalCopayers - self.requiredCopayers;
|
||||
var uu = self.txProposals.getUsedUnspent(maxRejectCount);
|
||||
|
||||
for(var i in unspentList){
|
||||
for (var i in unspentList) {
|
||||
if (uu.indexOf(unspentList[i].txid) === -1)
|
||||
ret.push(unspentList[i]);
|
||||
}
|
||||
|
@ -491,23 +492,27 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, utxos, opts) {
|
|||
|
||||
var amountSat = bitcore.bignum(amountSatStr);
|
||||
|
||||
if (! pkr.isComplete() ) {
|
||||
if (!pkr.isComplete()) {
|
||||
throw new Error('publicKeyRing is not complete');
|
||||
}
|
||||
|
||||
if (!opts.remainderOut) {
|
||||
opts.remainderOut ={ address: this.generateAddress(true).toString() };
|
||||
opts.remainderOut = {
|
||||
address: this.generateAddress(true).toString()
|
||||
};
|
||||
}
|
||||
|
||||
var b = new Builder(opts)
|
||||
.setUnspent(utxos)
|
||||
.setHashToScriptMap(pkr.getRedeemScriptMap())
|
||||
.setOutputs([{address: toAddress, amountSat: amountSat}])
|
||||
;
|
||||
.setOutputs([{
|
||||
address: toAddress,
|
||||
amountSat: amountSat
|
||||
}]);
|
||||
|
||||
var signRet;
|
||||
if (priv) {
|
||||
b.sign( priv.getAll(pkr.addressIndex, pkr.changeAddressIndex) );
|
||||
b.sign(priv.getAll(pkr.addressIndex, pkr.changeAddressIndex));
|
||||
}
|
||||
var myId = this.getMyCopayerId();
|
||||
var now = Date.now();
|
||||
|
@ -536,7 +541,7 @@ Wallet.prototype.connectTo = function(peerId) {
|
|||
|
||||
Wallet.prototype.disconnect = function() {
|
||||
|
||||
console.log('[Wallet.js.524] DISC'); //TODO
|
||||
console.log('[Wallet.js.524] DISC'); //TODO
|
||||
this.network.disconnect();
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ angular.module('copay.controllerUtils')
|
|||
root.setupUxHandlers = function(w) {
|
||||
var handlePeerVideo = function(err, peerID, url) {
|
||||
if (err) {
|
||||
root.onErrorDigest(err);
|
||||
return;
|
||||
}
|
||||
$rootScope.videoSrc[peerID] = encodeURI(url);
|
||||
|
|
|
@ -11,6 +11,7 @@ var Video = function() {
|
|||
Video.prototype.setOwnPeer = function(peer, wallet, cb) {
|
||||
var self = this;
|
||||
|
||||
|
||||
navigator.getUserMedia({
|
||||
audio: true,
|
||||
video: true
|
||||
|
|
Loading…
Reference in New Issue