From 2a18a7697354dab6345dc1fd387428970c62c5c2 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 24 Jun 2016 12:54:49 -0700 Subject: [PATCH] fix coins parsing. address type. --- lib/bcoin/coins.js | 1 + lib/bcoin/script.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/bcoin/coins.js b/lib/bcoin/coins.js index 20ef8aab..edca553b 100644 --- a/lib/bcoin/coins.js +++ b/lib/bcoin/coins.js @@ -234,6 +234,7 @@ Coins.prototype.fromRaw = function fromRaw(data, hash, index) { mask = p.readU8(); if (mask === 0xff) { + p.end(); if (index != null) { if (i === index) return; diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index 01d4d8c5..eee2c0d7 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -2531,6 +2531,9 @@ Script.fromAddress = function fromAddress(address) { if (typeof address === 'string') address = bcoin.address.fromBase58(address); + if (!address) + throw new Error('Unknown address type.'); + if (address.type === 'pubkeyhash') return Script.fromPubkeyhash(address.hash); @@ -2540,7 +2543,7 @@ Script.fromAddress = function fromAddress(address) { if (address.version !== -1) return Script.fromProgram(address.version, address.hash); - assert(false, 'Bad type.'); + assert(false, 'Bad address type.'); }; /**