Merge pull request #569 from matiu/bug/safeUnspent

Bug/safe unspent
This commit is contained in:
Manuel Aráoz 2014-06-05 15:27:04 -03:00
commit a3e0711dcd
7 changed files with 21 additions and 13 deletions

2
.ctags Normal file
View File

@ -0,0 +1,2 @@
--exclude=js/copayBundle.js
--exclude=lib/bitcore/browser/bundle.js

View File

@ -23,12 +23,12 @@ var defaultConfig = {
// Use this to connect to bitpay's PeerJS server // Use this to connect to bitpay's PeerJS server
key: 'satoshirocks', key: 'satoshirocks',
host: '162.242.219.26', host: '162.242.219.26',
port: 80, port: 10000,
path: '/', path: '/',
// other PeerJS config // other PeerJS config
maxPeers: 15, maxPeers: 15,
debug: 3, debug: 1,
// Network encryption config // Network encryption config
sjclParams: { sjclParams: {

View File

@ -82,7 +82,7 @@
</div> </div>
</div> </div>
<div class="row" ng-if='$root.insightError>1'> <div class="row" ng-if='$root.insightError>0'>
<div class="small-8 large-centered columns"> <div class="small-8 large-centered columns">
<div data-alert class="alert-box radius error"> <div data-alert class="alert-box radius error">
Having troubles connecting to Insight server. Check Having troubles connecting to Insight server. Check

View File

@ -35,14 +35,15 @@ angular.module('copayApp.controllers').controller('HeaderController',
// Initialize alert notification (not show when init wallet) // Initialize alert notification (not show when init wallet)
$rootScope.txAlertCount = 0; $rootScope.txAlertCount = 0;
$rootScope.insightError = -1; $rootScope.insightError = 0;
$rootScope.$watch('insightError', function(status) { $rootScope.$watch('insightError', function(status) {
if (status === 0) { if (status === -1) {
$rootScope.$flashMessage = { $rootScope.$flashMessage = {
type: 'success', type: 'success',
message: 'Networking Restored :)', message: 'Networking Restored :)',
}; };
$rootScope.insightError = 0;
} }
}); });

View File

@ -231,15 +231,17 @@ TxProposals.prototype.getTxProposal = function(ntxid, copayers) {
return i; return i;
}; };
//returns the unspent txid-vout used in PENDING Txs
TxProposals.prototype.getUsedUnspent = function(maxRejectCount) { TxProposals.prototype.getUsedUnspent = function(maxRejectCount) {
var ret = []; var ret = {};
for(var i in this.txps) { for(var i in this.txps) {
var u = this.txps[i].builder.getSelectedUnspent(); var u = this.txps[i].builder.getSelectedUnspent();
if (this.getTxProposal(i).rejectCount>maxRejectCount) var p = this.getTxProposal(i);
if (p.rejectCount>maxRejectCount || p.sentTxid)
continue; continue;
for (var j in u){ for (var j in u) {
ret.push(u[j].txid); ret[u[j].txid + ',' + u[j].vout]=1;
} }
} }
return ret; return ret;

View File

@ -596,8 +596,9 @@ Wallet.prototype.getUnspent = function(cb) {
var uu = self.txProposals.getUsedUnspent(maxRejectCount); var uu = self.txProposals.getUsedUnspent(maxRejectCount);
for (var i in unspentList) { for (var i in unspentList) {
if (uu.indexOf(unspentList[i].txid) === -1) var u=unspentList[i];
safeUnspendList.push(unspentList[i]); if (! uu[u.txid +','+u.vout])
safeUnspendList.push(u);
} }
return cb(null, safeUnspendList, unspentList); return cb(null, safeUnspendList, unspentList);

View File

@ -174,7 +174,6 @@ angular.module('copayApp.services')
}; };
root._setCommError = function(e) { root._setCommError = function(e) {
// first error ever?
if ($rootScope.insightError<0) if ($rootScope.insightError<0)
$rootScope.insightError=0; $rootScope.insightError=0;
$rootScope.insightError++; $rootScope.insightError++;
@ -182,7 +181,10 @@ angular.module('copayApp.services')
root._clearCommError = function(e) { root._clearCommError = function(e) {
$rootScope.insightError=0; if ($rootScope.insightError>0)
$rootScope.insightError=-1;
else
$rootScope.insightError=0;
}; };
root.setSocketHandlers = function() { root.setSocketHandlers = function() {