block: add type checking
This commit is contained in:
parent
dd4596a44a
commit
4ee298c414
1 changed files with 3 additions and 0 deletions
|
@ -2,6 +2,8 @@ var bufferutils = require('./bufferutils')
|
|||
var bcrypto = require('./crypto')
|
||||
var bufferReverse = require('buffer-reverse')
|
||||
var fastMerkleRoot = require('merkle-lib/fastRoot')
|
||||
var typeforce = require('typeforce')
|
||||
var types = require('./types')
|
||||
|
||||
var Transaction = require('./transaction')
|
||||
|
||||
|
@ -134,6 +136,7 @@ Block.calculateTarget = function (bits) {
|
|||
}
|
||||
|
||||
Block.calculateMerkleRoot = function (transactions) {
|
||||
typeforce([{ getHash: types.Function }], transactions)
|
||||
if (transactions.length === 0) throw TypeError('Cannot compute merkle root for zero transactions')
|
||||
|
||||
var hashes = transactions.map(function (transaction) {
|
||||
|
|
Loading…
Add table
Reference in a new issue