Bugfix: Merkleroot not calculated correctly for multi-transaction blocks

This commit is contained in:
joshuayabut 2016-11-27 11:55:01 -05:00
parent 0789bfe61f
commit cb984a997d
1 changed files with 2 additions and 3 deletions

View File

@ -9,13 +9,12 @@ function calcRoot(hashes) {
}
exports.getRoot = function (rpcData, generateTxRaw) {
hashes = [generateTxRaw];
hashes = [util.reverseBuffer(Buffer(generateTxRaw, 'hex')).toString('hex')];
rpcData.transactions.forEach(function (value) {
hashes.push(value.hash);
});
if (hashes.length === 1) {
result = util.reverseBuffer(Buffer(hashes[0], 'hex')).toString('hex');
return result;
return hashes[0];
}
var result = calcRoot(hashes);
return result;