HDWallet: rename derivePrivate to deriveHardened
This commit is contained in:
parent
29fbbaa58d
commit
dca284a131
3 changed files with 5 additions and 5 deletions
|
@ -273,7 +273,7 @@ HDWallet.prototype.derive = function(index) {
|
||||||
return hd
|
return hd
|
||||||
}
|
}
|
||||||
|
|
||||||
HDWallet.prototype.derivePrivate = function(index) {
|
HDWallet.prototype.deriveHardened = function(index) {
|
||||||
// Only derives hardened private keys by default
|
// Only derives hardened private keys by default
|
||||||
return this.derive(index + HDWallet.HIGHEST_BIT)
|
return this.derive(index + HDWallet.HIGHEST_BIT)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ function Wallet(seed, network) {
|
||||||
seed = seed || new Buffer(rng(32))
|
seed = seed || new Buffer(rng(32))
|
||||||
masterkey = HDNode.fromSeedBuffer(seed, network)
|
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
|
// See https://bitcointalk.org/index.php?topic=405179.msg4415254#msg4415254
|
||||||
accountZero = masterkey.derivePrivate(0)
|
accountZero = masterkey.deriveHardened(0)
|
||||||
externalAccount = accountZero.derive(0)
|
externalAccount = accountZero.derive(0)
|
||||||
internalAccount = accountZero.derive(1)
|
internalAccount = accountZero.derive(1)
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ describe('HDWallet', function() {
|
||||||
f.children.forEach(function(c, i) {
|
f.children.forEach(function(c, i) {
|
||||||
it(c.description + ' from ' + f.master.fingerprint, function() {
|
it(c.description + ' from ' + f.master.fingerprint, function() {
|
||||||
if (c.hardened) {
|
if (c.hardened) {
|
||||||
hd = hd.derivePrivate(c.m)
|
hd = hd.deriveHardened(c.m)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
hd = hd.derive(c.m)
|
hd = hd.derive(c.m)
|
||||||
|
@ -255,7 +255,7 @@ describe('HDWallet', function() {
|
||||||
var parent = HDWallet.fromBase58(f.master.base58)
|
var parent = HDWallet.fromBase58(f.master.base58)
|
||||||
|
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
parent.derivePrivate(c.m)
|
parent.deriveHardened(c.m)
|
||||||
}, /Could not derive hardened child key/)
|
}, /Could not derive hardened child key/)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue