Fixed raven block processing
This commit is contained in:
12
index.js
12
index.js
@@ -42,10 +42,14 @@ function hash256(buffer) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getMerkleRoot(transactions) {
|
function getMerkleRoot(transactions) {
|
||||||
if (transactions.length === 0) return null;
|
// error
|
||||||
if (transactions.length === 1) return transactions[0].getHash();
|
if (transactions.length === 0) return new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex');
|
||||||
let hashes = [ reverseBuffer(transactions[0].getHash()).toString('hex') ];
|
// coinbase tx only
|
||||||
transactions.split(1).forEach(function (value) {
|
const txhash0 = transactions[0].getHash();
|
||||||
|
if (transactions.length === 1) return txhash0;
|
||||||
|
// have other txs
|
||||||
|
let hashes = [ reverseBuffer(txhash0).toString('hex') ];
|
||||||
|
transactions.slice(1).forEach(function (value) {
|
||||||
hashes.push(value.hash);
|
hashes.push(value.hash);
|
||||||
});
|
});
|
||||||
return reverseBuffer(new Buffer(Object.values(merklebitcoin(hashes))[2].root, 'hex'));
|
return reverseBuffer(new Buffer(Object.values(merklebitcoin(hashes))[2].root, 'hex'));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cryptoforknote-util",
|
"name": "cryptoforknote-util",
|
||||||
"version": "9.0.15",
|
"version": "9.0.16",
|
||||||
"main": "cryptoforknote-util",
|
"main": "cryptoforknote-util",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "LucasJones",
|
"name": "LucasJones",
|
||||||
|
|||||||
Reference in New Issue
Block a user