Fail to send should check if already sent
This commit is contained in:
parent
63fb94c2be
commit
0710c002ca
3 changed files with 18 additions and 1 deletions
|
|
@ -817,7 +817,7 @@ Wallet.prototype.sendTx = function(ntxid, cb) {
|
||||||
self.store();
|
self.store();
|
||||||
return cb(txid);
|
return cb(txid);
|
||||||
} else {
|
} else {
|
||||||
self.log('Sent failed. Checking is the TX was sent already');
|
self.log('Sent failed. Checking if the TX was sent already');
|
||||||
self._checkSentTx(ntxid, function(txid) {
|
self._checkSentTx(ntxid, function(txid) {
|
||||||
if (txid)
|
if (txid)
|
||||||
self.store();
|
self.store();
|
||||||
|
|
|
||||||
|
|
@ -46,4 +46,9 @@ FakeBlockchain.prototype.sendRawTransaction = function(rawtx, cb) {
|
||||||
return cb(txid);
|
return cb(txid);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FakeBlockchain.prototype.checkSentTx = function (tx, cb) {
|
||||||
|
var txid = '0be0fb4579911be829e3077202e1ab47fcc12cf3ab8f8487ccceae768e1f95fa';
|
||||||
|
return cb(null, txid);
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = FakeBlockchain;
|
module.exports = FakeBlockchain;
|
||||||
|
|
|
||||||
|
|
@ -756,6 +756,18 @@ describe('Wallet model', function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('should check if transaction already sent when failing to send', function(done) {
|
||||||
|
var w = createW2(null, 1);
|
||||||
|
var utxo = createUTXO(w);
|
||||||
|
w.blockchain.fixUnspent(utxo);
|
||||||
|
w.createTx(toAddress, amountSatStr, null, function(ntxid) {
|
||||||
|
sinon.stub(w.blockchain, 'sendRawTransaction').yields(undefined);
|
||||||
|
var spyCheckSentTx = sinon.spy(w, '_checkSentTx');
|
||||||
|
w.sendTx(ntxid, function () {});
|
||||||
|
chai.expect(spyCheckSentTx.calledOnce).to.be.true;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
it('should send TxProposal', function(done) {
|
it('should send TxProposal', function(done) {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue