Browse Source

HDWallet: move toBase58

hk-custom-address
Daniel Cousens 11 years ago
parent
commit
48503f252c
  1. 20
      src/hdwallet.js

20
src/hdwallet.js

@ -148,6 +148,16 @@ HDWallet.prototype.getAddress = function() {
return this.pub.getAddress(this.network.pubKeyHash)
}
HDWallet.prototype.toBase58 = function(isPrivate) {
var buffer = this.toBuffer(isPrivate)
var checksum = crypto.hash256(buffer).slice(0, 4)
return base58.encode(Buffer.concat([
buffer,
checksum
]))
}
HDWallet.prototype.toBuffer = function(isPrivate) {
// Version
var version = isPrivate ? this.network.bip32.private : this.network.bip32.public
@ -191,16 +201,6 @@ HDWallet.prototype.toHex = function(isPrivate) {
return this.toBuffer(isPrivate).toString('hex')
}
HDWallet.prototype.toBase58 = function(isPrivate) {
var buffer = this.toBuffer(isPrivate)
var checksum = crypto.hash256(buffer).slice(0, 4)
return base58.encode(Buffer.concat([
buffer,
checksum
]))
}
// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
HDWallet.prototype.derive = function(index) {
var isHardened = index >= HDWallet.HIGHEST_BIT

Loading…
Cancel
Save