Skip to content

Commit

Permalink
Core14 Evo Znodes
Browse files Browse the repository at this point in the history
  • Loading branch information
JCThePants committed Jun 10, 2020
1 parent d68471e commit 5140c5c
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions libs/class.Coinbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const
BUFFER_U32_ZERO = buffers.packUInt32LE(0),
BUFFER_VAR_ONE = buffers.packVarInt(1),
BUFFER_32_MAX = Buffer.from('FFFFFFFF', 'hex'),
BUFFER_TX_VERSION_1 = buffers.packUInt32LE(1),
BUFFER_TX_VERSION_3 = Buffer.from('03000500', 'hex'),
BUFFER_INPUT_HASH = buffers.packUInt256LE(0);


Expand Down Expand Up @@ -94,7 +94,7 @@ class Coinbase {
// First part of coinbase which is split at the extra nonce values
return Buffer.concat([

/* version */ BUFFER_TX_VERSION_1,
/* version */ BUFFER_TX_VERSION_3,

// Tx Inputs
/* input count */ BUFFER_VAR_ONE,
Expand Down Expand Up @@ -127,7 +127,8 @@ class Coinbase {
/* output count */ buffers.packVarInt(_._txCount),
/* outputs */ outputTxBuf,

/* lock time */ BUFFER_U32_ZERO
/* lock time */ BUFFER_U32_ZERO,
/* extra_payload */ _._getExtraPayloadBuf()
]);
}

Expand Down Expand Up @@ -179,10 +180,10 @@ class Coinbase {
_._addTransaction(outputTxsArr, feeRewardSt, feeScript);
_._addTransaction(outputTxsArr, poolRewardSt, poolAddressScript);

// Znodes
const znode = blockTemplate.znode;
if (znode && znode.payee)
_._addTransaction(outputTxsArr, znode.amount, scripts.makeAddressScript(znode.payee));
// Evo Znodes
blockTemplate.znode.forEach(entry => {
_._addTransaction(outputTxsArr, entry.amount, scripts.makeAddressScript(entry.payee));
});

return Buffer.concat(outputTxsArr);
}
Expand All @@ -197,6 +198,19 @@ class Coinbase {
);
_._txCount++;
}


_getExtraPayloadBuf() {

const _ = this;
const payload = Buffer.from(_._blockTemplate.coinbase_payload, 'hex');
const cbPayload = Buffer.alloc(1 + payload.length);

cbPayload.writeUInt8(payload.length, 0);
payload.copy(cbPayload, 1);

return cbPayload;
}
}

module.exports = Coinbase;

0 comments on commit 5140c5c

Please sign in to comment.