HDWallet: move toBase58
This commit is contained in:
parent
dca284a131
commit
48503f252c
1 changed files with 10 additions and 10 deletions
|
@ -148,6 +148,16 @@ HDWallet.prototype.getAddress = function() {
|
||||||
return this.pub.getAddress(this.network.pubKeyHash)
|
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) {
|
HDWallet.prototype.toBuffer = function(isPrivate) {
|
||||||
// Version
|
// Version
|
||||||
var version = isPrivate ? this.network.bip32.private : this.network.bip32.public
|
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')
|
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
|
// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
|
||||||
HDWallet.prototype.derive = function(index) {
|
HDWallet.prototype.derive = function(index) {
|
||||||
var isHardened = index >= HDWallet.HIGHEST_BIT
|
var isHardened = index >= HDWallet.HIGHEST_BIT
|
||||||
|
|
Loading…
Add table
Reference in a new issue