Browse Source

HDWallet: rename derivePrivate to deriveHardened

hk-custom-address
Daniel Cousens 11 years ago
parent
commit
dca284a131
  1. 2
      src/hdwallet.js
  2. 4
      src/wallet.js
  3. 4
      test/hdwallet.js

2
src/hdwallet.js

@ -273,7 +273,7 @@ HDWallet.prototype.derive = function(index) {
return hd
}
HDWallet.prototype.derivePrivate = function(index) {
HDWallet.prototype.deriveHardened = function(index) {
// Only derives hardened private keys by default
return this.derive(index + HDWallet.HIGHEST_BIT)
}

4
src/wallet.js

@ -31,9 +31,9 @@ function Wallet(seed, network) {
seed = seed || new Buffer(rng(32))
masterkey = HDNode.fromSeedBuffer(seed, network)
// HD first-level child derivation method should be private
// HD first-level child derivation method should be hardened
// See https://bitcointalk.org/index.php?topic=405179.msg4415254#msg4415254
accountZero = masterkey.derivePrivate(0)
accountZero = masterkey.deriveHardened(0)
externalAccount = accountZero.derive(0)
internalAccount = accountZero.derive(1)

4
test/hdwallet.js

@ -227,7 +227,7 @@ describe('HDWallet', function() {
f.children.forEach(function(c, i) {
it(c.description + ' from ' + f.master.fingerprint, function() {
if (c.hardened) {
hd = hd.derivePrivate(c.m)
hd = hd.deriveHardened(c.m)
} else {
hd = hd.derive(c.m)
@ -255,7 +255,7 @@ describe('HDWallet', function() {
var parent = HDWallet.fromBase58(f.master.base58)
assert.throws(function() {
parent.derivePrivate(c.m)
parent.deriveHardened(c.m)
}, /Could not derive hardened child key/)
})
})

Loading…
Cancel
Save