diff --git a/lib/net/pool.js b/lib/net/pool.js index 5c75a0966..869746e2f 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -744,7 +744,7 @@ class Pool extends EventEmitter { this.filterSyncing = true; const cFHeaderHeight = await this.chain.getCFHeaderHeight(); const startHeight = cFHeaderHeight - ? cFHeaderHeight : 1; + ? cFHeaderHeight + 1 : 1; const chainHeight = await this.chain.height; const stopHeight = chainHeight > 2000 ? 2000 : chainHeight; const stopHash = await this.chain.getHash(stopHeight); @@ -769,7 +769,7 @@ class Pool extends EventEmitter { this.filterSyncing = true; const cFilterHeight = await this.chain.getCFilterHeight(); const startHeight = cFilterHeight - ? cFilterHeight : 1; + ? cFilterHeight + 1 : 1; const chainHeight = await this.chain.height; const stopHeight = chainHeight > 1000 ? 1000 : chainHeight; const stopHash = await this.chain.getHash(stopHeight); @@ -1761,10 +1761,7 @@ class Pool extends EventEmitter { return; if (this.neutrino) { - const locator = await this.chain.getLocator(); - this.sendLocator(locator, peer); - if (!this.syncing) - this.startFilterHeadersSync(); + this.startSync(); return; } @@ -3668,9 +3665,6 @@ class Pool extends EventEmitter { */ getBlock(peer, hashes) { - if (this.options.neutrino) - return; - if (!this.opened) return; diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js index a4134caf9..275ee07b3 100644 --- a/lib/wallet/walletdb.js +++ b/lib/wallet/walletdb.js @@ -579,9 +579,8 @@ class WalletDB extends EventEmitter { } async checkFilter (blockHash, filter) { - // script pub keys this.filterHeight = this.filterHeight + 1; - const gcsKey = blockHash.reverse().slice(0, 16); + const gcsKey = blockHash.slice(0, 16); const piter = this.db.iterator({ gte: layout.p.min(), @@ -590,10 +589,9 @@ class WalletDB extends EventEmitter { await piter.each(async (key) => { const [data] = layout.p.decode(key); - // address fromHash toScript if (data.length === 20) { const script = Script.fromPubkeyhash(data); - const match = filter.match(gcsKey, script); + const match = filter.match(gcsKey, script.raw); if (match) { await this.client.getBlockFromNode(blockHash, filter); return; diff --git a/test/wallet-neutrino-test.js b/test/wallet-neutrino-test.js index f0be7547c..02e040267 100644 --- a/test/wallet-neutrino-test.js +++ b/test/wallet-neutrino-test.js @@ -42,7 +42,6 @@ const fwAddresses = []; const nwAddresses = []; async function mineBlock(tx, address) { - console.log('address', address); const job = await miner.createJob(); if (!tx) @@ -83,7 +82,6 @@ describe('wallet-neutrino', function() { for (let i = 0; i < 10; i++) { const key = await wallet1.createReceive(0); const address = key.getAddress().toString(node1.network.type); - // console.log(address); fwAddresses.push(address); miner.addAddress(address); } @@ -148,11 +146,9 @@ describe('wallet-neutrino', function() { const basicFilter = new BasicFilter(); const gcs = basicFilter.fromNBytes(filter.filter); const key = hash.slice(0, 16); - const address = Address.fromString(fwAddresses[i], node2.network.type); + const address = Address.fromString(fwAddresses[i], node1.network.type); const script = Script.fromAddress(address); - // console.log(address.hash); - console.log(script.toRaw()); - // assert(gcs.match(key, script.)); + assert(gcs.match(key, script.raw)); } }); });