From 4ee298c414a3dcdf549692602868fec0e8a09bf6 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Sat, 8 Oct 2016 12:08:07 +1100 Subject: [PATCH] block: add type checking --- src/block.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/block.js b/src/block.js index 23ae976..8e608e8 100644 --- a/src/block.js +++ b/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) {