From c35dd1e42664c2a1a67823264637f3ac209d454c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Rodriguez=20Ve=CC=81lez?= Date: Mon, 1 Oct 2018 01:24:34 -0400 Subject: [PATCH] FIX: Fixed testing. --- HDWallet.test.js | 4 ++-- class/abstract-hd-wallet.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/HDWallet.test.js b/HDWallet.test.js index a991df4c5..2b93df7c3 100644 --- a/HDWallet.test.js +++ b/HDWallet.test.js @@ -125,7 +125,7 @@ it('Segwit HD (BIP49) can fetch UTXO', async function() { hd.usedAddresses = ['1Ez69SnzzmePmZX3WpEzMKTrcBF2gpNQ55', '1BiTCHeYzJNMxBLFCMkwYXNdFEdPJP53ZV']; // hacking internals await hd.fetchUtxo(); assert.equal(hd.utxo.length, 9); - assert.ok(hd.utxo[0].confirmations); + assert.ok(typeof hd.utxo[0].confirmations === 'number'); assert.ok(hd.utxo[0].txid); assert.ok(hd.utxo[0].vout); assert.ok(hd.utxo[0].amount); @@ -283,6 +283,6 @@ it('can convert blockchain.info TX to blockcypher TX format', () => { assert.ok(blockcyphertx.received); // time assert.ok(blockcyphertx.hash); assert.ok(blockcyphertx.value); - assert.ok(blockcyphertx.confirmations); + assert.ok(typeof blockcyphertx.confirmations === 'number'); assert.ok(blockcyphertx.outputs); }); diff --git a/class/abstract-hd-wallet.js b/class/abstract-hd-wallet.js index feaaf9622..d2e519691 100644 --- a/class/abstract-hd-wallet.js +++ b/class/abstract-hd-wallet.js @@ -41,6 +41,9 @@ export class AbstractHDWallet extends LegacyWallet { var clone = Object.assign({}, tx); clone.received = new Date(clone.time * 1000).toISOString(); clone.outputs = clone.out; + if (clone.confirmations === undefined) { + clone.confirmations = 0; + } for (let o of clone.outputs) { o.addresses = [o.addr]; }