From 8ddcf737f90d6b2b75e96d976274985cbaa3120f Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Tue, 3 May 2016 15:45:43 +0300 Subject: [PATCH] Update Transaction.isCoinbaseHash - add argument type-checking - replace Array.every on for-loop --- src/transaction.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/transaction.js b/src/transaction.js index c54cceb..13a853b 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -82,9 +82,11 @@ Transaction.fromHex = function (hex) { } Transaction.isCoinbaseHash = function (buffer) { - return Array.prototype.every.call(buffer, function (x) { - return x === 0 - }) + typeforce(types.Hash256bit, buffer) + for (var i = 0; i < 32; ++i) { + if (buffer[i] !== 0) return false + } + return true } Transaction.prototype.isCoinbase = function () {