Add overwinter support
This commit is contained in:
parent
768db03a54
commit
75916ebf6a
|
@ -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 = [];
|
||||
|
@ -24,11 +24,11 @@ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, extr
|
|||
|
||||
// generate the fees and coinbase tx
|
||||
var blockReward = (this.rpcData.miner) * 100000000;
|
||||
|
||||
|
||||
var masternodeReward;
|
||||
var masternodePayee;
|
||||
var masternodePayment;
|
||||
|
||||
|
||||
if (payFoundersReward === true) {
|
||||
if (!this.rpcData.founders || this.rpcData.founders.length <= 0) {
|
||||
console.log('Error, founders reward missing for block template!');
|
||||
|
@ -39,7 +39,7 @@ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, extr
|
|||
masternodeReward = rpcData.payee_amount;
|
||||
masternodePayee = rpcData.payee;
|
||||
masternodePayment = rpcData.masternode_payments;
|
||||
|
||||
|
||||
var fees = [];
|
||||
rpcData.transactions.forEach(function(value) {
|
||||
fees.push(value);
|
||||
|
@ -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();
|
||||
|
||||
/*
|
||||
|
@ -95,14 +95,14 @@ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, extr
|
|||
if (Math.abs(txCount.length % 2) == 1) {
|
||||
txCount = "0" + txCount;
|
||||
}
|
||||
|
||||
|
||||
if (this.txCount <= 0x7f){
|
||||
var varInt = new Buffer(txCount, 'hex');
|
||||
}
|
||||
else if (this.txCount <= 0x7fff){
|
||||
var varInt = new Buffer.concat([Buffer('FD', 'hex'), new Buffer(txCount, 'hex')]);
|
||||
}
|
||||
|
||||
|
||||
buf = new Buffer.concat([
|
||||
header,
|
||||
soln,
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue