diff --git a/lib/address.js b/lib/address.js index 96d1a062a..b773f9d96 100644 --- a/lib/address.js +++ b/lib/address.js @@ -213,8 +213,9 @@ Address._transformBuffer = function(buffer, network, type){ * @private */ Address._transformPublicKey = function(pubkey){ + var PublicKey = require('./publickey'); var info = {}; - if (!pubkey.constructor || (pubkey.constructor.name && pubkey.constructor.name !== 'PublicKey')) { + if (!(pubkey instanceof PublicKey)) { throw new TypeError('Address must be an instance of PublicKey.'); } info.hashBuffer = Hash.sha256ripemd160(pubkey.toBuffer()); @@ -230,8 +231,9 @@ Address._transformPublicKey = function(pubkey){ * @private */ Address._transformScript = function(script, network){ + var Script = require('./script'); var info = {}; - if (!script.constructor || (script.constructor.name && script.constructor.name !== 'Script')) { + if (!(script instanceof Script)) { throw new TypeError('Address must be an instance of Script.'); } if (script.isScriptHashOut()) {