bring formatting in line with bitcore standards
This commit is contained in:
parent
fa47ee9984
commit
31a024a20b
14
BIP32.js
14
BIP32.js
|
@ -1,3 +1,6 @@
|
|||
var EncodedData = require('./util/EncodedData');
|
||||
var base58 = imports.base58 || require('base58-native').base58Check;
|
||||
|
||||
var BITCOIN_MAINNET_PUBLIC = 0x0488b21e;
|
||||
var BITCOIN_MAINNET_PRIVATE = 0x0488ade4;
|
||||
var BITCOIN_TESTNET_PUBLIC = 0x043587cf;
|
||||
|
@ -14,8 +17,9 @@ var LITECOIN_TESTNET_PRIVATE = 0x0436ef7d;
|
|||
var BIP32 = function(bytes) {
|
||||
// decode base58
|
||||
if (typeof bytes === "string") {
|
||||
var decoded = Bitcoin.Base58.decode(bytes);
|
||||
if( decoded.length != 82 ) throw new Error("Not enough data");
|
||||
var decoded = base58.decode(bytes);
|
||||
if (decoded.length != 82)
|
||||
throw new Error("Not enough data");
|
||||
var checksum = decoded.slice(78, 82);
|
||||
bytes = decoded.slice(0, 78);
|
||||
|
||||
|
@ -202,7 +206,8 @@ BIP32.prototype.derive = function(path) {
|
|||
var e = path.split('/');
|
||||
|
||||
// Special cases:
|
||||
if( path == 'm' || path == 'M' || path == 'm\'' || path == 'M\'' ) return this;
|
||||
if (path == 'm' || path == 'M' || path == 'm\'' || path == 'M\'')
|
||||
return this;
|
||||
|
||||
var bip32 = this;
|
||||
for (var i in e) {
|
||||
|
@ -243,7 +248,8 @@ BIP32.prototype.derive_child = function(i) {
|
|||
this.version == LITECOIN_MAINNET_PRIVATE ||
|
||||
this.version == LITECOIN_TESTNET_PRIVATE);
|
||||
|
||||
if( use_private && (!this.has_private_key || !is_private) ) throw new Error("Cannot do private key derivation without private key");
|
||||
if (use_private && (!this.has_private_key || !is_private))
|
||||
throw new Error("Cannot do private key derivation without private key");
|
||||
|
||||
var ret = null;
|
||||
if (this.has_private_key) {
|
||||
|
|
Loading…
Reference in New Issue