diff --git a/lib/wallet.js b/lib/wallet.js index 482d4be..842d0ac 100644 --- a/lib/wallet.js +++ b/lib/wallet.js @@ -251,8 +251,9 @@ Wallet.prototype._scanChain = function (opts) { Wallet.prototype.isOwnOutput = function (output, cb) { if (!output.script) return cb(null, false) if (output.script.isPublicKeyHashOut() || output.script.isPublicKeyOut()) { - var pubHash = output.script.toAddress(this.network).hashBuffer - this.store.get(pubHash.toString('base64'), function (err, key) { + var addr = output.script.toAddress(this.network) + if (!addr) return cb(null, false) + this.store.get(addr.hashBuffer.toString('base64'), function (err, key) { if (err && !err.notFound) return cb(err) if (err && err.notFound) return cb(null, false) cb(null, true) @@ -265,8 +266,9 @@ Wallet.prototype.isOwnOutput = function (output, cb) { Wallet.prototype.isOwnInput = function (input, cb) { if (!input.script) return cb(null, 0) if (input.script.isPublicKeyHashIn() || input.script.isPublicKeyIn()) { - var pubHash = input.script.toAddress(this.network).hashBuffer - this.store.get(pubHash.toString('base64'), function (err, key) { + var addr = input.script.toAddress(this.network) + if (!addr) return cb(null, false) + this.store.get(addr.hashBuffer.toString('base64'), function (err, key) { if (err && !err.notFound) return cb(err) if (err && err.notFound) return cb(null, false) cb(null, true)