Skip to content

Commit

Permalink
test: getblockpeer
Browse files Browse the repository at this point in the history
  • Loading branch information
manavdesai27 committed Jul 9, 2023
1 parent c73dfcf commit a8281f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/wallet/walletdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class WalletDB extends EventEmitter {
this.depth = 0;
this.rescanning = false;
this.filterSent = false;
this.isWitness = false;

// Wallet read lock.
this.readLock = new MapLock();
Expand Down Expand Up @@ -212,6 +213,9 @@ class WalletDB extends EventEmitter {
id: 'primary'
});

const account = await wallet.getAccount(wallet.wid);
this.isWitness = account.witness;

const addr = await wallet.receiveAddress();

this.logger.info(
Expand Down Expand Up @@ -591,7 +595,12 @@ class WalletDB extends EventEmitter {
await piter.each(async (key) => {
const [data] = layout.p.decode(key);
if (data.length === 20) {
const address = Address.fromWitnessPubkeyhash(data);
let address = null;
if (this.isWitness)
address = Address.fromWitnessPubkeyhash(data);
else
address = Address.fromPubkeyhash(data);

const script = Script.fromAddress(address);
const match = filter.match(gcsKey, script.raw);
if (match) {
Expand Down
8 changes: 8 additions & 0 deletions test/wallet-neutrino-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,12 @@ describe('wallet-neutrino', function() {
assert(gcs.match(key, script.raw));
}
});

it('should getblockfrompeer', async () => {
for (let i = 21; i <= node2.chain.height; i++) {
const hash = await node2.chain.getHash(i);
const block = await node2.chain.getBlock(hash);
assert(block);
}
});
});

0 comments on commit a8281f6

Please sign in to comment.