Fixes #167 and adds temporary test
This commit is contained in:
parent
bb80eda218
commit
ff08c2eec3
2 changed files with 13 additions and 1 deletions
|
@ -205,6 +205,7 @@ HDWallet.prototype.derive = function(i) {
|
|||
I = HmacFromBytesToBytes(SHA512, KPar.concat(iBytes), cPar)
|
||||
}
|
||||
|
||||
|
||||
// FIXME: Boo, CSJ.algo.SHA512 uses byte arrays
|
||||
I = new Buffer(I)
|
||||
|
||||
|
@ -225,7 +226,7 @@ HDWallet.prototype.derive = function(i) {
|
|||
hd.pub = hd.priv.pub
|
||||
} else {
|
||||
// Ki = (IL + kpar)*G = IL*G + Kpar
|
||||
var Ki = IL.multiply(ecparams.getG()).add(this.pub.Q)
|
||||
var Ki = ecparams.getG().multiply(IL).add(this.pub.Q)
|
||||
|
||||
hd.pub = new ECPubKey(Ki, true)
|
||||
}
|
||||
|
|
|
@ -231,6 +231,17 @@ describe('HDWallet', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('derive', function() {
|
||||
describe('m/0', function() {
|
||||
it('works', function() {
|
||||
var wallet = HDWallet.fromBase58('xpub6CxuB8ifZCMXeS3KbyNkYvrsJEHqxedCSiUhrNwH1nKtb8hcJpxDbDxkdoVCTR2bQ1G8hY4UMv85gef9SEpgFFUftBjt37FUSZxVx4AU9Qh').derive(0)
|
||||
|
||||
assert.equal(wallet.depth, 4)
|
||||
assert.equal(wallet.toBase58(), 'xpub6DyYbqDaPgHkj1Sk5EaqC4HgGN7xRePCGJeei9En2kCK8kZk8HRnnPuKSbNX6vwQVvmYnTPhK8vpUEXTBd5BQ9MUKBewhGJtL49YuUfQwJw')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('network types', function() {
|
||||
it('ensures that a bitcoin Wallet generates bitcoin addresses', function() {
|
||||
var wallet = new HDWallet(new Buffer('foobar'), 'bitcoin')
|
||||
|
|
Loading…
Reference in a new issue