Skip to content

Commit

Permalink
feat: add checkKeyFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
manavdesai27 authored and masterchief164 committed Jun 5, 2023
1 parent 260e979 commit 363ef03
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/client/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ class NodeClient extends Client {
return this.get(`/filter/${filter}`);
}

checkKeyFilter(key, filter) {
return this.call('check key filter', key, filter);
}

/**
* Add a transaction to the mempool and broadcast it.
* @param {TX} tx
Expand Down
7 changes: 7 additions & 0 deletions lib/node/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,13 @@ class HTTP extends Server {
return null;
});

socket.hook('check key filter', (...args) => {
const valid = new Validator(args);
const key = valid.buf(0);
const filter = valid.buf(1);
return this.pool.checkKeyFilter(key, filter);
});

socket.hook('estimate fee', (...args) => {
const valid = new Validator(args);
const blocks = valid.u32(0);
Expand Down
13 changes: 13 additions & 0 deletions lib/wallet/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const NodeClient = require('../client/node');
const util = require('../utils/util');
const TX = require('../primitives/tx');
const hash256 = require('bcrypto/lib/hash256');
const WalletKey = require('./walletkey');
const Filter = require('../primitives/filter');

const parsers = {
'block connect': (entry, txs) => parseBlock(entry, txs),
Expand Down Expand Up @@ -71,6 +73,17 @@ class WalletClient extends NodeClient {
return super.setFilter(filter.toRaw());
}

/**
* Check filter against wallet key ring
* @param {WalletKey} ring
* @param {Filter} filter
* @returns {Promise}
*/

async checkKeyFilter(ring, filter) {
return super.checkKeyFilter(ring, filter);
}

async rescan(start) {
if (Buffer.isBuffer(start))
start = util.revHex(start);
Expand Down
1 change: 0 additions & 1 deletion lib/wallet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

exports.Account = require('./account');
exports.Client = require('./client');
exports.NeutrinoClient = require('./neutrinoclient');
exports.common = require('./common');
exports.HTTP = require('./http');
exports.layout = require('./layout');
Expand Down
13 changes: 13 additions & 0 deletions lib/wallet/nodeclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

const assert = require('bsert');
const AsyncEmitter = require('bevent');
const WalletKey = require('./walletkey');
const Filter = require('../primitives/filter');

/**
* Node Client
Expand Down Expand Up @@ -174,6 +176,17 @@ class NodeClient extends AsyncEmitter {
this.node.pool.queueFilterLoad();
}

/**
* Check filter against wallet key ring
* @param {WalletKey} ring
* @param {Filter} filter
* @returns {Promise}
*/

async checkKeyFilter(ring, filter) {
this.node.pool.checkKeyFilter(ring, filter);
}

/**
* Estimate smart fee.
* @param {Number?} blocks
Expand Down
13 changes: 13 additions & 0 deletions lib/wallet/nullclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

const assert = require('bsert');
const EventEmitter = require('events');
const WalletKey = require('./walletkey');
const Filter = require('../primitives/filter');

/**
* Null Client
Expand Down Expand Up @@ -130,6 +132,17 @@ class NullClient extends EventEmitter {
this.wdb.emit('reset filter');
}

/**
* Check filter against wallet key ring
* @param {WalletKey} ring
* @param {Filter} filter
* @returns {Promise}
*/

async checkKeyFilter(ring, filter) {
;
}

/**
* Esimate smart fee.
* @param {Number?} blocks
Expand Down

0 comments on commit 363ef03

Please sign in to comment.