fixes handling wrong txs

This commit is contained in:
Matias Alejo Garcia 2014-11-02 22:41:04 -03:00
commit 22ef1bb3f3
2 changed files with 6 additions and 3 deletions

View file

@ -256,7 +256,7 @@ Insight.prototype.broadcast = function(rawtx, cb) {
this.requestPost('/api/tx/send', {
rawtx: rawtx
}, function(err, res, body) {
if (err || res.status != 200) cb(err || res);
if (err || res.statusCode != 200) cb(err || body);
cb(null, body ? body.txid : null);
});
};

View file

@ -1381,14 +1381,17 @@ Wallet.prototype.sendTx = function(ntxid, cb) {
var self = this;
this.blockchain.broadcast(txHex, function(err, txid) {
log.debug('Wallet:' + self.id + ' BITCOIND txid:', txid);
if (err)
log.error('Error sending TX:',err);
if (txid) {
log.debug('Wallet:' + self.getName() + ' Broadcasted TX. BITCOIND txid:', txid);
self.txProposals.get(ntxid).setSent(txid);
self.sendTxProposal(ntxid);
self.emitAndKeepAlive('txProposalsUpdated');
return cb(txid);
} else {
log.debug('Wallet:' + self.id + ' Sent failed. Checking if the TX was sent already');
log.info('Wallet:' + self.getName() + '. Sent failed. Checking if the TX was sent already');
self._checkSentTx(ntxid, function(txid) {
if (txid)
self.emitAndKeepAlive('txProposalsUpdated');