Browse Source

block: add type checking

hk-custom-address
Daniel Cousens 8 years ago
committed by Daniel Cousens
parent
commit
4ee298c414
  1. 3
      src/block.js

3
src/block.js

@ -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…
Cancel
Save