Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/hdnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ HDNode.HIGHEST_BIT = 0x80000000
HDNode.LENGTH = 78

HDNode.fromSeedBuffer = function(seed, network) {
assert(Buffer.isBuffer(seed), 'Expected Buffer, got' + seed)
assert(seed.length >= 16, 'Seed should be at least 128 bits')
assert(seed.length <= 64, 'Seed should be at most 512 bits')

var I = crypto.HmacSHA512(seed, HDNode.MASTER_SECRET)
var IL = I.slice(0, 32)
var IR = I.slice(32)
Expand Down
4 changes: 3 additions & 1 deletion src/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ Transaction.prototype.addOutput = function(scriptPubKey, value) {
scriptPubKey = address.toOutputScript()
}

assert(scriptPubKey instanceof Script, 'Expected Address or Script, got ' + scriptPubKey)

return (this.outs.push({
script: scriptPubKey,
value: value,
value: value
}) - 1)
}

Expand Down
12 changes: 12 additions & 0 deletions test/hdnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ describe('HDNode', function() {
assert.equal(hd.chainCode.toString('hex'), f.master.chainCode)
})
})

it('throws on low entropy seed', function() {
assert.throws(function() {
HDNode.fromSeedHex('ffffffffff')
}, /Seed should be at least 128 bits/)
})

it('throws on too high entropy seed', function() {
assert.throws(function() {
HDNode.fromSeedHex('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff')
}, /Seed should be at most 512 bits/)
})
})

describe('toBase58', function() {
Expand Down