From 97c4de9da62e44d49a237e933b472935fb1ea410 Mon Sep 17 00:00:00 2001 From: Daniel Cousens <github@dcousens.com> Date: Tue, 23 Jun 2015 16:43:17 +1000 Subject: [PATCH] *: throw new Error over assert(false, ... --- src/address.js | 4 ++-- src/ecpair.js | 2 +- src/hdnode.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/address.js b/src/address.js index 4d8c67a..4b29a1f 100644 --- a/src/address.js +++ b/src/address.js @@ -37,7 +37,7 @@ Address.fromOutputScript = function (script, network) { if (scripts.isPubKeyHashOutput(script)) return new Address(script.chunks[2], network.pubKeyHash) if (scripts.isScriptHashOutput(script)) return new Address(script.chunks[1], network.scriptHash) - assert(false, script.toASM() + ' has no matching Address') + throw new Error(script.toASM() + ' has no matching Address') } Address.prototype.toBase58Check = function () { @@ -54,7 +54,7 @@ Address.prototype.toOutputScript = function () { if (scriptType === 'pubkeyhash') return scripts.pubKeyHashOutput(this.hash) if (scriptType === 'scripthash') return scripts.scriptHashOutput(this.hash) - assert(false, this.toString() + ' has no matching Script') + throw new Error(this.toString() + ' has no matching Script') } Address.prototype.toString = Address.prototype.toBase58Check diff --git a/src/ecpair.js b/src/ecpair.js index 990c2dd..a8042c6 100644 --- a/src/ecpair.js +++ b/src/ecpair.js @@ -17,7 +17,7 @@ function findNetworkByWIFVersion (version) { if (network.wif === version) return network } - assert(false, 'Unknown network') + throw new Error('Unknown network') } function ECPair (d, Q, options) { diff --git a/src/hdnode.js b/src/hdnode.js index 6989b3e..604bd74 100644 --- a/src/hdnode.js +++ b/src/hdnode.js @@ -20,7 +20,7 @@ function findBIP32NetworkByVersion (version) { } } - assert(false, 'Could not find network for ' + version.toString(16)) + throw new Error('Could not find network for ' + version.toString(16)) } function HDNode (keyPair, chainCode) {