Fixed actions on txProposal event
This commit is contained in:
parent
2c53bc073e
commit
645734f139
2 changed files with 19 additions and 15 deletions
|
|
@ -378,7 +378,7 @@ Wallet.prototype._onTxProposal = function(senderId, data) {
|
||||||
if (tx.isComplete()) {
|
if (tx.isComplete()) {
|
||||||
this._checkSentTx(m.ntxid, function(ret) {
|
this._checkSentTx(m.ntxid, function(ret) {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
m.txp.setSent(m.mtxid);
|
m.txp.setSent(m.ntxid);
|
||||||
self.emit('txProposalsUpdated');
|
self.emit('txProposalsUpdated');
|
||||||
self.store();
|
self.store();
|
||||||
}
|
}
|
||||||
|
|
@ -2107,27 +2107,30 @@ Wallet.prototype.removeTxWithSpentInputs = function(cb) {
|
||||||
|
|
||||||
cb = cb || function() {};
|
cb = cb || function() {};
|
||||||
|
|
||||||
var txps = _.where(this.getTxProposals(), {
|
if (!_.some(self.getTxProposals(), {
|
||||||
isPending: true
|
isPending: true
|
||||||
});
|
}))
|
||||||
var inputs = _.flatten(_.map(txps, function(txp) {
|
|
||||||
return _.map(txp.builder.utxos, function(utxo) {
|
|
||||||
return {
|
|
||||||
ntxid: txp.ntxid,
|
|
||||||
txid: utxo.txid,
|
|
||||||
vout: utxo.vout,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (inputs.length === 0)
|
|
||||||
return cb();
|
return cb();
|
||||||
|
|
||||||
|
|
||||||
var proposalsChanged = false;
|
var proposalsChanged = false;
|
||||||
this.blockchain.getUnspent(this.getAddressesStr(), function(err, unspentList) {
|
this.blockchain.getUnspent(this.getAddressesStr(), function(err, unspentList) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
var txps = _.where(self.getTxProposals(), {
|
||||||
|
isPending: true
|
||||||
|
});
|
||||||
|
if (txps.length === 0) return cb();
|
||||||
|
|
||||||
|
var inputs = _.flatten(_.map(txps, function(txp) {
|
||||||
|
return _.map(txp.builder.utxos, function(utxo) {
|
||||||
|
return {
|
||||||
|
ntxid: txp.ntxid,
|
||||||
|
txid: utxo.txid,
|
||||||
|
vout: utxo.vout,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
_.each(unspentList, function(unspent) {
|
_.each(unspentList, function(unspent) {
|
||||||
_.each(inputs, function(input) {
|
_.each(inputs, function(input) {
|
||||||
input.unspent = input.unspent || (input.txid === unspent.txid && input.vout === unspent.vout);
|
input.unspent = input.unspent || (input.txid === unspent.txid && input.vout === unspent.vout);
|
||||||
|
|
|
||||||
|
|
@ -1592,6 +1592,7 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
w._onTxProposal('senderID', data);
|
w._onTxProposal('senderID', data);
|
||||||
txp.setSent.called.should.be.false;
|
txp.setSent.called.should.be.false;
|
||||||
|
txp.setSent.calledWith(1).should.be.false;
|
||||||
w.sendTxProposal.called.should.be.false;
|
w.sendTxProposal.called.should.be.false;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue