Skip to content

Commit

Permalink
feat(Wallet): support bloom filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Jan 5, 2016
1 parent 3541b25 commit a55d33b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ var Wallet = module.exports = function (opts, cb) {

this.feePerKb = opts.feePerKb || 10000

this.filters = []

this._error = this._error.bind(this)
this.initialized = false
this._initialize(cb)
Expand Down Expand Up @@ -598,6 +600,7 @@ Wallet.prototype._generateKeys = function (cb) {
path: 'm/0/' + i
}
self.store.put(hash.toString('base64'), value, cb)
self.emit('genkey', key, i)
})
})(i)
}
Expand Down Expand Up @@ -716,3 +719,19 @@ Wallet.prototype._saveState = function (cb) {
}
this.store.put('state', state, cb)
}

Wallet.prototype.addFilter = function (filter) {
if (this.filters.indexOf(filter) !== -1) return
this.filters.push(filter)
function addKey (hdkey) {
var pubkey = hdkey.publicKey
filter.insert(pubkey.toBuffer())
filter.insert(keyHash(pubkey.toBuffer()))
}
if (this.state) {
for (var i = 0; i < this.state.gen; i++) {
addKey(this.deriveKey(i))
}
}
this.on('genkey', addKey)
}

0 comments on commit a55d33b

Please sign in to comment.