diff --git a/.gitignore b/.gitignore index 0a75c5e5a..7f9b1000e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ docker_data/ docs/reference/ node_modules/ npm-debug.log +.vscode/ diff --git a/lib/wallet/txdb.js b/lib/wallet/txdb.js index 38eca6a68..46d894179 100644 --- a/lib/wallet/txdb.js +++ b/lib/wallet/txdb.js @@ -3178,11 +3178,15 @@ class TXDB { assert((age >>> 0) === age); const now = util.now(); + const pendingTxs = await this.getPendingHashes(acct); - const txs = await this.getRange(acct, { - start: 0, - end: now - age - }); + const txs = []; + + for (const hash of pendingTxs) { + const tx = await this.getTX(hash); + assert(tx); + txs.push(tx); + } const hashes = []; diff --git a/test/wallet-http-test.js b/test/wallet-http-test.js index 51ed107e7..e73e3abf4 100644 --- a/test/wallet-http-test.js +++ b/test/wallet-http-test.js @@ -812,6 +812,30 @@ describe('Wallet HTTP', function() { } }); + it('should zap eligible transactions', async () => { + // clear all pending txes + let pendingTxes = await wallet.getPending('default'); + for (const pendingTx of pendingTxes) { + await wallet.abandon(pendingTx.hash); + } + + const tx = await wallet.send({ + outputs: [{ address: cbAddress, value: 1e4 }] + }); + + pendingTxes = await wallet.getPending('default'); + assert(pendingTxes.length === 1); + assert(pendingTxes[0].hash === tx.hash); + + await sleep(1001); + + const {success} = await wallet.zap('default', 1); + assert(success === true); + + pendingTxes = await wallet.getPending('default'); + assert(pendingTxes.length === 0); + }); + // this test creates namestate to use duing the // next test, hold on to the name being used. const state = {