Compare commits

..

6 Commits

Author SHA1 Message Date
MoneroOcean 8e2572248d Fixed raven block prev hash calc 2020-12-09 00:39:02 +00:00
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
MoneroOcean a697f0fa32 Replaced deleted merkle-bitcoin repo 2020-12-01 17:14:59 +00:00
MoneroOcean bc501fcb4d Fixed extranonce location 2020-11-27 22:04:40 +00:00
2 changed files with 19 additions and 10 deletions
+17 -8
View File
@@ -62,12 +62,14 @@ 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
let blockHeightSerial = rpcData.height.toString(16).length % 2 === 0 ?
rpcData.height.toString(16) :
rpcData.height.toString(16) :
'0' + rpcData.height.toString(16);
const bytesHeight = Math.ceil((rpcData.height << 1).toString(2).length / 8);
bytesHeight = Math.ceil((rpcData.height << 1).toString(2).length / 8);
const lengthDiff = blockHeightSerial.length/2 - bytesHeight;
for (let i = 0; i < lengthDiff; i++) blockHeightSerial = blockHeightSerial + '00';
const serializedBlockHeight = new Buffer.concat([
@@ -136,7 +138,8 @@ module.exports.RavenBlockTemplate = function(rpcData, poolAddress) {
return {
blocktemplate_blob: blob.toString('hex'),
// reserved_offset to CCCCCC....
reserved_offset: offset1 + 4 /* txCoinbase.version */ + 1 /* vinLen */ + 32 /* hash */ + 4 /* index */ + 1 /* vScript len */,
reserved_offset: offset1 + 4 /* txCoinbase.version */ + 1 /* vinLen */ + 32 /* hash */ + 4 /* index */ +
1 /* vScript len */ + 1 /* coinbase height len */ + bytesHeight + 1 /* trailing zero byte */,
seed_hash: last_seed_hash.toString('hex'),
difficulty: difficulty,
height: rpcData.height,
@@ -144,22 +147,28 @@ 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);
const rpcData = { transactions: transactions.slice(1) };
reverseBuffer(getMerkleRoot(rpcData, transactions[0].getHash().toString('hex'))).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;
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "cryptoforknote-util",
"version": "9.0.2",
"version": "9.0.7",
"main": "cryptoforknote-util",
"author": {
"name": "LucasJones",
@@ -18,7 +18,7 @@
"sha3": "*",
"varuint-bitcoin": "^1.0.4",
"bitcoinjs-lib": "git+https://github.com/bitcoinjs/bitcoinjs-lib.git#533d6c2e6d0aa4111f7948b1c12003cf6ef83137",
"merkle-bitcoin": "git+https://github.com/joshuayabut/merkle-bitcoin.git#ec00ae20ba60d444e150ead03c747695ddaa83a1"
"merkle-bitcoin": "git+https://github.com/CloudMining/merkle-bitcoin.git#ec00ae20ba60d444e150ead03c747695ddaa83a1"
},
"keywords": [
"cryptonight",