Compare commits

..

3 Commits

Author SHA1 Message Date
MoneroOcean 0fc0e0ac9f Fixed merkle root hash calc 2020-12-08 22:42:29 +00:00
MoneroOcean e4d961cd99 Fixed merkle root hash calc 2020-12-08 22:42:15 +00:00
MoneroOcean 18eedca1e9 constructNewRavenBlob fix 2020-12-07 02:14:52 +00:00
2 changed files with 12 additions and 6 deletions
+11 -5
View File
@@ -62,6 +62,7 @@ const diff1 = 0x00000000ff000000000000000000000000000000000000000000000000000000
module.exports.RavenBlockTemplate = function(rpcData, poolAddress) {
const poolAddrHash = bitcoin.address.fromBase58Check(poolAddress).hash;
let txCoinbase = new bitcoin.Transaction();
let bytesHeight;
{ // input for coinbase tx
@@ -146,22 +147,27 @@ module.exports.RavenBlockTemplate = function(rpcData, poolAddress) {
};
};
module.exports.convertRavenBlob = function(blobBuffer) {
let header = blobBuffer.slice(0, 80); // header
function update_merkle_root_hash(blob_in, blob_out) {
let offset = 80 + 8 + 32;
const nTransactions = varuint.decode(blobBuffer, offset);
const nTransactions = varuint.decode(blob_in, offset);
offset += varuint.decode.bytes;
let transactions = [];
for (let i = 0; i < nTransactions; ++i) {
const tx = bitcoin.Transaction.fromBuffer(blobBuffer.slice(offset), true);
const tx = bitcoin.Transaction.fromBuffer(blob_in.slice(offset), true);
transactions.push(tx);
offset += tx.byteLength();
}
getMerkleRoot2(transactions).copy(header, 4 + 32);
reverseBuffer(getMerkleRoot2(transactions)).copy(blob_out, 4 + 32);
};
module.exports.convertRavenBlob = function(blobBuffer) {
let header = blobBuffer.slice(0, 80);
update_merkle_root_hash(blobBuffer, header);
return reverseBuffer(crypto.createHash('sha256').update(header).digest());
};
module.exports.constructNewRavenBlob = function(blockTemplate, nonceBuff, mixhashBuff) {
update_merkle_root_hash(blockTemplate, blockTemplate);
nonceBuff.copy (blockTemplate, 80, 0, 8);
mixhashBuff.copy(blockTemplate, 88, 0, 32);
return blockTemplate;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cryptoforknote-util",
"version": "9.0.4",
"version": "9.0.6",
"main": "cryptoforknote-util",
"author": {
"name": "LucasJones",