Skip to content

Commit

Permalink
fix(Wallet): ignore unrecognized scripts
Browse files Browse the repository at this point in the history
Fixes errors when checking transactions that have scripts that we can't get an address from.
  • Loading branch information
mappum committed Jun 2, 2015
1 parent bbc89f5 commit 82634e4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 82634e4

Please sign in to comment.