Skip to content

Commit fdc3f91

Browse files
committed
fix: checkFilter()
1 parent 4832f54 commit fdc3f91

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

lib/net/pool.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ class Pool extends EventEmitter {
744744
this.filterSyncing = true;
745745
const cFHeaderHeight = await this.chain.getCFHeaderHeight();
746746
const startHeight = cFHeaderHeight
747-
? cFHeaderHeight : 1;
747+
? cFHeaderHeight + 1 : 1;
748748
const chainHeight = await this.chain.height;
749749
const stopHeight = chainHeight > 2000 ? 2000 : chainHeight;
750750
const stopHash = await this.chain.getHash(stopHeight);
@@ -769,7 +769,7 @@ class Pool extends EventEmitter {
769769
this.filterSyncing = true;
770770
const cFilterHeight = await this.chain.getCFilterHeight();
771771
const startHeight = cFilterHeight
772-
? cFilterHeight : 1;
772+
? cFilterHeight + 1 : 1;
773773
const chainHeight = await this.chain.height;
774774
const stopHeight = chainHeight > 1000 ? 1000 : chainHeight;
775775
const stopHash = await this.chain.getHash(stopHeight);
@@ -1761,10 +1761,7 @@ class Pool extends EventEmitter {
17611761
return;
17621762

17631763
if (this.neutrino) {
1764-
const locator = await this.chain.getLocator();
1765-
this.sendLocator(locator, peer);
1766-
if (!this.syncing)
1767-
this.startFilterHeadersSync();
1764+
this.startSync();
17681765
return;
17691766
}
17701767

@@ -3668,9 +3665,6 @@ class Pool extends EventEmitter {
36683665
*/
36693666

36703667
getBlock(peer, hashes) {
3671-
if (this.options.neutrino)
3672-
return;
3673-
36743668
if (!this.opened)
36753669
return;
36763670

lib/wallet/walletdb.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,8 @@ class WalletDB extends EventEmitter {
579579
}
580580

581581
async checkFilter (blockHash, filter) {
582-
// script pub keys
583582
this.filterHeight = this.filterHeight + 1;
584-
const gcsKey = blockHash.reverse().slice(0, 16);
583+
const gcsKey = blockHash.slice(0, 16);
585584

586585
const piter = this.db.iterator({
587586
gte: layout.p.min(),
@@ -590,10 +589,9 @@ class WalletDB extends EventEmitter {
590589

591590
await piter.each(async (key) => {
592591
const [data] = layout.p.decode(key);
593-
// address fromHash toScript
594592
if (data.length === 20) {
595593
const script = Script.fromPubkeyhash(data);
596-
const match = filter.match(gcsKey, script);
594+
const match = filter.match(gcsKey, script.raw);
597595
if (match) {
598596
await this.client.getBlockFromNode(blockHash, filter);
599597
return;

test/wallet-neutrino-test.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const fwAddresses = [];
4242
const nwAddresses = [];
4343

4444
async function mineBlock(tx, address) {
45-
console.log('address', address);
4645
const job = await miner.createJob();
4746

4847
if (!tx)
@@ -83,7 +82,6 @@ describe('wallet-neutrino', function() {
8382
for (let i = 0; i < 10; i++) {
8483
const key = await wallet1.createReceive(0);
8584
const address = key.getAddress().toString(node1.network.type);
86-
// console.log(address);
8785
fwAddresses.push(address);
8886
miner.addAddress(address);
8987
}
@@ -148,11 +146,9 @@ describe('wallet-neutrino', function() {
148146
const basicFilter = new BasicFilter();
149147
const gcs = basicFilter.fromNBytes(filter.filter);
150148
const key = hash.slice(0, 16);
151-
const address = Address.fromString(fwAddresses[i], node2.network.type);
149+
const address = Address.fromString(fwAddresses[i], node1.network.type);
152150
const script = Script.fromAddress(address);
153-
// console.log(address.hash);
154-
console.log(script.toRaw());
155-
// assert(gcs.match(key, script.));
151+
assert(gcs.match(key, script.raw));
156152
}
157153
});
158154
});

0 commit comments

Comments
 (0)