Fixed bug in Safari for PublicKey and Script instance checking in Address

This commit is contained in:
Braydon Fuller 2015-01-05 17:31:51 -05:00
parent 6fb5c4771f
commit a801663c6d

View File

@ -213,8 +213,9 @@ Address._transformBuffer = function(buffer, network, type){
* @private * @private
*/ */
Address._transformPublicKey = function(pubkey){ Address._transformPublicKey = function(pubkey){
var PublicKey = require('./publickey');
var info = {}; 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.'); throw new TypeError('Address must be an instance of PublicKey.');
} }
info.hashBuffer = Hash.sha256ripemd160(pubkey.toBuffer()); info.hashBuffer = Hash.sha256ripemd160(pubkey.toBuffer());
@ -230,8 +231,9 @@ Address._transformPublicKey = function(pubkey){
* @private * @private
*/ */
Address._transformScript = function(script, network){ Address._transformScript = function(script, network){
var Script = require('./script');
var info = {}; 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.'); throw new TypeError('Address must be an instance of Script.');
} }
if (script.isScriptHashOut()) { if (script.isScriptHashOut()) {