|
@ -44,8 +44,8 @@ BIP32.prototype.fromRandom = function(networkstr) { |
|
|
this.keypair = (new Keypair()).fromRandom(); |
|
|
this.keypair = (new Keypair()).fromRandom(); |
|
|
this.hasPrivateKey = true; |
|
|
this.hasPrivateKey = true; |
|
|
this.pubKeyHash = Hash.sha256ripemd160(this.keypair.pubkey.toBuffer()); |
|
|
this.pubKeyHash = Hash.sha256ripemd160(this.keypair.pubkey.toBuffer()); |
|
|
this.buildExtendedPublicKey(); |
|
|
this.buildxpubkey(); |
|
|
this.buildExtendedPrivateKey(); |
|
|
this.buildxprivkey(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
BIP32.prototype.fromString = function(str) { |
|
|
BIP32.prototype.fromString = function(str) { |
|
@ -77,8 +77,8 @@ BIP32.prototype.fromSeed = function(bytes, networkstr) { |
|
|
this.hasPrivateKey = true; |
|
|
this.hasPrivateKey = true; |
|
|
this.pubKeyHash = Hash.sha256ripemd160(this.keypair.pubkey.toBuffer()); |
|
|
this.pubKeyHash = Hash.sha256ripemd160(this.keypair.pubkey.toBuffer()); |
|
|
|
|
|
|
|
|
this.buildExtendedPublicKey(); |
|
|
this.buildxpubkey(); |
|
|
this.buildExtendedPrivateKey(); |
|
|
this.buildxprivkey(); |
|
|
|
|
|
|
|
|
return this; |
|
|
return this; |
|
|
}; |
|
|
}; |
|
@ -119,11 +119,11 @@ BIP32.prototype.initFromBytes = function(bytes) { |
|
|
throw new Error('Invalid key'); |
|
|
throw new Error('Invalid key'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.buildExtendedPublicKey(); |
|
|
this.buildxpubkey(); |
|
|
this.buildExtendedPrivateKey(); |
|
|
this.buildxprivkey(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BIP32.prototype.buildExtendedPublicKey = function() { |
|
|
BIP32.prototype.buildxpubkey = function() { |
|
|
this.xpubkey = new Buffer([]); |
|
|
this.xpubkey = new Buffer([]); |
|
|
|
|
|
|
|
|
var v = null; |
|
|
var v = null; |
|
@ -167,7 +167,7 @@ BIP32.prototype.xpubkeyString = function(format) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BIP32.prototype.buildExtendedPrivateKey = function() { |
|
|
BIP32.prototype.buildxprivkey = function() { |
|
|
if (!this.hasPrivateKey) return; |
|
|
if (!this.hasPrivateKey) return; |
|
|
this.xprivkey = new Buffer([]); |
|
|
this.xprivkey = new Buffer([]); |
|
|
|
|
|
|
|
@ -306,8 +306,8 @@ BIP32.prototype.deriveChild = function(i) { |
|
|
|
|
|
|
|
|
ret.pubKeyHash = Hash.sha256ripemd160(ret.keypair.pubkey.toBuffer()); |
|
|
ret.pubKeyHash = Hash.sha256ripemd160(ret.keypair.pubkey.toBuffer()); |
|
|
|
|
|
|
|
|
ret.buildExtendedPublicKey(); |
|
|
ret.buildxpubkey(); |
|
|
ret.buildExtendedPrivateKey(); |
|
|
ret.buildxprivkey(); |
|
|
|
|
|
|
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|