Fixed KCN blob contruction in all cases
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cryptoforknote-util",
|
||||
"version": "15.3.17",
|
||||
"version": "15.3.18",
|
||||
"author": {
|
||||
"name": "LucasJones",
|
||||
"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 };
|
||||
}
|
||||
|
||||
function generateTransactionOutputs(rpcData, poolAddress, is_witness) {
|
||||
function generateTransactionOutputs(rpcData, poolAddress) {
|
||||
let reward = rpcData.coinbasevalue + (rpcData.coinbasedevreward ? rpcData.coinbasedevreward.value : 0);
|
||||
let rewardToPool = reward;
|
||||
let txOutputBuffers = [];
|
||||
|
||||
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;
|
||||
rewardToPool = rewards.rewardToPool;
|
||||
}
|
||||
@@ -215,16 +215,16 @@ function generateTransactionOutputs(rpcData, poolAddress, is_witness) {
|
||||
|
||||
createTransactionOutput(rewardToPool, null, rewardToPool, reward, txOutputBuffers, Buffer.from(addressToScript(poolAddress), "hex"));
|
||||
|
||||
if (is_witness) {
|
||||
const witness_commitment = Buffer.from(rpcData.default_witness_commitment, 'hex');
|
||||
if (rpcData.default_witness_commitment) {
|
||||
createTransactionOutput(0, null, rewardToPool, reward, txOutputBuffers, Buffer.from(rpcData.default_witness_commitment, 'hex'));
|
||||
txOutputBuffers.push(Buffer.concat([
|
||||
varIntBuffer(1),
|
||||
varIntBuffer(witness_commitment.length),
|
||||
witness_commitment
|
||||
varIntBuffer(32),
|
||||
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) {
|
||||
@@ -240,7 +240,7 @@ module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
||||
|
||||
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([
|
||||
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
|
||||
// just drop them for now
|
||||
// example: https://explorer.raptoreum.com/tx/1461d70fa8362b0896e2e9be6312521f2684f22c9b0f9152695f33f67d9f9d3f
|
||||
/*rpcData.transactions.forEach(function(tx) {
|
||||
rpcData.transactions.forEach(function(tx) {
|
||||
if (tx.version != 1) {
|
||||
try {
|
||||
bitcoin.Transaction.fromBuffer(Buffer.from(tx.data, 'hex'), false, false);
|
||||
@@ -293,7 +293,7 @@ module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
||||
} else {
|
||||
console.error("Skip RTM v1 tx: " + tx.data);
|
||||
}
|
||||
});*/
|
||||
});
|
||||
const txn = varIntBuffer(txs.length + 1);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user