Replaced Crypto.util and util (was a typo) with conv
This commit is contained in:
parent
38ea108183
commit
f95b08a576
4 changed files with 9 additions and 8 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
var BigInteger = require('./jsbn/jsbn');
|
var BigInteger = require('./jsbn/jsbn');
|
||||||
var Crypto = require('./crypto-js/crypto');
|
var Crypto = require('./crypto-js/crypto');
|
||||||
|
var conv = require('/convert');
|
||||||
|
|
||||||
var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
||||||
var base = BigInteger.valueOf(58);
|
var base = BigInteger.valueOf(58);
|
||||||
|
@ -38,7 +39,7 @@ module.exports.encode = function (input) {
|
||||||
},
|
},
|
||||||
|
|
||||||
module.exports.encodeHex = 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
|
// decode a base58 string into a byte array
|
||||||
|
@ -94,7 +95,7 @@ module.exports.checkEncode = function(input, vbyte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.checkEncodeHex = 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) {
|
module.exports.checkDecode = function(input) {
|
||||||
|
|
|
@ -121,7 +121,7 @@ ECKey.prototype.toString = function (format) {
|
||||||
if (format === "base58") {
|
if (format === "base58") {
|
||||||
return base58.checkEncode(this.priv.toByteArrayUnsigned(),128);
|
return base58.checkEncode(this.priv.toByteArrayUnsigned(),128);
|
||||||
} else {
|
} else {
|
||||||
return Crypto.util.bytesToHex(this.priv.toByteArrayUnsigned());
|
return conv.bytesToHex(this.priv.toByteArrayUnsigned());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -384,7 +384,7 @@ Transaction.prototype.calcImpact = function (wallet) {
|
||||||
var valueOut = BigInteger.ZERO;
|
var valueOut = BigInteger.ZERO;
|
||||||
for (var j = 0; j < this.outs.length; j++) {
|
for (var j = 0; j < this.outs.length; j++) {
|
||||||
var txout = this.outs[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)) {
|
if (wallet.hasHash(hash)) {
|
||||||
valueOut = valueOut.add(util.valueToBigInt(txout.value));
|
valueOut = valueOut.add(util.valueToBigInt(txout.value));
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ Transaction.prototype.calcImpact = function (wallet) {
|
||||||
var valueIn = BigInteger.ZERO;
|
var valueIn = BigInteger.ZERO;
|
||||||
for (var j = 0; j < this.ins.length; j++) {
|
for (var j = 0; j < this.ins.length; j++) {
|
||||||
var txin = this.ins[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)) {
|
if (wallet.hasHash(hash)) {
|
||||||
var fromTx = wallet.txIndex[txin.outpoint.hash];
|
var fromTx = wallet.txIndex[txin.outpoint.hash];
|
||||||
if (fromTx) {
|
if (fromTx) {
|
||||||
|
@ -450,7 +450,7 @@ Transaction.deserialize = function(buffer) {
|
||||||
for (var i = 0; i < ins; i++) {
|
for (var i = 0; i < ins; i++) {
|
||||||
obj.ins.push({
|
obj.ins.push({
|
||||||
outpoint: {
|
outpoint: {
|
||||||
hash: util.bytesToHex(readBytes(32)),
|
hash: conv.bytesToHex(readBytes(32)),
|
||||||
index: readAsInt(4)
|
index: readAsInt(4)
|
||||||
},
|
},
|
||||||
script: new Script(readVarString()),
|
script: new Script(readVarString()),
|
||||||
|
|
|
@ -98,7 +98,7 @@ var Wallet = function () {
|
||||||
var pubs = [];
|
var pubs = [];
|
||||||
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
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;
|
return pubs;
|
||||||
|
@ -329,7 +329,7 @@ Wallet.prototype.clearTransactions = function () {
|
||||||
* Check to see if a pubKeyHash belongs to this wallet.
|
* Check to see if a pubKeyHash belongs to this wallet.
|
||||||
*/
|
*/
|
||||||
Wallet.prototype.hasHash = function (hash) {
|
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
|
// TODO: Just create an object with hashes as keys for faster lookup
|
||||||
for (var k = 0; k < this.addressHashes.length; k++) {
|
for (var k = 0; k < this.addressHashes.length; k++) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue