Add overwinter support

This commit is contained in:
Beshoy Girgis 2018-07-08 03:59:50 -05:00
parent 768db03a54
commit 75916ebf6a
3 changed files with 15 additions and 10 deletions

View File

@ -8,7 +8,7 @@ var util = require('./util.js');
* The BlockTemplate class holds a single job.
* and provides several methods to validate and submit it to the daemon coin
**/
var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, extraNoncePlaceholder, reward, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress){
var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, extraNoncePlaceholder, reward, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress, overwinter){
//private members
var submits = [];
@ -48,7 +48,7 @@ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, extr
rpcData.rewardFees = this.rewardFees;
if (typeof this.genTx === 'undefined') {
this.genTx = transactions.createGeneration(rpcData.height, blockReward, this.rewardFees, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress, masternodeReward, masternodePayee, masternodePayment).toString('hex');
this.genTx = transactions.createGeneration(rpcData.height, blockReward, this.rewardFees, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress, masternodeReward, masternodePayee, masternodePayment, overwinter).toString('hex');
this.genTxHash = transactions.txHash();
/*

View File

@ -133,7 +133,8 @@ var JobManager = module.exports = function JobManager(options) {
options.coin.percentTreasuryReward,
options.coin.treasuryRewardStartBlockHeight,
options.coin.treasuryRewardAddressChangeInterval,
options.coin.vTreasuryRewardAddress
options.coin.vTreasuryRewardAddress,
options.coin.overwinter
);
_this.currentJob = tmpBlockTemplate;
@ -237,7 +238,7 @@ var JobManager = module.exports = function JobManager(options) {
let N = parameters.N || 200
let K = parameters.K || 9
let expectedLength = EH_PARAMS_MAP[`${N}_${K}`].SOLUTION_LENGTH || -1
let expectedLength = EH_PARAMS_MAP[`${N}_${K}`].SOLUTION_LENGTH || 2694
let solutionSlice = EH_PARAMS_MAP[`${N}_${K}`].SOLUTION_SLICE || 0
if (soln.length !== expectedLength) {

View File

@ -31,7 +31,7 @@ function scriptFoundersCompile(address){
}
exports.createGeneration = function(blockHeight, blockReward, feeReward, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress, masternodeReward, masternodePayee, masternodePayment) {
exports.createGeneration = function(blockHeight, blockReward, feeReward, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress, masternodeReward, masternodePayee, masternodePayment, overwinter) {
var poolAddrHash = bitcoin.address.fromBase58Check(poolAddress).hash;
if (masternodePayee !== undefined) {
var masternodeAddrHash = bitcoin.address.fromBase58Check(masternodePayee).hash;
@ -41,6 +41,10 @@ exports.createGeneration = function(blockHeight, blockReward, feeReward, recipie
}
var tx = new bitcoin.Transaction();
if (overwinter) {
tx.setOverwinter();
}
// input for coinbase tx
if (blockHeight.toString(16).length % 2 === 0) {
var blockHeightSerial = blockHeight.toString(16);