Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 170d0c0ec9 | |||
| 5548c6de53 | |||
| 56ea8f3792 |
@@ -164,10 +164,14 @@ function update_merkle_root_hash(offset, payload, blob_in, blob_out) {
|
|||||||
getMerkleRoot(transactions).copy(blob_out, 4 + 32);
|
getMerkleRoot(transactions).copy(blob_out, 4 + 32);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.blockHashBuff = function(blobBuffer) {
|
||||||
|
return reverseBuffer(hash256(blobBuffer));
|
||||||
|
};
|
||||||
|
|
||||||
module.exports.convertRavenBlob = function(blobBuffer) {
|
module.exports.convertRavenBlob = function(blobBuffer) {
|
||||||
let header = blobBuffer.slice(0, 80);
|
let header = blobBuffer.slice(0, 80);
|
||||||
update_merkle_root_hash(80 + 8 + 32, false, blobBuffer, header);
|
update_merkle_root_hash(80 + 8 + 32, false, blobBuffer, header);
|
||||||
return reverseBuffer(hash256(header));
|
return module.exports.blockHashBuff(header);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.constructNewRavenBlob = function(blockTemplate, nonceBuff, mixhashBuff) {
|
module.exports.constructNewRavenBlob = function(blockTemplate, nonceBuff, mixhashBuff) {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cryptoforknote-util",
|
"name": "cryptoforknote-util",
|
||||||
"version": "11.0.0",
|
"version": "11.0.2",
|
||||||
"main": "cryptoforknote-util",
|
"main": "cryptoforknote-util",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "LucasJones",
|
"name": "LucasJones",
|
||||||
|
|||||||
@@ -248,17 +248,18 @@ module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
|||||||
Buffer.from(rpcData.coinbase_payload, 'hex')
|
Buffer.from(rpcData.coinbase_payload, 'hex')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const prev_hash = reverseBuffer(Buffer.from(rpcData.previousblockhash, 'hex')).toString('hex');
|
||||||
const version = packInt32LE(rpcData.version).toString('hex');
|
const version = packInt32LE(rpcData.version).toString('hex');
|
||||||
const curtime = packUInt32LE(rpcData.curtime).toString('hex');
|
const curtime = packUInt32LE(rpcData.curtime).toString('hex');
|
||||||
let bits = Buffer.from(rpcData.bits, 'hex');
|
let bits = Buffer.from(rpcData.bits, 'hex');
|
||||||
bits.writeUInt32LE(bits.readUInt32BE());
|
bits.writeUInt32LE(bits.readUInt32BE());
|
||||||
const txn = varIntBuffer(rpcData.transactions.length + 1);
|
const txn = varIntBuffer(rpcData.transactions.length + 1);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
difficulty: parseFloat((diff1 / bignum(rpcData.target, 16).toNumber()).toFixed(9)),
|
difficulty: parseFloat((diff1 / bignum(rpcData.target, 16).toNumber()).toFixed(9)),
|
||||||
height: rpcData.height,
|
height: rpcData.height,
|
||||||
prev_hash: rpcData.previousblockhash,
|
prev_hash: prev_hash,
|
||||||
blocktemplate_blob: version + rpcData.previousblockhash + Buffer.alloc(32, 0).toString('hex') + curtime + bits.toString('hex') + Buffer.alloc(4, 0).toString('hex') +
|
blocktemplate_blob: version + prev_hash + Buffer.alloc(32, 0).toString('hex') + curtime + bits.toString('hex') + Buffer.alloc(4, 0).toString('hex') +
|
||||||
txn.toString('hex') + blob1.toString('hex') + Buffer.alloc(extraNoncePlaceholderLength, 0xCC).toString('hex') + blob2.toString('hex') +
|
txn.toString('hex') + blob1.toString('hex') + Buffer.alloc(extraNoncePlaceholderLength, 0xCC).toString('hex') + blob2.toString('hex') +
|
||||||
Buffer.concat(rpcData.transactions.map(function(tx) { return Buffer.from(tx.data, 'hex'); })).toString('hex'),
|
Buffer.concat(rpcData.transactions.map(function(tx) { return Buffer.from(tx.data, 'hex'); })).toString('hex'),
|
||||||
reserved_offset: 80 + txn.length + blob1.length
|
reserved_offset: 80 + txn.length + blob1.length
|
||||||
|
|||||||
Reference in New Issue
Block a user