Fixed KCN blob contruction in all cases
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cryptoforknote-util",
|
"name": "cryptoforknote-util",
|
||||||
"version": "15.3.17",
|
"version": "15.3.18",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "LucasJones",
|
"name": "LucasJones",
|
||||||
"email": "lucasjonesdev@hotmail.co.uk"
|
"email": "lucasjonesdev@hotmail.co.uk"
|
||||||
|
|||||||
20
rtm.js
20
rtm.js
@@ -173,13 +173,13 @@ function createTransactionOutput(amount, payee, rewardToPool, reward, txOutputBu
|
|||||||
return { reward: reward - amount, rewardToPool: rewardToPool - amount };
|
return { reward: reward - amount, rewardToPool: rewardToPool - amount };
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateTransactionOutputs(rpcData, poolAddress, is_witness) {
|
function generateTransactionOutputs(rpcData, poolAddress) {
|
||||||
let reward = rpcData.coinbasevalue + (rpcData.coinbasedevreward ? rpcData.coinbasedevreward.value : 0);
|
let reward = rpcData.coinbasevalue + (rpcData.coinbasedevreward ? rpcData.coinbasedevreward.value : 0);
|
||||||
let rewardToPool = reward;
|
let rewardToPool = reward;
|
||||||
let txOutputBuffers = [];
|
let txOutputBuffers = [];
|
||||||
|
|
||||||
if (rpcData.coinbasedevreward) {
|
if (rpcData.coinbasedevreward) {
|
||||||
const rewards = createTransactionOutput(rpcData.coinbasedevreward.value, rpcData.coinbasedevreward.address, rewardToPool, reward, txOutputBuffers, Buffer.from(rpcData.coinbasedevreward.scriptpubkey, 'hex'));
|
const rewards = createTransactionOutput(rpcData.coinbasedevreward.value, null, rewardToPool, reward, txOutputBuffers, Buffer.from(rpcData.coinbasedevreward.scriptpubkey, 'hex'));
|
||||||
reward = rewards.reward;
|
reward = rewards.reward;
|
||||||
rewardToPool = rewards.rewardToPool;
|
rewardToPool = rewards.rewardToPool;
|
||||||
}
|
}
|
||||||
@@ -215,16 +215,16 @@ function generateTransactionOutputs(rpcData, poolAddress, is_witness) {
|
|||||||
|
|
||||||
createTransactionOutput(rewardToPool, null, rewardToPool, reward, txOutputBuffers, Buffer.from(addressToScript(poolAddress), "hex"));
|
createTransactionOutput(rewardToPool, null, rewardToPool, reward, txOutputBuffers, Buffer.from(addressToScript(poolAddress), "hex"));
|
||||||
|
|
||||||
if (is_witness) {
|
if (rpcData.default_witness_commitment) {
|
||||||
const witness_commitment = Buffer.from(rpcData.default_witness_commitment, 'hex');
|
createTransactionOutput(0, null, rewardToPool, reward, txOutputBuffers, Buffer.from(rpcData.default_witness_commitment, 'hex'));
|
||||||
txOutputBuffers.push(Buffer.concat([
|
txOutputBuffers.push(Buffer.concat([
|
||||||
varIntBuffer(1),
|
varIntBuffer(1),
|
||||||
varIntBuffer(witness_commitment.length),
|
varIntBuffer(32),
|
||||||
witness_commitment
|
Buffer.alloc(32, 0)
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Buffer.concat([ varIntBuffer(is_witness ? txOutputBuffers.length - 1 : txOutputBuffers.length), Buffer.concat(txOutputBuffers)]);
|
return Buffer.concat([ varIntBuffer(rpcData.default_witness_commitment ? txOutputBuffers.length - 1 : txOutputBuffers.length), Buffer.concat(txOutputBuffers)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
||||||
@@ -240,7 +240,7 @@ module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
|||||||
|
|
||||||
const scriptSigPart2 = serializeString('/nodeStratum/');
|
const scriptSigPart2 = serializeString('/nodeStratum/');
|
||||||
|
|
||||||
const is_witness = false;//rpcData.default_witness_commitment !== undefined;
|
const is_witness = rpcData.default_witness_commitment !== undefined;
|
||||||
|
|
||||||
const blob1 = Buffer.concat([
|
const blob1 = Buffer.concat([
|
||||||
coinbaseVersion,
|
coinbaseVersion,
|
||||||
@@ -281,7 +281,7 @@ module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
|||||||
// tx input scripts instead of size of script part so not sure how to parse them
|
// tx input scripts instead of size of script part so not sure how to parse them
|
||||||
// just drop them for now
|
// just drop them for now
|
||||||
// example: https://explorer.raptoreum.com/tx/1461d70fa8362b0896e2e9be6312521f2684f22c9b0f9152695f33f67d9f9d3f
|
// example: https://explorer.raptoreum.com/tx/1461d70fa8362b0896e2e9be6312521f2684f22c9b0f9152695f33f67d9f9d3f
|
||||||
/*rpcData.transactions.forEach(function(tx) {
|
rpcData.transactions.forEach(function(tx) {
|
||||||
if (tx.version != 1) {
|
if (tx.version != 1) {
|
||||||
try {
|
try {
|
||||||
bitcoin.Transaction.fromBuffer(Buffer.from(tx.data, 'hex'), false, false);
|
bitcoin.Transaction.fromBuffer(Buffer.from(tx.data, 'hex'), false, false);
|
||||||
@@ -293,7 +293,7 @@ module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
|||||||
} else {
|
} else {
|
||||||
console.error("Skip RTM v1 tx: " + tx.data);
|
console.error("Skip RTM v1 tx: " + tx.data);
|
||||||
}
|
}
|
||||||
});*/
|
});
|
||||||
const txn = varIntBuffer(txs.length + 1);
|
const txn = varIntBuffer(txs.length + 1);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user