diff --git a/src/base58.js b/src/base58.js index aabc523..9515f3d 100644 --- a/src/base58.js +++ b/src/base58.js @@ -3,6 +3,7 @@ var BigInteger = require('./jsbn/jsbn'); var Crypto = require('./crypto-js/crypto'); +var conv = require('/convert'); var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; var base = BigInteger.valueOf(58); @@ -38,7 +39,7 @@ module.exports.encode = function (input) { }, module.exports.encodeHex = function (input) { - return Crypto.util.bytesToHex(module.exports.encode(input)); + return conv.bytesToHex(module.exports.encode(input)); } // decode a base58 string into a byte array @@ -94,7 +95,7 @@ module.exports.checkEncode = function(input, vbyte) { } module.exports.checkEncodeHex = function (input, vbyte) { - return Crypto.util.bytesToHex(module.exports.encode(input)); + return conv.bytesToHex(module.exports.encode(input)); } module.exports.checkDecode = function(input) { diff --git a/src/eckey.js b/src/eckey.js index 13506a5..c3c13d3 100644 --- a/src/eckey.js +++ b/src/eckey.js @@ -121,7 +121,7 @@ ECKey.prototype.toString = function (format) { if (format === "base58") { return base58.checkEncode(this.priv.toByteArrayUnsigned(),128); } else { - return Crypto.util.bytesToHex(this.priv.toByteArrayUnsigned()); + return conv.bytesToHex(this.priv.toByteArrayUnsigned()); } }; diff --git a/src/transaction.js b/src/transaction.js index 543922d..992037f 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -384,7 +384,7 @@ Transaction.prototype.calcImpact = function (wallet) { var valueOut = BigInteger.ZERO; for (var j = 0; j < this.outs.length; j++) { var txout = this.outs[j]; - var hash = Crypto.util.bytesToHex(txout.script.simpleOutPubKeyHash()); + var hash = conv.bytesToHex(txout.script.simpleOutPubKeyHash()); if (wallet.hasHash(hash)) { valueOut = valueOut.add(util.valueToBigInt(txout.value)); } @@ -394,7 +394,7 @@ Transaction.prototype.calcImpact = function (wallet) { var valueIn = BigInteger.ZERO; for (var j = 0; j < this.ins.length; j++) { var txin = this.ins[j]; - var hash = Crypto.util.bytesToHex(txin.script.simpleInPubKeyHash()); + var hash = conv.bytesToHex(txin.script.simpleInPubKeyHash()); if (wallet.hasHash(hash)) { var fromTx = wallet.txIndex[txin.outpoint.hash]; if (fromTx) { @@ -450,7 +450,7 @@ Transaction.deserialize = function(buffer) { for (var i = 0; i < ins; i++) { obj.ins.push({ outpoint: { - hash: util.bytesToHex(readBytes(32)), + hash: conv.bytesToHex(readBytes(32)), index: readAsInt(4) }, script: new Script(readVarString()), diff --git a/src/wallet.js b/src/wallet.js index 99f73d2..c91a916 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -98,7 +98,7 @@ var Wallet = function () { var pubs = []; for (var i = 0; i < keys.length; i++) { - pubs.push(Crypto.util.bytesToHex(keys[i].getPub())); + pubs.push(conv.bytesToHex(keys[i].getPub())); } return pubs; @@ -329,7 +329,7 @@ Wallet.prototype.clearTransactions = function () { * Check to see if a pubKeyHash belongs to this wallet. */ Wallet.prototype.hasHash = function (hash) { - if (Bitcoin.Util.isArray(hash)) hash = Crypto.util.bytesToHex(hash); + if (Bitcoin.Util.isArray(hash)) hash = conv.bytesToHex(hash); // TODO: Just create an object with hashes as keys for faster lookup for (var k = 0; k < this.addressHashes.length; k++) {