"gc" was some find-replace error from earlier

This commit is contained in:
Ryan X. Charles 2014-09-17 14:37:53 -07:00
parent af6932a313
commit 334c443d8b
1 changed files with 14 additions and 14 deletions

View File

@ -31,14 +31,14 @@ BIP32.prototype.fromRandom = function(networkstr) {
BIP32.prototype.fromString = function(str) { BIP32.prototype.fromString = function(str) {
var decoded = base58.decode(str); var decoded = base58.decode(str);
if (decoded.length != 82) if (decoded.length != 82)
throw new Error('gcNot enough data, expected 82 and received ' + decoded.length); throw new Error('Not enough data, expected 82 and received ' + decoded.length);
var checksum = decoded.slice(78, 82); var checksum = decoded.slice(78, 82);
var bytes = decoded.slice(0, 78); var bytes = decoded.slice(0, 78);
var hash = Hash.sha256sha256(bytes); var hash = Hash.sha256sha256(bytes);
if (hash[0] != checksum[0] || hash[1] != checksum[1] || hash[2] != checksum[2] || hash[3] != checksum[3]) if (hash[0] != checksum[0] || hash[1] != checksum[1] || hash[2] != checksum[2] || hash[3] != checksum[3])
throw new Error('gcInvalid checksum'); throw new Error('Invalid checksum');
if (bytes !== undefined && bytes !== null) if (bytes !== undefined && bytes !== null)
this.initFromBytes(bytes); this.initFromBytes(bytes);
@ -51,11 +51,11 @@ BIP32.prototype.fromSeed = function(bytes, networkstr) {
networkstr = 'mainnet'; networkstr = 'mainnet';
if (!Buffer.isBuffer(bytes)) if (!Buffer.isBuffer(bytes))
throw new Error('gcbytes must be a buffer'); throw new Error('bytes must be a buffer');
if (bytes.length < 128 / 8) if (bytes.length < 128 / 8)
throw new Error('gcNeed more than 128 bytes of entropy'); throw new Error('Need more than 128 bytes of entropy');
if (bytes.length > 512 / 8) if (bytes.length > 512 / 8)
throw new Error('gcMore than 512 bytes of entropy is nonstandard'); throw new Error('More than 512 bytes of entropy is nonstandard');
var hash = Hash.sha512hmac(bytes, new Buffer('Bitcoin seed')); var hash = Hash.sha512hmac(bytes, new Buffer('Bitcoin seed'));
this.depth = 0x00; this.depth = 0x00;
@ -78,7 +78,7 @@ BIP32.prototype.fromSeed = function(bytes, networkstr) {
BIP32.prototype.initFromBytes = function(bytes) { BIP32.prototype.initFromBytes = function(bytes) {
// Both pub and private extended keys are 78 bytes // Both pub and private extended keys are 78 bytes
if (bytes.length != 78) if (bytes.length != 78)
throw new Error('gcnot enough data'); throw new Error('not enough data');
this.version = u32(bytes.slice(0, 4)); this.version = u32(bytes.slice(0, 4));
this.depth = u8(bytes.slice(4, 5)); this.depth = u8(bytes.slice(4, 5));
@ -108,7 +108,7 @@ BIP32.prototype.initFromBytes = function(bytes) {
this.pubKeyHash = Hash.sha256ripemd160(this.key.pubkey.toBuffer()); this.pubKeyHash = Hash.sha256ripemd160(this.key.pubkey.toBuffer());
this.hasPrivateKey = false; this.hasPrivateKey = false;
} else { } else {
throw new Error('gcInvalid key'); throw new Error('Invalid key');
} }
this.buildExtendedPublicKey(); this.buildExtendedPublicKey();
@ -129,7 +129,7 @@ BIP32.prototype.buildExtendedPublicKey = function() {
v = constants.testnet.bip32pubkey; v = constants.testnet.bip32pubkey;
break; break;
default: default:
throw new Error('gcUnknown version'); throw new Error('Unknown version');
} }
// Version // Version
@ -158,7 +158,7 @@ BIP32.prototype.extendedPublicKeyString = function(format) {
} else if (format === 'hex') { } else if (format === 'hex') {
return this.extendedPublicKey.toString('hex');; return this.extendedPublicKey.toString('hex');;
} else { } else {
throw new Error('gcbad format'); throw new Error('bad format');
} }
} }
@ -194,7 +194,7 @@ BIP32.prototype.extendedPrivateKeyString = function(format) {
} else if (format === 'hex') { } else if (format === 'hex') {
return this.extendedPrivateKey.toString('hex'); return this.extendedPrivateKey.toString('hex');
} else { } else {
throw new Error('gcbad format'); throw new Error('bad format');
} }
} }
@ -211,12 +211,12 @@ BIP32.prototype.derive = function(path) {
var c = e[i]; var c = e[i];
if (i == 0) { if (i == 0) {
if (c != 'm') throw new Error('gcinvalid path'); if (c != 'm') throw new Error('invalid path');
continue; continue;
} }
if (parseInt(c.replace("'", "")).toString() !== c.replace("'", "")) if (parseInt(c.replace("'", "")).toString() !== c.replace("'", ""))
throw new Error('gcinvalid path'); throw new Error('invalid path');
var usePrivate = (c.length > 1) && (c[c.length - 1] == '\''); var usePrivate = (c.length > 1) && (c[c.length - 1] == '\'');
var childIndex = parseInt(usePrivate ? c.slice(0, c.length - 1) : c) & 0x7fffffff; var childIndex = parseInt(usePrivate ? c.slice(0, c.length - 1) : c) & 0x7fffffff;
@ -232,7 +232,7 @@ BIP32.prototype.derive = function(path) {
BIP32.prototype.deriveChild = function(i) { BIP32.prototype.deriveChild = function(i) {
if (typeof i !== 'number') if (typeof i !== 'number')
throw new Error('gci must be a number'); throw new Error('i must be a number');
var ib = []; var ib = [];
ib.push((i >> 24) & 0xff); ib.push((i >> 24) & 0xff);
@ -248,7 +248,7 @@ BIP32.prototype.deriveChild = function(i) {
this.version == constants.testnet.bip32privkey); this.version == constants.testnet.bip32privkey);
if (usePrivate && (!this.hasPrivateKey || !isPrivate)) if (usePrivate && (!this.hasPrivateKey || !isPrivate))
throw new Error('gcCannot do private key derivation without private key'); throw new Error('Cannot do private key derivation without private key');
var ret = null; var ret = null;
if (this.hasPrivateKey) { if (this.hasPrivateKey) {