Compare commits

...

4 Commits

Author SHA1 Message Date
MoneroOcean 9d722a83a3 Fixed raven block processing 2020-12-09 04:19:26 +00:00
MoneroOcean 16acb844d7 Fixed raven block processing 2020-12-09 04:19:15 +00:00
MoneroOcean 1647e8ccd6 Fixed raven block processing 2020-12-09 03:45:40 +00:00
MoneroOcean 95870f3f47 Fixed raven block processing 2020-12-09 03:07:40 +00:00
2 changed files with 12 additions and 10 deletions
+9 -8
View File
@@ -5,8 +5,8 @@ const bignum = require('bignum');
const bitcoin = require('bitcoinjs-lib');
const varuint = require('varuint-bitcoin');
const crypto = require('crypto');
const fastMerkleRoot = require('merkle-lib/fastRoot');
const promise = require('promise');
const merklebitcoin = promise.denodeify(require('merkle-bitcoin'));
function scriptCompile(addrHash) {
return bitcoin.script.compile([
@@ -43,10 +43,12 @@ function hash256(buffer) {
function getMerkleRoot(transactions) {
if (transactions.length === 0) return null;
const forWitness = txesHaveWitnessCommit(transactions);
const hashes = transactions.map(transaction => transaction.getHash(forWitness));
const rootHash = fastMerkleRoot(hashes, hash256);
return forWitness ? hash256(Buffer.concat([rootHash, transactions[0].ins[0].witness[0]])) : rootHash;
if (transactions.length === 1) return transactions[0].getHash();
let hashes = [ reverseBuffer(transactions[0]).toString('hex') ];
transactions.split(1).forEach(function (value) {
hashes.push(value.hash);
});
return reverseBuffer(new Buffer(Object.values(merklebitcoin(hashes))[2].root, 'hex'));
}
let last_epoch_number;
@@ -84,14 +86,13 @@ module.exports.RavenBlockTemplate = function(rpcData, poolAddress) {
txCoinbase.addOutput(new Buffer(rpcData.default_witness_commitment, 'hex'), 0);
}
}
const merkleRoot = new Buffer('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD', 'hex'); // 32 bytes
let header = new Buffer(80);
{ let position = 0;
header.writeUInt32BE(rpcData.height, position, 4); // height 42-46
header.write(rpcData.bits, position += 4, 4, 'hex'); // bits 47-50
header.writeUInt32BE(rpcData.curtime, position += 4, 4, 'hex'); // nTime 51-54
header.write(merkleRoot, position += 4, 32, 'hex'); // merkelRoot 55-87
header.write('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD', position += 4, 32, 'hex'); // merkelRoot 55-87
header.write(rpcData.previousblockhash, position += 32, 32, 'hex'); // prevblockhash 88-120
header.writeUInt32BE(rpcData.version, position += 32, 4); // version 121-153
header = reverseBuffer(header);
@@ -150,7 +151,7 @@ function update_merkle_root_hash(blob_in, blob_out) {
transactions.push(tx);
offset += tx.byteLength();
}
reverseBuffer(getMerkleRoot(transactions)).copy(blob_out, 4 + 32);
getMerkleRoot(transactions).copy(blob_out, 4 + 32);
};
module.exports.convertRavenBlob = function(blobBuffer) {
+3 -2
View File
@@ -1,6 +1,6 @@
{
"name": "cryptoforknote-util",
"version": "9.0.11",
"version": "9.0.14",
"main": "cryptoforknote-util",
"author": {
"name": "LucasJones",
@@ -17,7 +17,8 @@
"bignum": "^0.13.1",
"sha3": "*",
"varuint-bitcoin": "^1.0.4",
"bitcoinjs-lib": "git+https://github.com/bitcoinjs/bitcoinjs-lib.git#533d6c2e6d0aa4111f7948b1c12003cf6ef83137"
"bitcoinjs-lib": "git+https://github.com/bitcoinjs/bitcoinjs-lib.git#533d6c2e6d0aa4111f7948b1c12003cf6ef83137",
"merkle-bitcoin": "git+https://github.com/CloudMining/merkle-bitcoin.git#ec00ae20ba60d444e150ead03c747695ddaa83a1"
},
"keywords": [
"cryptonight",