fix safeUnspents report

This commit is contained in:
Matias Alejo Garcia 2014-06-05 14:55:19 -03:00
commit c64bf07ae3
6 changed files with 19 additions and 13 deletions

View file

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

View file

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